chgserver: respect detailed exit code in case of ConfigError
authorPulkit Goyal <7895pulkit@gmail.com>
Fri, 18 Dec 2020 13:53:26 +0530
changeset 46145 6383bb86b700
parent 46144 e4f6dae01b3b
child 46146 d109dda4a3e7
chgserver: respect detailed exit code in case of ConfigError This effectively backs out 60523483897cf8caf7718aaf81c58d4d9fd5e1fa which was a bandaid. Martin yesterday fixed a similar failure which motivated me to fix it the correct way.
mercurial/chgserver.py
tests/test-chg.t
tests/test-config.t
--- a/mercurial/chgserver.py	Thu Dec 17 18:08:25 2020 +0100
+++ b/mercurial/chgserver.py	Fri Dec 18 13:53:26 2020 +0530
@@ -518,6 +518,8 @@
         except error.Abort as inst:
             if isinstance(inst, error.InputError):
                 detailed_exit_code = 10
+            elif isinstance(inst, error.ConfigError):
+                detailed_exit_code = 30
             self.ui.error(inst.format())
             errorraised = True
 
--- a/tests/test-chg.t	Thu Dec 17 18:08:25 2020 +0100
+++ b/tests/test-chg.t	Fri Dec 18 13:53:26 2020 +0530
@@ -30,7 +30,7 @@
   $ echo '=brokenconfig' >> $HGRCPATH
   $ chg status
   config error at * =brokenconfig (glob)
-  [255]
+  [30]
 
   $ cp $HGRCPATH.orig $HGRCPATH
 
--- a/tests/test-config.t	Thu Dec 17 18:08:25 2020 +0100
+++ b/tests/test-config.t	Fri Dec 18 13:53:26 2020 +0530
@@ -6,59 +6,35 @@
   $ cat > .hg/hgrc << EOF
   > novaluekey
   > EOF
-#if chg
-  $ hg showconfig
-  config error at $TESTTMP/.hg/hgrc:1: novaluekey
-  [255]
-#else
   $ hg showconfig
   config error at $TESTTMP/.hg/hgrc:1: novaluekey
   [30]
-#endif
 
 Invalid syntax: no key
 
   $ cat > .hg/hgrc << EOF
   > =nokeyvalue
   > EOF
-#if chg
-  $ hg showconfig
-  config error at $TESTTMP/.hg/hgrc:1: =nokeyvalue
-  [255]
-#else
   $ hg showconfig
   config error at $TESTTMP/.hg/hgrc:1: =nokeyvalue
   [30]
-#endif
 
 Test hint about invalid syntax from leading white space
 
   $ cat > .hg/hgrc << EOF
   >  key=value
   > EOF
-#if chg
-  $ hg showconfig
-  config error at $TESTTMP/.hg/hgrc:1: unexpected leading whitespace:  key=value
-  [255]
-#else
   $ hg showconfig
   config error at $TESTTMP/.hg/hgrc:1: unexpected leading whitespace:  key=value
   [30]
-#endif
 
   $ cat > .hg/hgrc << EOF
   >  [section]
   > key=value
   > EOF
-#if chg
-  $ hg showconfig
-  config error at $TESTTMP/.hg/hgrc:1: unexpected leading whitespace:  [section]
-  [255]
-#else
   $ hg showconfig
   config error at $TESTTMP/.hg/hgrc:1: unexpected leading whitespace:  [section]
   [30]
-#endif
 
 Reset hgrc