errors: respect ui.detailed-exit-code in chg
authorMartin von Zweigbergk <martinvonz@google.com>
Thu, 17 Dec 2020 10:43:43 -0800
changeset 46143 dadca47e3d4d
parent 46142 634cea2c247f
child 46144 e4f6dae01b3b
errors: respect ui.detailed-exit-code in chg This fixes `test-globalopts.t`, which has been failing since db5dddb38f5b (errors: raise InputError on early parse error in dispatch, 2020-11-23). Differential Revision: https://phab.mercurial-scm.org/D9630
mercurial/chgserver.py
--- a/mercurial/chgserver.py	Thu Dec 17 13:33:27 2020 -0500
+++ b/mercurial/chgserver.py	Thu Dec 17 10:43:43 2020 -0800
@@ -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 = []