Patchwork D8364: rust-chg: send client-side environment variables to server

login
register
mail settings
Submitter phabricator
Date April 3, 2020, 7:17 p.m.
Message ID <e5d1f1dca5e034ffe3b246c3c877bdc0@localhost.localdomain>
Download mbox | patch
Permalink /patch/46023/
State Not Applicable
Headers show

Comments

phabricator - April 3, 2020, 7:17 p.m.
Closed by commit rHG97e6d435ff7e: rust-chg: send client-side environment variables to server (authored by yuja).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8364?vs=20966&id=20993

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8364/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8364

AFFECTED FILES
  rust/chg/src/clientext.rs
  rust/chg/src/locator.rs

CHANGE DETAILS




To: yuja, #hg-reviewers, Alphare
Cc: mercurial-devel

Patch

diff --git a/rust/chg/src/locator.rs b/rust/chg/src/locator.rs
--- a/rust/chg/src/locator.rs
+++ b/rust/chg/src/locator.rs
@@ -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.
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
@@ -33,6 +33,12 @@ 
     where
         P: AsRef<Path>;
 
+    /// Updates the environment variables of the server.
+    fn set_env_vars_os<I, P>(self, vars: I) -> OneShotRequest<C>
+    where
+        I: IntoIterator<Item = (P, P)>,
+        P: AsRef<OsStr>;
+
     /// Runs the specified Mercurial command with cHg extension.
     fn run_command_chg<I, P, H>(self, handler: H, args: I) -> ChgRunCommand<C, H>
     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<I, P>(self, vars: I) -> OneShotRequest<C>
+    where
+        I: IntoIterator<Item = (P, P)>,
+        P: AsRef<OsStr>,
+    {
+        OneShotRequest::start_with_args(self, b"setenv", message::pack_env_vars_os(vars))
+    }
+
     fn run_command_chg<I, P, H>(self, handler: H, args: I) -> ChgRunCommand<C, H>
     where
         I: IntoIterator<Item = P>,