# HG changeset patch # User Yuya Nishihara # Date 1538662068 -32400 # Node ID 97e6d435ff7ee69e9b6a6739c36908f829b8118f # Parent 8a7beeea655f12d5962319a3cfe3db470122b17a rust-chg: send client-side environment variables to server This is also needed to run config validation. The "validate" request and its response handling will be implemented in the next batch. Differential Revision: https://phab.mercurial-scm.org/D8364 diff -r 8a7beeea655f -r 97e6d435ff7e rust/chg/src/clientext.rs --- a/rust/chg/src/clientext.rs Thu Oct 04 23:01:34 2018 +0900 +++ b/rust/chg/src/clientext.rs Thu Oct 04 23:07:48 2018 +0900 @@ -33,6 +33,12 @@ where P: AsRef; + /// Updates the environment variables of the server. + fn set_env_vars_os(self, vars: I) -> OneShotRequest + where + I: IntoIterator, + P: AsRef; + /// Runs the specified Mercurial command with cHg extension. fn run_command_chg(self, handler: H, args: I) -> ChgRunCommand where @@ -61,6 +67,14 @@ OneShotRequest::start_with_args(self, b"chdir", dir.as_ref().as_os_str().as_bytes()) } + fn set_env_vars_os(self, vars: I) -> OneShotRequest + where + I: IntoIterator, + P: AsRef, + { + OneShotRequest::start_with_args(self, b"setenv", message::pack_env_vars_os(vars)) + } + fn run_command_chg(self, handler: H, args: I) -> ChgRunCommand where I: IntoIterator, diff -r 8a7beeea655f -r 97e6d435ff7e rust/chg/src/locator.rs --- a/rust/chg/src/locator.rs Thu Oct 04 23:01:34 2018 +0900 +++ b/rust/chg/src/locator.rs Thu Oct 04 23:07:48 2018 +0900 @@ -24,7 +24,7 @@ use super::message::ServerSpec; use super::procutil; -const REQUIRED_SERVER_CAPABILITIES: &[&str] = &["attachio", "chdir", "runcommand"]; +const REQUIRED_SERVER_CAPABILITIES: &[&str] = &["attachio", "chdir", "runcommand", "setenv"]; /// Helper to connect to and spawn a server process. #[derive(Clone, Debug)] @@ -86,6 +86,11 @@ .set_current_dir(&loc.current_dir) .map(|client| (loc, client)) }) + .and_then(|(loc, client)| { + client + .set_env_vars_os(loc.env_vars.iter().cloned()) + .map(|client| (loc, client)) + }) } /// Spawns new server process and connects to it.