Patchwork D8402: rust-chg: move get_umask() call out of run() function

login
register
mail settings
Submitter phabricator
Date April 14, 2020, 4:41 p.m.
Message ID <480114c9746581ee3f4f1a19e5aa9cc2@localhost.localdomain>
Download mbox | patch
Permalink /patch/46100/
State Not Applicable
Headers show

Comments

phabricator - April 14, 2020, 4:41 p.m.
Closed by commit rHG5ac5c25ea97b: rust-chg: move get_umask() call out of run() function (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/D8402?vs=21037&id=21073

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

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

AFFECTED FILES
  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
@@ -59,15 +59,15 @@ 
 
     // TODO: add loop detection by $CHGINTERNALMARK
 
-    let code = run().unwrap_or_else(|err| {
+    let umask = unsafe { procutil::get_umask() }; // not thread safe
+    let code = run(umask).unwrap_or_else(|err| {
         writeln!(io::stderr(), "chg: abort: {}", err).unwrap_or(());
         255
     });
     process::exit(code);
 }
 
-fn run() -> io::Result<i32> {
-    let umask = unsafe { procutil::get_umask() }; // not thread safe
+fn run(umask: u32) -> io::Result<i32> {
     let mut loc = Locator::prepare_from_env()?;
     loc.set_early_args(locator::collect_early_args(env::args_os().skip(1)));
     let handler = ChgUiHandler::new();