Patchwork D9386: errors: raise more specifc errors from narrowcommands

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

Comments

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

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED 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

CHANGE DETAILS




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

Patch

diff --git a/tests/test-narrow.t b/tests/test-narrow.t
--- a/tests/test-narrow.t
+++ b/tests/test-narrow.t
@@ -98,7 +98,7 @@ 
   * (glob)
   abort: local changes found
   (use --force-delete-local-changes to ignore)
-  [255]
+  [10]
 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]
+  [10]
 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]
+  [10]
   $ cd ..
 
 Test --auto-remove-includes
diff --git a/tests/test-narrow-trackedcmd.t b/tests/test-narrow-trackedcmd.t
--- a/tests/test-narrow-trackedcmd.t
+++ b/tests/test-narrow-trackedcmd.t
@@ -121,7 +121,7 @@ 
   [255]
   $ hg tracked --import-rules doesnotexist
   abort: cannot read narrowspecs from '$TESTTMP/narrow/doesnotexist': $ENOENT$
-  [255]
+  [10]
 
   $ 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]
diff --git a/tests/test-narrow-clone.t b/tests/test-narrow-clone.t
--- a/tests/test-narrow-clone.t
+++ b/tests/test-narrow-clone.t
@@ -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]
diff --git a/tests/test-narrow-clone-no-ellipsis.t b/tests/test-narrow-clone-no-ellipsis.t
--- a/tests/test-narrow-clone-no-ellipsis.t
+++ b/tests/test-narrow-clone-no-ellipsis.t
@@ -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]
diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -99,7 +99,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"
@@ -248,7 +248,7 @@ 
                 % (len(visibletostrip) - maxnodes)
             )
         if not force:
-            raise error.Abort(
+            raise error.InputError(
                 _(b'local changes found'),
                 hint=_(b'use --force-delete-local-changes to ignore'),
             )
@@ -483,7 +483,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'
@@ -493,7 +493,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')
@@ -502,7 +502,7 @@ 
             filepath = os.path.join(encoding.getcwd(), newrules)
             fdata = util.readfile(filepath)
         except IOError as inst:
-            raise error.Abort(
+            raise error.InputError(
                 _(b"cannot read narrowspecs from '%s': %s")
                 % (filepath, encoding.strtolocal(inst.strerror))
             )
@@ -510,7 +510,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"