30 I: AsRawFd, |
30 I: AsRawFd, |
31 O: AsRawFd, |
31 O: AsRawFd, |
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<P>(self, dir: P) -> OneShotRequest<C> |
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 I: IntoIterator<Item = (P, P)>, |
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<P>(self, name: P) -> OneShotRequest<C> |
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 |
61 /// configuration. |
59 /// configuration. |
62 /// |
60 /// |
63 /// The `args` should contain early command arguments such as `--config` |
61 /// The `args` should contain early command arguments such as `--config` |
64 /// and `-R`. |
62 /// and `-R`. |
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 I: IntoIterator<Item = P>, |
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> |
75 where |
73 where |
76 C: Connection + AsRawFd, |
74 C: Connection + AsRawFd, |
82 E: AsRawFd, |
80 E: AsRawFd, |
83 { |
81 { |
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<P>(self, dir: P) -> OneShotRequest<C> |
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 I: IntoIterator<Item = (P, P)>, |
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<P>(self, name: P) -> OneShotRequest<C> |
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 |
109 fn set_umask(self, mask: u32) -> OneShotRequest<C> { |
100 fn set_umask(self, mask: u32) -> OneShotRequest<C> { |
110 let mut args = BytesMut::with_capacity(mem::size_of_val(&mask)); |
101 let mut args = BytesMut::with_capacity(mem::size_of_val(&mask)); |
111 args.put_u32_be(mask); |
102 args.put_u32_be(mask); |
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 I: IntoIterator<Item = P>, |
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", |
132 message::pack_args_os(args), |
124 message::pack_args_os(args), |
133 message::parse_instructions, |
125 message::parse_instructions, |