Patchwork [3,of,3,chg] chgserver: respect detailed exit code in case of ConfigError

login
register
mail settings
Submitter Pulkit Goyal
Date Dec. 18, 2020, 8:46 a.m.
Message ID <f928cc73e4fea7c16462.1608281181@DESKTOP-STQPTJK>
Download mbox | patch
Permalink /patch/47931/
State Accepted
Headers show

Comments

Pulkit Goyal - Dec. 18, 2020, 8:46 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1608279806 -19800
#      Fri Dec 18 13:53:26 2020 +0530
# Node ID f928cc73e4fea7c16462ea20895f8dfd650d4b90
# Parent  9f0555329584b3e91e74e0606d66d16dd7a4c82f
# EXP-Topic chg-test
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.

Patch

diff -r 9f0555329584 -r f928cc73e4fe mercurial/chgserver.py
--- a/mercurial/chgserver.py	Tue Dec 08 17:10:03 2020 +0530
+++ 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
 
diff -r 9f0555329584 -r f928cc73e4fe tests/test-chg.t
--- a/tests/test-chg.t	Tue Dec 08 17:10:03 2020 +0530
+++ 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
 
diff -r 9f0555329584 -r f928cc73e4fe tests/test-config.t
--- a/tests/test-config.t	Tue Dec 08 17:10:03 2020 +0530
+++ 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