errors: use InputError for errors about bad label names (tags etc)
authorMartin von Zweigbergk <martinvonz@google.com>
Thu, 12 Nov 2020 10:35:33 -0800
changeset 45864 f96fa4de5055
parent 45863 3175b0e0058b
child 45865 96ca817ec192
errors: use InputError for errors about bad label names (tags etc) Differential Revision: https://phab.mercurial-scm.org/D9327
mercurial/scmutil.py
tests/test-bookmarks.t
tests/test-branch-change.t
tests/test-branches.t
tests/test-tag.t
--- a/mercurial/scmutil.py	Thu Nov 12 09:53:14 2020 -0800
+++ b/mercurial/scmutil.py	Thu Nov 12 10:35:33 2020 -0800
@@ -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):
--- a/tests/test-bookmarks.t	Thu Nov 12 09:53:14 2020 -0800
+++ b/tests/test-bookmarks.t	Thu Nov 12 10:35:33 2020 -0800
@@ -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
 
--- a/tests/test-branch-change.t	Thu Nov 12 09:53:14 2020 -0800
+++ b/tests/test-branch-change.t	Thu Nov 12 10:35:33 2020 -0800
@@ -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
 
--- a/tests/test-branches.t	Thu Nov 12 09:53:14 2020 -0800
+++ b/tests/test-branches.t	Thu Nov 12 10:35:33 2020 -0800
@@ -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
 
--- a/tests/test-tag.t	Thu Nov 12 09:53:14 2020 -0800
+++ b/tests/test-tag.t	Thu Nov 12 10:35:33 2020 -0800
@@ -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