Patchwork D11969: logcmdutil: raise `StateError` when file to follow doesn't exist

login
register
mail settings
Submitter phabricator
Date Jan. 7, 2022, 6:11 a.m.
Message ID <differential-rev-PHID-DREV-6feon3rbuhev7gco4scf-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50295/
State New
Headers show

Comments

phabricator - Jan. 7, 2022, 6:11 a.m.
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/D11969

AFFECTED FILES
  mercurial/logcmdutil.py
  tests/test-grep.t
  tests/test-log-linerange.t
  tests/test-log.t

CHANGE DETAILS




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

Patch

diff --git a/tests/test-log.t b/tests/test-log.t
--- a/tests/test-log.t
+++ b/tests/test-log.t
@@ -122,13 +122,13 @@ 
 
   $ hg log -qfl1 '' inexistent
   abort: cannot follow file not in parent revision: "inexistent"
-  [255]
+  [20]
   $ hg log -qfl1 . inexistent
   abort: cannot follow file not in parent revision: "inexistent"
-  [255]
+  [20]
   $ hg log -qfl1 "`pwd`" inexistent
   abort: cannot follow file not in parent revision: "inexistent"
-  [255]
+  [20]
 
   $ hg log -qfl1 '' e
   4:7e4639b4691b
@@ -145,7 +145,7 @@ 
 
   $ hg log -f dir
   abort: cannot follow file not in parent revision: "dir"
-  [255]
+  [20]
 
 -f, directory
 
@@ -552,7 +552,7 @@ 
 
   $ hg log -T '{rev}\n' -fr4 e x
   abort: cannot follow file not in any of the specified revisions: "x"
-  [255]
+  [20]
 
 follow files from the specified revisions with directory patterns
 (BROKEN: should follow copies from dir/b@2)
@@ -2422,7 +2422,7 @@ 
 
   $ hg log -T '== {rev} ==\n' -fr'wdir()' --git --stat notfound
   abort: cannot follow file not in any of the specified revisions: "notfound"
-  [255]
+  [20]
 
 follow files from wdir and non-wdir revision:
 
@@ -2435,15 +2435,15 @@ 
 
   $ hg log -T '{rev}\n' -f d1/f2
   abort: cannot follow nonexistent file: "d1/f2"
-  [255]
+  [20]
 
   $ hg log -T '{rev}\n' -f f1-copy
   abort: cannot follow nonexistent file: "f1-copy"
-  [255]
+  [20]
 
   $ hg log -T '{rev}\n' -f .d6/f1
   abort: cannot follow file not in parent revision: ".d6/f1"
-  [255]
+  [20]
 
   $ hg revert -aqC
 
diff --git a/tests/test-log-linerange.t b/tests/test-log-linerange.t
--- a/tests/test-log-linerange.t
+++ b/tests/test-log-linerange.t
@@ -1150,4 +1150,4 @@ 
   $ hg ci -m 'remove baz' --quiet
   $ hg log -f -L dir/baz,5:7 -p
   abort: cannot follow file not in parent revision: "dir/baz"
-  [255]
+  [20]
diff --git a/tests/test-grep.t b/tests/test-grep.t
--- a/tests/test-grep.t
+++ b/tests/test-grep.t
@@ -1200,11 +1200,11 @@ 
 
   $ hg log -f add0-cp4
   abort: cannot follow nonexistent file: "add0-cp4"
-  [255]
+  [20]
 
   $ hg grep --diff -f data add0-cp4
   abort: cannot follow nonexistent file: "add0-cp4"
-  [255]
+  [20]
 
  BROKEN: maybe better to abort
   $ hg grep -f data add0-cp4
@@ -1214,11 +1214,11 @@ 
 
   $ hg log -f add0-cp1-mod1-rm3
   abort: cannot follow file not in parent revision: "add0-cp1-mod1-rm3"
-  [255]
+  [20]
 
   $ hg grep --diff -f data add0-cp1-mod1-rm3
   abort: cannot follow file not in parent revision: "add0-cp1-mod1-rm3"
-  [255]
+  [20]
 
  BROKEN: maybe better to abort
   $ hg grep -f data add0-cp1-mod1-rm3
@@ -1229,11 +1229,11 @@ 
 
   $ hg log -fr. add0-cp1-mod1-rm3
   abort: cannot follow file not in any of the specified revisions: "add0-cp1-mod1-rm3"
-  [255]
+  [20]
 
   $ hg grep --diff -fr. data add0-cp1-mod1-rm3
   abort: cannot follow file not in any of the specified revisions: "add0-cp1-mod1-rm3"
-  [255]
+  [20]
 
  BROKEN: should abort
   $ hg grep -fr. data add0-cp1-mod1-rm3
@@ -1244,11 +1244,11 @@ 
 
   $ hg log -f add0-rm4
   abort: cannot follow file not in parent revision: "add0-rm4"
-  [255]
+  [20]
 
   $ hg grep --diff -f data add0-rm4
   abort: cannot follow file not in parent revision: "add0-rm4"
-  [255]
+  [20]
 
  BROKEN: should abort
   $ hg grep -f data add0-rm4
@@ -1340,11 +1340,11 @@ 
 
   $ hg log -fr2 add0-rm2
   abort: cannot follow file not in any of the specified revisions: "add0-rm2"
-  [255]
+  [20]
 
   $ hg grep --diff -fr2 data add0-rm2
   abort: cannot follow file not in any of the specified revisions: "add0-rm2"
-  [255]
+  [20]
 
  BROKEN: should abort
   $ hg grep -fr2 data add0-rm2
diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -831,7 +831,7 @@ 
                         # take the slow path.
                         found = slowpath = True
                 if not found:
-                    raise error.Abort(
+                    raise error.StateError(
                         _(
                             b'cannot follow file not in any of the specified '
                             b'revisions: "%s"'
@@ -847,7 +847,7 @@ 
                         slowpath = True
                         continue
                     else:
-                        raise error.Abort(
+                        raise error.StateError(
                             _(
                                 b'cannot follow file not in parent '
                                 b'revision: "%s"'
@@ -858,7 +858,7 @@ 
                 if not filelog:
                     # A file exists in wdir but not in history, which means
                     # the file isn't committed yet.
-                    raise error.Abort(
+                    raise error.StateError(
                         _(b'cannot follow nonexistent file: "%s"') % f
                     )
         else:
@@ -1138,7 +1138,7 @@ 
     linerangesbyrev = {}
     for fname, (fromline, toline) in _parselinerangeopt(repo, opts):
         if fname not in wctx:
-            raise error.Abort(
+            raise error.StateError(
                 _(b'cannot follow file not in parent revision: "%s"') % fname
             )
         fctx = wctx.filectx(fname)