Patchwork D8362: rust-chg: move set_current_dir() to Locator

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

Comments

phabricator - April 3, 2020, 7:17 p.m.
Closed by commit rHG0a2516efc463: rust-chg: move set_current_dir() to Locator (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/D8362?vs=20964&id=20991

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

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

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

CHANGE DETAILS




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

Patch

diff --git a/rust/chg/src/main.rs b/rust/chg/src/main.rs
--- a/rust/chg/src/main.rs
+++ b/rust/chg/src/main.rs
@@ -73,14 +73,12 @@ 
 }
 
 fn run() -> io::Result<i32> {
-    let current_dir = env::current_dir()?;
     let loc = Locator::prepare_from_env()?;
     let handler = ChgUiHandler::new();
     let (result_tx, result_rx) = oneshot::channel();
     let fut = loc
         .connect()
-        .and_then(|(_, client)| client.set_current_dir(current_dir))
-        .and_then(|client| client.attach_io(io::stdin(), io::stdout(), io::stderr()))
+        .and_then(|(_, client)| client.attach_io(io::stdin(), io::stdout(), io::stderr()))
         .and_then(|client| {
             let pid = client.server_spec().process_id.unwrap();
             let pgid = client.server_spec().process_group_id;
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
@@ -20,6 +20,7 @@ 
 use tokio_process::{Child, CommandExt};
 use tokio_timer;
 
+use super::clientext::ChgClientExt;
 use super::message::ServerSpec;
 use super::procutil;
 
@@ -80,6 +81,11 @@ 
                 check_server_capabilities(client.server_spec())?;
                 Ok((loc, client))
             })
+            .and_then(|(loc, client)| {
+                client
+                    .set_current_dir(&loc.current_dir)
+                    .map(|client| (loc, client))
+            })
     }
 
     /// Spawns new server process and connects to it.