logcmdutil: raise `StateError` when file to follow doesn't exist
authorMartin von Zweigbergk <martinvonz@google.com>
Thu, 06 Jan 2022 22:09:40 -0800
changeset 48553 3b6b43a7ace4
parent 48552 91017508a785
child 48554 0dc698c91ca0
logcmdutil: raise `StateError` when file to follow doesn't exist Differential Revision: https://phab.mercurial-scm.org/D11969
mercurial/logcmdutil.py
tests/test-grep.t
tests/test-log-linerange.t
tests/test-log.t
--- a/mercurial/logcmdutil.py	Thu Jan 06 22:03:21 2022 -0800
+++ b/mercurial/logcmdutil.py	Thu Jan 06 22:09:40 2022 -0800
@@ -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)
--- a/tests/test-grep.t	Thu Jan 06 22:03:21 2022 -0800
+++ b/tests/test-grep.t	Thu Jan 06 22:09:40 2022 -0800
@@ -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
--- a/tests/test-log-linerange.t	Thu Jan 06 22:03:21 2022 -0800
+++ b/tests/test-log-linerange.t	Thu Jan 06 22:09:40 2022 -0800
@@ -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]
--- a/tests/test-log.t	Thu Jan 06 22:03:21 2022 -0800
+++ b/tests/test-log.t	Thu Jan 06 22:09:40 2022 -0800
@@ -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