diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1024,8 +1024,15 @@ def walkchangerevs(repo, match, opts, pr return reversed(revs) def iterfiles(): + pctx = repo['.'] for filename in match.files(): - yield filename, None + if follow: + if filename not in pctx: + raise util.Abort(_('cannot follow file not in parent ' + 'revision: "%s"') % filename) + yield filename, pctx[filename].filenode() + else: + yield filename, None for filename_node in copies: yield filename_node for file_, node in iterfiles(): diff --git a/tests/test-convert-hg-startrev.t b/tests/test-convert-hg-startrev.t --- a/tests/test-convert-hg-startrev.t +++ b/tests/test-convert-hg-startrev.t @@ -115,6 +115,7 @@ Convert from merge parent o 0 "1: add c" files: a b c $ cd conv1 + $ hg up -q Check copy preservation diff --git a/tests/test-log.t b/tests/test-log.t --- a/tests/test-log.t +++ b/tests/test-log.t @@ -40,7 +40,7 @@ changeset graph -f, directory $ hg log -f dir - abort: cannot follow nonexistent file: "dir" + abort: cannot follow file not in parent revision: "dir" [255] -f, but no args @@ -75,6 +75,7 @@ changeset graph one rename + $ hg up -q 2 $ hg log -vf a changeset: 0:9161b9aeaf16 user: test @@ -87,6 +88,7 @@ one rename many renames + $ hg up -q tip $ hg log -vf e changeset: 4:7e4639b4691b tag: tip @@ -125,6 +127,7 @@ many renames log -pf dir/b + $ hg up -q 3 $ hg log -pf dir/b changeset: 2:f8954cd4dc1f user: test @@ -189,6 +192,20 @@ log -vf dir/b +-f and multiple filelog heads + + $ hg up -q 2 + $ hg log -f g --template '{rev}\n' + 2 + 1 + 0 + $ hg up -q tip + $ hg log -f g --template '{rev}\n' + 3 + 2 + 0 + + log copies with --copies $ hg log -vC --template '{rev} {file_copies}\n'