diff --git a/rust/chg/src/clientext.rs b/rust/chg/src/clientext.rs --- a/rust/chg/src/clientext.rs +++ b/rust/chg/src/clientext.rs @@ -6,8 +6,11 @@ //! cHg extensions to command server client. use std::ffi::OsStr; +use std::os::unix::ffi::OsStrExt; use std::os::unix::io::AsRawFd; +use std::path::Path; use tokio_hglib::{Client, Connection}; +use tokio_hglib::protocol::OneShotRequest; use super::attachio::AttachIo; use super::message; @@ -23,6 +26,10 @@ pub trait ChgClientExt O: AsRawFd, E: AsRawFd; + /// Changes the working directory of the server. + fn set_current_dir

(self, dir: P) -> OneShotRequest + where P: AsRef; + /// Runs the specified Mercurial command with cHg extension. fn run_command_chg(self, handler: H, args: I) -> ChgRunCommand where I: IntoIterator, @@ -41,6 +48,12 @@ impl ChgClientExt for Client AttachIo::with_client(self, stdin, stdout, Some(stderr)) } + fn set_current_dir

(self, dir: P) -> OneShotRequest + where P: AsRef, + { + OneShotRequest::start_with_args(self, b"chdir", dir.as_ref().as_os_str().as_bytes()) + } + fn run_command_chg(self, handler: H, args: I) -> ChgRunCommand where I: IntoIterator, P: AsRef,