Patchwork D9387: errors: raise ConfigError on early parse error in dispatch

login
register
mail settings
Submitter phabricator
Date Nov. 24, 2020, 6:07 p.m.
Message ID <differential-rev-PHID-DREV-b2wnx24w7nkb7izpjatm-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47666/
State Superseded
Headers show

Comments

phabricator - Nov. 24, 2020, 6:07 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I didn't think this would have any effect on the tests, but it does
  because the catching in `scmutil.callcatch()` still happens. That's
  because `dispatch` passes in the function that includes the parsing as
  an argument to that function.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dispatch.py
  tests/test-globalopts.t
  tests/test-legacy-exit-code.t

CHANGE DETAILS




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

Patch

diff --git a/tests/test-legacy-exit-code.t b/tests/test-legacy-exit-code.t
--- a/tests/test-legacy-exit-code.t
+++ b/tests/test-legacy-exit-code.t
@@ -36,7 +36,7 @@ 
   [255]
 
   $ hg st --config a=b
-  abort: malformed --config option: 'a=b' (use --config section.name=value)
+  config error: malformed --config option: 'a=b' (use --config section.name=value)
   [255]
 
   $ echo b > a
diff --git a/tests/test-globalopts.t b/tests/test-globalopts.t
--- a/tests/test-globalopts.t
+++ b/tests/test-globalopts.t
@@ -216,20 +216,20 @@ 
   $ hg --cwd c --config paths.quuxfoo=bar paths | grep quuxfoo > /dev/null && echo quuxfoo
   quuxfoo
   $ hg --cwd c --config '' tip -q
-  abort: malformed --config option: '' (use --config section.name=value)
-  [255]
+  config error: malformed --config option: '' (use --config section.name=value)
+  [30]
   $ hg --cwd c --config a.b tip -q
-  abort: malformed --config option: 'a.b' (use --config section.name=value)
-  [255]
+  config error: malformed --config option: 'a.b' (use --config section.name=value)
+  [30]
   $ hg --cwd c --config a tip -q
-  abort: malformed --config option: 'a' (use --config section.name=value)
-  [255]
+  config error: malformed --config option: 'a' (use --config section.name=value)
+  [30]
   $ hg --cwd c --config a.= tip -q
-  abort: malformed --config option: 'a.=' (use --config section.name=value)
-  [255]
+  config error: malformed --config option: 'a.=' (use --config section.name=value)
+  [30]
   $ hg --cwd c --config .b= tip -q
-  abort: malformed --config option: '.b=' (use --config section.name=value)
-  [255]
+  config error: malformed --config option: '.b=' (use --config section.name=value)
+  [30]
 
 Testing --debug:
 
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -828,7 +828,7 @@ 
             ui.setconfig(section, name, value, b'--config')
             configs.append((section, name, value))
         except (IndexError, ValueError):
-            raise error.Abort(
+            raise error.ConfigError(
                 _(
                     b'malformed --config option: %r '
                     b'(use --config section.name=value)'