changeset 45472:07324227f6b7

log: fix -fr'wdir()' PATH to follow newly added file Testing filelog doesn't make sense in this case because the file existence is tested against the specified changectxs. If the filelog is empty and if startctxs != [wctx], 'f not in c' should be triggered.
author Yuya Nishihara <yuya@tcha.org>
date Fri, 11 Sep 2020 15:13:35 +0900
parents a03fde1077ce
children 5f0eeda2005d
files mercurial/logcmdutil.py tests/test-log.t
diffstat 2 files changed, 15 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/logcmdutil.py	Fri Sep 11 15:08:58 2020 +0900
+++ b/mercurial/logcmdutil.py	Fri Sep 11 15:13:35 2020 +0900
@@ -698,12 +698,7 @@
                 # take the slow path.
                 if any(f not in c for c in startctxs):
                     slowpath = True
-                    continue
-                filelog = repo.file(f)
-                if not filelog:
-                    raise error.Abort(
-                        _(b'cannot follow nonexistent file: "%s"') % f
-                    )
+                    break
         elif follow:
             for f in match.files():
                 if f not in wctx:
@@ -722,6 +717,8 @@
                         )
                 filelog = repo.file(f)
                 if not filelog:
+                    # A file exists in wdir but not in history, which means
+                    # the file isn't committed yet.
                     raise error.Abort(
                         _(b'cannot follow nonexistent file: "%s"') % f
                     )
--- a/tests/test-log.t	Fri Sep 11 15:08:58 2020 +0900
+++ b/tests/test-log.t	Fri Sep 11 15:13:35 2020 +0900
@@ -2295,15 +2295,21 @@
    1 files changed, 1 insertions(+), 0 deletions(-)
   
 
- BROKEN: added file should exist in wdir
   $ hg log -T '== {rev} ==\n' -fr'wdir()' --git --stat d1/f2
-  abort: cannot follow nonexistent file: "d1/f2"
-  [255]
+  == 2147483647 ==
+   d1/f2 |  1 +
+   1 files changed, 1 insertions(+), 0 deletions(-)
+  
 
- BROKEN: copied file should exist in wdir
   $ hg log -T '== {rev} ==\n' -fr'wdir()' --git --stat f1-copy
-  abort: cannot follow nonexistent file: "f1-copy"
-  [255]
+  == 2147483647 ==
+   f1-copy |  1 +
+   1 files changed, 1 insertions(+), 0 deletions(-)
+  
+  == 0 ==
+   d1/f1 |  1 +
+   1 files changed, 1 insertions(+), 0 deletions(-)
+  
 
   $ hg log -T '== {rev} ==\n' -fr'wdir()' --git --stat notfound
   notfound: $ENOENT$