##// END OF EJS Templates
rust-chg: add interface to run "validate" request...
Yuya Nishihara -
r45171:43513444 default
parent child Browse files
Show More
@@ -5,15 +5,17 b''
5
5
6 //! cHg extensions to command server client.
6 //! cHg extensions to command server client.
7
7
8 use bytes::Bytes;
8 use std::ffi::OsStr;
9 use std::ffi::OsStr;
10 use std::io;
9 use std::os::unix::ffi::OsStrExt;
11 use std::os::unix::ffi::OsStrExt;
10 use std::os::unix::io::AsRawFd;
12 use std::os::unix::io::AsRawFd;
11 use std::path::Path;
13 use std::path::Path;
12 use tokio_hglib::protocol::OneShotRequest;
14 use tokio_hglib::protocol::{OneShotQuery, OneShotRequest};
13 use tokio_hglib::{Client, Connection};
15 use tokio_hglib::{Client, Connection};
14
16
15 use super::attachio::AttachIo;
17 use super::attachio::AttachIo;
16 use super::message;
18 use super::message::{self, Instruction};
17 use super::runcommand::ChgRunCommand;
19 use super::runcommand::ChgRunCommand;
18 use super::uihandler::SystemHandler;
20 use super::uihandler::SystemHandler;
19
21
@@ -45,6 +47,19 b' where'
45 I: IntoIterator<Item = P>,
47 I: IntoIterator<Item = P>,
46 P: AsRef<OsStr>,
48 P: AsRef<OsStr>,
47 H: SystemHandler;
49 H: SystemHandler;
50
51 /// Validates if the server can run Mercurial commands with the expected
52 /// configuration.
53 ///
54 /// The `args` should contain early command arguments such as `--config`
55 /// and `-R`.
56 ///
57 /// Client-side environment must be sent prior to this request, by
58 /// `set_current_dir()` and `set_env_vars_os()`.
59 fn validate<I, P>(self, args: I) -> OneShotQuery<C, fn(Bytes) -> io::Result<Vec<Instruction>>>
60 where
61 I: IntoIterator<Item = P>,
62 P: AsRef<OsStr>;
48 }
63 }
49
64
50 impl<C> ChgClientExt<C> for Client<C>
65 impl<C> ChgClientExt<C> for Client<C>
@@ -83,4 +98,17 b' where'
83 {
98 {
84 ChgRunCommand::with_client(self, handler, message::pack_args_os(args))
99 ChgRunCommand::with_client(self, handler, message::pack_args_os(args))
85 }
100 }
101
102 fn validate<I, P>(self, args: I) -> OneShotQuery<C, fn(Bytes) -> io::Result<Vec<Instruction>>>
103 where
104 I: IntoIterator<Item = P>,
105 P: AsRef<OsStr>,
106 {
107 OneShotQuery::start_with_args(
108 self,
109 b"validate",
110 message::pack_args_os(args),
111 message::parse_instructions,
112 )
113 }
86 }
114 }
General Comments 0
You need to be logged in to leave comments. Login now