D9327: errors: use InputError for errors about bad label names (tags etc)

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Tue Nov 17 00:28:56 UTC 2020


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

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/scmutil.py
  tests/test-bookmarks.t
  tests/test-branch-change.t
  tests/test-branches.t
  tests/test-tag.t

CHANGE DETAILS

diff --git a/tests/test-tag.t b/tests/test-tag.t
--- a/tests/test-tag.t
+++ b/tests/test-tag.t
@@ -64,13 +64,13 @@
   [10]
   $ hg tag tap nada dot tip
   abort: the name 'tip' is reserved
-  [255]
+  [10]
   $ hg tag .
   abort: the name '.' is reserved
-  [255]
+  [10]
   $ hg tag null
   abort: the name 'null' is reserved
-  [255]
+  [10]
   $ hg tag "bleah"
   abort: tag 'bleah' already exists (use -f to force)
   [10]
@@ -157,10 +157,10 @@
   $ hg tag -l 'xx
   > newline'
   abort: '\n' cannot be used in a name
-  [255]
+  [10]
   $ hg tag -l 'xx:xx'
   abort: ':' cannot be used in a name
-  [255]
+  [10]
 
 cloning local tags
 
diff --git a/tests/test-branches.t b/tests/test-branches.t
--- a/tests/test-branches.t
+++ b/tests/test-branches.t
@@ -51,24 +51,24 @@
 
   $ hg branch tip
   abort: the name 'tip' is reserved
-  [255]
+  [10]
   $ hg branch null
   abort: the name 'null' is reserved
-  [255]
+  [10]
   $ hg branch .
   abort: the name '.' is reserved
-  [255]
+  [10]
 
 invalid characters
 
   $ hg branch 'foo:bar'
   abort: ':' cannot be used in a name
-  [255]
+  [10]
 
   $ hg branch 'foo
   > bar'
   abort: '\n' cannot be used in a name
-  [255]
+  [10]
 
 trailing or leading spaces should be stripped before testing duplicates
 
diff --git a/tests/test-branch-change.t b/tests/test-branch-change.t
--- a/tests/test-branch-change.t
+++ b/tests/test-branch-change.t
@@ -40,13 +40,13 @@
 
   $ hg branch -r . a:b
   abort: ':' cannot be used in a name
-  [255]
+  [10]
   $ hg branch -r . tip
   abort: the name 'tip' is reserved
-  [255]
+  [10]
   $ hg branch -r . 1234
   abort: cannot use an integer as a name
-  [255]
+  [10]
 
 Change on non-linear set of commits
 
diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
--- a/tests/test-bookmarks.t
+++ b/tests/test-bookmarks.t
@@ -396,15 +396,15 @@
 
   $ hg bookmark tip
   abort: the name 'tip' is reserved
-  [255]
+  [10]
 
   $ hg bookmark .
   abort: the name '.' is reserved
-  [255]
+  [10]
 
   $ hg bookmark null
   abort: the name 'null' is reserved
-  [255]
+  [10]
 
 
 bookmark with existing name
@@ -431,7 +431,7 @@
 
   $ hg bookmark 10
   abort: cannot use an integer as a name
-  [255]
+  [10]
 
 bookmark with a name that matches a node id
   $ hg bookmark 925d80f479bb db815d6d32e6 --config "$TESTHOOK"
@@ -538,12 +538,12 @@
 
   $ hg bookmark 'foo:bar'
   abort: ':' cannot be used in a name
-  [255]
+  [10]
 
   $ hg bookmark 'foo
   > bar'
   abort: '\n' cannot be used in a name
-  [255]
+  [10]
 
 the bookmark extension should be ignored now that it is part of core
 
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -293,19 +293,21 @@
     # Do not use the "kind" parameter in ui output.
     # It makes strings difficult to translate.
     if lbl in [b'tip', b'.', b'null']:
-        raise error.Abort(_(b"the name '%s' is reserved") % lbl)
+        raise error.InputError(_(b"the name '%s' is reserved") % lbl)
     for c in (b':', b'\0', b'\n', b'\r'):
         if c in lbl:
-            raise error.Abort(
+            raise error.InputError(
                 _(b"%r cannot be used in a name") % pycompat.bytestr(c)
             )
     try:
         int(lbl)
-        raise error.Abort(_(b"cannot use an integer as a name"))
+        raise error.InputError(_(b"cannot use an integer as a name"))
     except ValueError:
         pass
     if lbl.strip() != lbl:
-        raise error.Abort(_(b"leading or trailing whitespace in name %r") % lbl)
+        raise error.InputError(
+            _(b"leading or trailing whitespace in name %r") % lbl
+        )
 
 
 def checkfilename(f):



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


More information about the Mercurial-devel mailing list