Patchwork D9630: errors: respect ui.detailed-exit-code in chg

login
register
mail settings
Submitter phabricator
Date Dec. 17, 2020, 6:48 p.m.
Message ID <differential-rev-PHID-DREV-3lh6acxfsvghcw476twm-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47928/
State Superseded
Headers show

Comments

phabricator - Dec. 17, 2020, 6:48 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This fixes `test-globalopts.t`, which has been failing since
  db5dddb38f5b <https://phab.mercurial-scm.org/rHGdb5dddb38f5b95e626d6659f3e4be7e0c7403693> (errors: raise InputError on early parse error in
  dispatch, 2020-11-23).

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/chgserver.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -505,6 +505,7 @@ 
         """
         args = self._readlist()
         errorraised = False
+        detailed_exit_code = 255
         try:
             self.ui, lui = _loadnewui(self.ui, args, self.cdebug)
         except error.RepoError as inst:
@@ -515,12 +516,17 @@ 
                 self.ui.error(_(b"(%s)\n") % inst.hint)
             errorraised = True
         except error.Abort as inst:
+            if isinstance(inst, error.InputError):
+                detailed_exit_code = 10
             self.ui.error(inst.format())
             errorraised = True
 
         if errorraised:
             self.ui.flush()
-            self.cresult.write(b'exit 255')
+            exit_code = 255
+            if self.ui.configbool(b'ui', b'detailed-exit-code'):
+                exit_code = detailed_exit_code
+            self.cresult.write(b'exit %d' % exit_code)
             return
         newhash = hashstate.fromui(lui, self.hashstate.mtimepaths)
         insts = []