changeset 46117:6cc269bd1c29

errors: raise more specifc errors from narrowcommands Differential Revision: https://phab.mercurial-scm.org/D9386
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 18 Nov 2020 23:37:09 -0800
parents 17a695357270
children db5dddb38f5b
files hgext/narrow/narrowcommands.py tests/test-narrow-clone-no-ellipsis.t tests/test-narrow-clone.t tests/test-narrow-trackedcmd.t tests/test-narrow.t
diffstat 5 files changed, 17 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/narrow/narrowcommands.py	Wed Dec 09 19:40:30 2020 -0800
+++ b/hgext/narrow/narrowcommands.py	Wed Nov 18 23:37:09 2020 -0800
@@ -103,7 +103,7 @@
 
         includes, excludes, profiles = sparse.parseconfig(ui, fdata, b'narrow')
         if profiles:
-            raise error.Abort(
+            raise error.ConfigError(
                 _(
                     b"cannot specify other files using '%include' in"
                     b" narrowspec"
@@ -252,7 +252,7 @@
                 % (len(visibletostrip) - maxnodes)
             )
         if not force:
-            raise error.Abort(
+            raise error.StateError(
                 _(b'local changes found'),
                 hint=_(b'use --force-delete-local-changes to ignore'),
             )
@@ -487,7 +487,7 @@
     """
     opts = pycompat.byteskwargs(opts)
     if requirements.NARROW_REQUIREMENT not in repo.requirements:
-        raise error.Abort(
+        raise error.InputError(
             _(
                 b'the tracked command is only supported on '
                 b'repositories cloned with --narrow'
@@ -497,7 +497,7 @@
     # Before supporting, decide whether it "hg tracked --clear" should mean
     # tracking no paths or all paths.
     if opts[b'clear']:
-        raise error.Abort(_(b'the --clear option is not yet supported'))
+        raise error.InputError(_(b'the --clear option is not yet supported'))
 
     # import rules from a file
     newrules = opts.get(b'import_rules')
@@ -506,7 +506,7 @@
             filepath = os.path.join(encoding.getcwd(), newrules)
             fdata = util.readfile(filepath)
         except IOError as inst:
-            raise error.Abort(
+            raise error.StorageError(
                 _(b"cannot read narrowspecs from '%s': %s")
                 % (filepath, encoding.strtolocal(inst.strerror))
             )
@@ -514,7 +514,7 @@
             ui, fdata, b'narrow'
         )
         if profiles:
-            raise error.Abort(
+            raise error.InputError(
                 _(
                     b"including other spec files using '%include' "
                     b"is not supported in narrowspec"
--- a/tests/test-narrow-clone-no-ellipsis.t	Wed Dec 09 19:40:30 2020 -0800
+++ b/tests/test-narrow-clone-no-ellipsis.t	Wed Nov 18 23:37:09 2020 -0800
@@ -136,8 +136,8 @@
 
   $ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs
   reading narrowspec from '$TESTTMP/narrowspecs'
-  abort: cannot specify other files using '%include' in narrowspec
-  [255]
+  config error: cannot specify other files using '%include' in narrowspec
+  [30]
 
   $ cat > narrowspecs <<EOF
   > [include]
--- a/tests/test-narrow-clone.t	Wed Dec 09 19:40:30 2020 -0800
+++ b/tests/test-narrow-clone.t	Wed Nov 18 23:37:09 2020 -0800
@@ -254,8 +254,8 @@
 
   $ hg clone ssh://user@dummy/master specfile --narrowspec narrowspecs
   reading narrowspec from '$TESTTMP/narrowspecs'
-  abort: cannot specify other files using '%include' in narrowspec
-  [255]
+  config error: cannot specify other files using '%include' in narrowspec
+  [30]
 
   $ cat > narrowspecs <<EOF
   > [include]
--- a/tests/test-narrow-trackedcmd.t	Wed Dec 09 19:40:30 2020 -0800
+++ b/tests/test-narrow-trackedcmd.t	Wed Nov 18 23:37:09 2020 -0800
@@ -121,7 +121,7 @@
   [255]
   $ hg tracked --import-rules doesnotexist
   abort: cannot read narrowspecs from '$TESTTMP/narrow/doesnotexist': $ENOENT$
-  [255]
+  [50]
 
   $ cat > specs <<EOF
   > %include foo
@@ -133,7 +133,7 @@
 
   $ hg tracked --import-rules specs
   abort: including other spec files using '%include' is not supported in narrowspec
-  [255]
+  [10]
 
   $ cat > specs <<EOF
   > [include]
@@ -198,7 +198,7 @@
 
   $ hg tracked --import-rules specs --clear
   abort: the --clear option is not yet supported
-  [255]
+  [10]
 
 Testing with passing a out of wdir file
 
@@ -224,4 +224,4 @@
   $ cd non-narrow
   $ hg tracked --addinclude foobar
   abort: the tracked command is only supported on repositories cloned with --narrow
-  [255]
+  [10]
--- a/tests/test-narrow.t	Wed Dec 09 19:40:30 2020 -0800
+++ b/tests/test-narrow.t	Wed Nov 18 23:37:09 2020 -0800
@@ -98,7 +98,7 @@
   * (glob)
   abort: local changes found
   (use --force-delete-local-changes to ignore)
-  [255]
+  [20]
 Check that nothing was removed by the failed attempts
   $ hg tracked
   I path:d0
@@ -422,7 +422,7 @@
   ...and 5 more, use --verbose to list all
   abort: local changes found
   (use --force-delete-local-changes to ignore)
-  [255]
+  [20]
 Now test it *with* verbose.
   $ hg tracked --removeinclude d9 --verbose
   comparing with ssh://user@dummy/master
@@ -446,7 +446,7 @@
   ^[0-9a-f]{12}$ (re)
   abort: local changes found
   (use --force-delete-local-changes to ignore)
-  [255]
+  [20]
   $ cd ..
 
 Test --auto-remove-includes