D9311: errors: set detailed exit code to 30 for config errors

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Thu Nov 12 16:39:37 UTC 2020


martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is per https://www.mercurial-scm.org/wiki/ErrorCategoriesPlan.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/scmutil.py
  tests/test-add.t
  tests/test-convert-git.t
  tests/test-merge1.t
  tests/test-phases.t
  tests/test-repo-compengines.t

CHANGE DETAILS

diff --git a/tests/test-repo-compengines.t b/tests/test-repo-compengines.t
--- a/tests/test-repo-compengines.t
+++ b/tests/test-repo-compengines.t
@@ -131,7 +131,7 @@
   $ commitone zlib-level-invalid
   abort: storage.revlog.zlib.level is not a valid integer ('foobar')
   abort: storage.revlog.zlib.level is not a valid integer ('foobar')
-  [255]
+  [30]
 
   $ hg init zlib-level-out-of-range
   $ cat << EOF >> zlib-level-out-of-range/.hg/hgrc
@@ -188,7 +188,7 @@
   $ commitone zstd-level-invalid
   abort: storage.revlog.zstd.level is not a valid integer ('foobar')
   abort: storage.revlog.zstd.level is not a valid integer ('foobar')
-  [255]
+  [30]
 
   $ hg init zstd-level-out-of-range --config format.revlog-compression=zstd
   $ cat << EOF >> zstd-level-out-of-range/.hg/hgrc
diff --git a/tests/test-phases.t b/tests/test-phases.t
--- a/tests/test-phases.t
+++ b/tests/test-phases.t
@@ -513,7 +513,7 @@
   transaction abort!
   rollback completed
   abort: phases.new-commit: not a valid phase name ('babar')
-  [255]
+  [30]
 Test phase command
 ===================
 
diff --git a/tests/test-merge1.t b/tests/test-merge1.t
--- a/tests/test-merge1.t
+++ b/tests/test-merge1.t
@@ -139,7 +139,7 @@
 bad config
   $ hg merge 1 --config merge.checkunknown=x
   abort: merge.checkunknown not valid ('x' is none of 'abort', 'ignore', 'warn')
-  [255]
+  [30]
 this merge should fail
   $ hg merge 1 --config merge.checkunknown=abort
   b: untracked file differs
diff --git a/tests/test-convert-git.t b/tests/test-convert-git.t
--- a/tests/test-convert-git.t
+++ b/tests/test-convert-git.t
@@ -333,7 +333,7 @@
 input validation
   $ hg convert --config convert.git.similarity=foo --datesort git-repo2 fullrepo
   abort: convert.git.similarity is not a valid integer ('foo')
-  [255]
+  [30]
   $ hg convert --config convert.git.similarity=-1 --datesort git-repo2 fullrepo
   abort: similarity must be between 0 and 100
   [255]
diff --git a/tests/test-add.t b/tests/test-add.t
--- a/tests/test-add.t
+++ b/tests/test-add.t
@@ -45,7 +45,7 @@
   $ echo foo > con.xml
   $ hg --config ui.portablefilenames=jump add con.xml
   abort: ui.portablefilenames value is invalid ('jump')
-  [255]
+  [30]
   $ hg --config ui.portablefilenames=abort add con.xml
   abort: filename contains 'con', which is reserved on Windows: con.xml
   [255]
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -226,6 +226,8 @@
             detailed_exit_code = 10
         elif isinstance(inst, error.StateError):
             detailed_exit_code = 20
+        elif isinstance(inst, error.ConfigError):
+            detailed_exit_code = 30
         ui.error(_(b"abort: %s\n") % inst.message)
         if inst.hint:
             ui.error(_(b"(%s)\n") % inst.hint)



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


More information about the Mercurial-devel mailing list