Patchwork D8383: rust-chg: update name of the server process

login
register
mail settings
Submitter phabricator
Date April 9, 2020, 7:26 p.m.
Message ID <613b882cab674ff6ee9d57ffe57ce762@localhost.localdomain>
Download mbox | patch
Permalink /patch/46051/
State Not Applicable
Headers show

Comments

phabricator - April 9, 2020, 7:26 p.m.
Closed by commit rHG80d6e3415636: rust-chg: update name of the server process (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/D8383?vs=20999&id=21021

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

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

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

CHANGE DETAILS




To: yuja, #hg-reviewers, Alphare
Cc: Alphare, 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
@@ -196,6 +196,17 @@ 
                 Ok((loc, client))
             })
             .and_then(|(loc, client)| {
+                // It's purely optional, and the server might not support this command.
+                if client.server_spec().capabilities.contains("setprocname") {
+                    let fut = client
+                        .set_process_name(format!("chg[worker/{}]", loc.process_id))
+                        .map(|client| (loc, client));
+                    Either::A(fut)
+                } else {
+                    Either::B(future::ok((loc, client)))
+                }
+            })
+            .and_then(|(loc, client)| {
                 client
                     .set_current_dir(&loc.current_dir)
                     .map(|client| (loc, client))
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
@@ -42,6 +42,11 @@ 
         I: IntoIterator<Item = (P, P)>,
         P: AsRef<OsStr>;
 
+    /// Changes the process title of the server.
+    fn set_process_name<P>(self, name: P) -> OneShotRequest<C>
+    where
+        P: AsRef<OsStr>;
+
     /// Changes the umask of the server process.
     fn set_umask(self, mask: u32) -> OneShotRequest<C>;
 
@@ -94,6 +99,13 @@ 
         OneShotRequest::start_with_args(self, b"setenv", message::pack_env_vars_os(vars))
     }
 
+    fn set_process_name<P>(self, name: P) -> OneShotRequest<C>
+    where
+        P: AsRef<OsStr>,
+    {
+        OneShotRequest::start_with_args(self, b"setprocname", name.as_ref().as_bytes())
+    }
+
     fn set_umask(self, mask: u32) -> OneShotRequest<C> {
         let mut args = BytesMut::with_capacity(mem::size_of_val(&mask));
         args.put_u32_be(mask);