diff rust/chg/src/locator.rs @ 44684:80d6e3415636

rust-chg: update name of the server process This is a copy of updateprocname() of hgclient.c. At this point, rust-chg is basically functional. I did dogfooding for a couple of weeks in 2018. There are a few remaining tasks: a. loop detection by CHGINTERNALMARK b. forward unsupported commands (notably serve -d) to real hg c. better handling of early server exception d. modernize codebase (2018 edition, impl trait, async/await) For (d), we'll probably want to switch to async-std, but I'm thinking of upgrading to Tokio 0.2 as an intermediate step since process API isn't ported to async-std yet. I'm pretty sure future migration to async-std will be painless compared to the mass rewrite from futures-0.1 to 0.3. https://github.com/async-rs/async-std/issues/22 Differential Revision: https://phab.mercurial-scm.org/D8383
author Yuya Nishihara <yuya@tcha.org>
date Mon, 19 Nov 2018 20:50:45 +0900
parents 065048e66f32
children 1f5ab1a9363d
line wrap: on
line diff
--- a/rust/chg/src/locator.rs	Thu Oct 04 22:44:37 2018 +0900
+++ b/rust/chg/src/locator.rs	Mon Nov 19 20:50:45 2018 +0900
@@ -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))