diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py --- a/mercurial/logcmdutil.py +++ b/mercurial/logcmdutil.py @@ -698,12 +698,7 @@ def _makematcher(repo, revs, pats, opts) # 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 @@ def _makematcher(repo, revs, pats, opts) ) 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 ) diff --git a/tests/test-log.t b/tests/test-log.t --- a/tests/test-log.t +++ b/tests/test-log.t @@ -2295,15 +2295,21 @@ follow files from wdir 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$