Patchwork D3446: dispatch: move sys.exit() to caller (API)

login
register
mail settings
Submitter phabricator
Date May 6, 2018, 4:11 a.m.
Message ID <differential-rev-PHID-DREV-fl24vcfjnbe6427vpga4-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/31281/
State New
Headers show

Comments

phabricator - May 6, 2018, 4:11 a.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Moving sys.exit() to the caller will make it easier to implement
  exit handling in Rust `hg` by eliminating the need to handle
  SystemExit in Rust.
  
  .. api::
  
    dispatch.run() now returns an integer exit code instead of calling
    sys.exit(). Callers of dispatch.run() must now exit.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  contrib/hgperf
  hg
  mercurial/dispatch.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -145,7 +145,7 @@ 
             # There's not much we can do about I/O errors at this point.
             code = -1
 
-    sys.exit(code & 255)
+    return code & 255
 
 if pycompat.ispy3:
     def _initstdio():
diff --git a/hg b/hg
--- a/hg
+++ b/hg
@@ -38,4 +38,4 @@ 
     sys.exit(-1)
 
 from mercurial import dispatch
-dispatch.run()
+sys.exit(dispatch.run())
diff --git a/contrib/hgperf b/contrib/hgperf
--- a/contrib/hgperf
+++ b/contrib/hgperf
@@ -94,4 +94,4 @@ 
 
 dispatch.runcommand = runcommand
 
-dispatch.run()
+sys.exit(dispatch.run())