Show More
@@ -32,29 +32,27 b' where' | |||||
32 | E: AsRawFd; |
|
32 | E: AsRawFd; | |
33 |
|
33 | |||
34 | /// Changes the working directory of the server. |
|
34 | /// Changes the working directory of the server. | |
35 |
fn set_current_dir |
|
35 | fn set_current_dir(self, dir: impl AsRef<Path>) -> OneShotRequest<C>; | |
36 | where |
|
|||
37 | P: AsRef<Path>; |
|
|||
38 |
|
36 | |||
39 | /// Updates the environment variables of the server. |
|
37 | /// Updates the environment variables of the server. | |
40 | fn set_env_vars_os<I, P>(self, vars: I) -> OneShotRequest<C> |
|
38 | fn set_env_vars_os( | |
41 | where |
|
39 | self, | |
42 |
|
|
40 | vars: impl IntoIterator<Item = (impl AsRef<OsStr>, impl AsRef<OsStr>)>, | |
43 | P: AsRef<OsStr>; |
|
41 | ) -> OneShotRequest<C>; | |
44 |
|
42 | |||
45 | /// Changes the process title of the server. |
|
43 | /// Changes the process title of the server. | |
46 |
fn set_process_name |
|
44 | fn set_process_name(self, name: impl AsRef<OsStr>) -> OneShotRequest<C>; | |
47 | where |
|
|||
48 | P: AsRef<OsStr>; |
|
|||
49 |
|
45 | |||
50 | /// Changes the umask of the server process. |
|
46 | /// Changes the umask of the server process. | |
51 | fn set_umask(self, mask: u32) -> OneShotRequest<C>; |
|
47 | fn set_umask(self, mask: u32) -> OneShotRequest<C>; | |
52 |
|
48 | |||
53 | /// Runs the specified Mercurial command with cHg extension. |
|
49 | /// Runs the specified Mercurial command with cHg extension. | |
54 | fn run_command_chg<I, P, H>(self, handler: H, args: I) -> ChgRunCommand<C, H> |
|
50 | fn run_command_chg<H>( | |
|
51 | self, | |||
|
52 | handler: H, | |||
|
53 | args: impl IntoIterator<Item = impl AsRef<OsStr>>, | |||
|
54 | ) -> ChgRunCommand<C, H> | |||
55 | where |
|
55 | where | |
56 | I: IntoIterator<Item = P>, |
|
|||
57 | P: AsRef<OsStr>, |
|
|||
58 | H: SystemHandler; |
|
56 | H: SystemHandler; | |
59 |
|
57 | |||
60 | /// Validates if the server can run Mercurial commands with the expected |
|
58 | /// Validates if the server can run Mercurial commands with the expected | |
@@ -65,10 +63,10 b' where' | |||||
65 | /// |
|
63 | /// | |
66 | /// Client-side environment must be sent prior to this request, by |
|
64 | /// Client-side environment must be sent prior to this request, by | |
67 | /// `set_current_dir()` and `set_env_vars_os()`. |
|
65 | /// `set_current_dir()` and `set_env_vars_os()`. | |
68 | fn validate<I, P>(self, args: I) -> OneShotQuery<C, fn(Bytes) -> io::Result<Vec<Instruction>>> |
|
66 | fn validate( | |
69 | where |
|
67 | self, | |
70 |
|
|
68 | args: impl IntoIterator<Item = impl AsRef<OsStr>>, | |
71 | P: AsRef<OsStr>; |
|
69 | ) -> OneShotQuery<C, fn(Bytes) -> io::Result<Vec<Instruction>>>; | |
72 | } |
|
70 | } | |
73 |
|
71 | |||
74 | impl<C> ChgClientExt<C> for Client<C> |
|
72 | impl<C> ChgClientExt<C> for Client<C> | |
@@ -84,25 +82,18 b' where' | |||||
84 | AttachIo::with_client(self, stdin, stdout, Some(stderr)) |
|
82 | AttachIo::with_client(self, stdin, stdout, Some(stderr)) | |
85 | } |
|
83 | } | |
86 |
|
84 | |||
87 |
fn set_current_dir |
|
85 | fn set_current_dir(self, dir: impl AsRef<Path>) -> OneShotRequest<C> { | |
88 | where |
|
|||
89 | P: AsRef<Path>, |
|
|||
90 | { |
|
|||
91 | OneShotRequest::start_with_args(self, b"chdir", dir.as_ref().as_os_str().as_bytes()) |
|
86 | OneShotRequest::start_with_args(self, b"chdir", dir.as_ref().as_os_str().as_bytes()) | |
92 | } |
|
87 | } | |
93 |
|
88 | |||
94 | fn set_env_vars_os<I, P>(self, vars: I) -> OneShotRequest<C> |
|
89 | fn set_env_vars_os( | |
95 | where |
|
90 | self, | |
96 |
|
|
91 | vars: impl IntoIterator<Item = (impl AsRef<OsStr>, impl AsRef<OsStr>)>, | |
97 | P: AsRef<OsStr>, |
|
92 | ) -> OneShotRequest<C> { | |
98 | { |
|
|||
99 | OneShotRequest::start_with_args(self, b"setenv", message::pack_env_vars_os(vars)) |
|
93 | OneShotRequest::start_with_args(self, b"setenv", message::pack_env_vars_os(vars)) | |
100 | } |
|
94 | } | |
101 |
|
95 | |||
102 |
fn set_process_name |
|
96 | fn set_process_name(self, name: impl AsRef<OsStr>) -> OneShotRequest<C> { | |
103 | where |
|
|||
104 | P: AsRef<OsStr>, |
|
|||
105 | { |
|
|||
106 | OneShotRequest::start_with_args(self, b"setprocname", name.as_ref().as_bytes()) |
|
97 | OneShotRequest::start_with_args(self, b"setprocname", name.as_ref().as_bytes()) | |
107 | } |
|
98 | } | |
108 |
|
99 | |||
@@ -112,20 +103,21 b' where' | |||||
112 | OneShotRequest::start_with_args(self, b"setumask2", args) |
|
103 | OneShotRequest::start_with_args(self, b"setumask2", args) | |
113 | } |
|
104 | } | |
114 |
|
105 | |||
115 | fn run_command_chg<I, P, H>(self, handler: H, args: I) -> ChgRunCommand<C, H> |
|
106 | fn run_command_chg<H>( | |
|
107 | self, | |||
|
108 | handler: H, | |||
|
109 | args: impl IntoIterator<Item = impl AsRef<OsStr>>, | |||
|
110 | ) -> ChgRunCommand<C, H> | |||
116 | where |
|
111 | where | |
117 | I: IntoIterator<Item = P>, |
|
|||
118 | P: AsRef<OsStr>, |
|
|||
119 | H: SystemHandler, |
|
112 | H: SystemHandler, | |
120 | { |
|
113 | { | |
121 | ChgRunCommand::with_client(self, handler, message::pack_args_os(args)) |
|
114 | ChgRunCommand::with_client(self, handler, message::pack_args_os(args)) | |
122 | } |
|
115 | } | |
123 |
|
116 | |||
124 | fn validate<I, P>(self, args: I) -> OneShotQuery<C, fn(Bytes) -> io::Result<Vec<Instruction>>> |
|
117 | fn validate( | |
125 | where |
|
118 | self, | |
126 |
|
|
119 | args: impl IntoIterator<Item = impl AsRef<OsStr>>, | |
127 | P: AsRef<OsStr>, |
|
120 | ) -> OneShotQuery<C, fn(Bytes) -> io::Result<Vec<Instruction>>> { | |
128 | { |
|
|||
129 | OneShotQuery::start_with_args( |
|
121 | OneShotQuery::start_with_args( | |
130 | self, |
|
122 | self, | |
131 | b"validate", |
|
123 | b"validate", |
@@ -75,11 +75,7 b' impl Locator {' | |||||
75 | } |
|
75 | } | |
76 |
|
76 | |||
77 | /// Specifies the arguments to be passed to the server at start. |
|
77 | /// Specifies the arguments to be passed to the server at start. | |
78 |
pub fn set_early_args |
|
78 | pub fn set_early_args(&mut self, args: impl IntoIterator<Item = impl AsRef<OsStr>>) { | |
79 | where |
|
|||
80 | I: IntoIterator<Item = P>, |
|
|||
81 | P: AsRef<OsStr>, |
|
|||
82 | { |
|
|||
83 | self.hg_early_args = args.into_iter().map(|a| a.as_ref().to_owned()).collect(); |
|
79 | self.hg_early_args = args.into_iter().map(|a| a.as_ref().to_owned()).collect(); | |
84 | } |
|
80 | } | |
85 |
|
81 | |||
@@ -358,10 +354,7 b' fn default_timeout() -> Duration {' | |||||
358 | /// Creates a directory which the other users cannot access to. |
|
354 | /// Creates a directory which the other users cannot access to. | |
359 | /// |
|
355 | /// | |
360 | /// If the directory already exists, tests its permission. |
|
356 | /// If the directory already exists, tests its permission. | |
361 |
fn create_secure_dir |
|
357 | fn create_secure_dir(path: impl AsRef<Path>) -> io::Result<()> { | |
362 | where |
|
|||
363 | P: AsRef<Path>, |
|
|||
364 | { |
|
|||
365 | DirBuilder::new() |
|
358 | DirBuilder::new() | |
366 | .mode(0o700) |
|
359 | .mode(0o700) | |
367 | .create(path.as_ref()) |
|
360 | .create(path.as_ref()) | |
@@ -404,11 +397,7 b' fn check_server_capabilities(spec: &Serv' | |||||
404 | } |
|
397 | } | |
405 |
|
398 | |||
406 | /// Collects arguments which need to be passed to the server at start. |
|
399 | /// Collects arguments which need to be passed to the server at start. | |
407 |
pub fn collect_early_args |
|
400 | pub fn collect_early_args(args: impl IntoIterator<Item = impl AsRef<OsStr>>) -> Vec<OsString> { | |
408 | where |
|
|||
409 | I: IntoIterator<Item = P>, |
|
|||
410 | P: AsRef<OsStr>, |
|
|||
411 | { |
|
|||
412 | let mut args_iter = args.into_iter(); |
|
401 | let mut args_iter = args.into_iter(); | |
413 | let mut early_args = Vec::new(); |
|
402 | let mut early_args = Vec::new(); | |
414 | while let Some(arg) = args_iter.next() { |
|
403 | while let Some(arg) = args_iter.next() { |
@@ -113,11 +113,9 b' const INITIAL_PACKED_ENV_VARS_CAPACITY: ' | |||||
113 | /// |
|
113 | /// | |
114 | /// Panics if key or value contains `\0` character, or key contains '=' |
|
114 | /// Panics if key or value contains `\0` character, or key contains '=' | |
115 | /// character. |
|
115 | /// character. | |
116 |
pub fn pack_env_vars_os |
|
116 | pub fn pack_env_vars_os( | |
117 | where |
|
117 | vars: impl IntoIterator<Item = (impl AsRef<OsStr>, impl AsRef<OsStr>)>, | |
118 | I: IntoIterator<Item = (P, P)>, |
|
118 | ) -> Bytes { | |
119 | P: AsRef<OsStr>, |
|
|||
120 | { |
|
|||
121 | let mut vars_iter = vars.into_iter(); |
|
119 | let mut vars_iter = vars.into_iter(); | |
122 | if let Some((k, v)) = vars_iter.next() { |
|
120 | if let Some((k, v)) = vars_iter.next() { | |
123 | let mut dst = BytesMut::with_capacity(INITIAL_PACKED_ENV_VARS_CAPACITY); |
|
121 | let mut dst = BytesMut::with_capacity(INITIAL_PACKED_ENV_VARS_CAPACITY); | |
@@ -143,17 +141,11 b' fn pack_env_into(dst: &mut BytesMut, k: ' | |||||
143 | dst.put_slice(v.as_bytes()); |
|
141 | dst.put_slice(v.as_bytes()); | |
144 | } |
|
142 | } | |
145 |
|
143 | |||
146 |
fn decode_latin1 |
|
144 | fn decode_latin1(s: impl AsRef<[u8]>) -> String { | |
147 | where |
|
|||
148 | S: AsRef<[u8]>, |
|
|||
149 | { |
|
|||
150 | s.as_ref().iter().map(|&c| c as char).collect() |
|
145 | s.as_ref().iter().map(|&c| c as char).collect() | |
151 | } |
|
146 | } | |
152 |
|
147 | |||
153 |
fn new_parse_error |
|
148 | fn new_parse_error(error: impl Into<Box<dyn error::Error + Send + Sync>>) -> io::Error { | |
154 | where |
|
|||
155 | E: Into<Box<dyn error::Error + Send + Sync>>, |
|
|||
156 | { |
|
|||
157 | io::Error::new(io::ErrorKind::InvalidData, error) |
|
149 | io::Error::new(io::ErrorKind::InvalidData, error) | |
158 | } |
|
150 | } | |
159 |
|
151 |
General Comments 0
You need to be logged in to leave comments.
Login now