$ hg init foo $ cd foo First, note the behavior with an empty repo: $ hg log -r 'follow(a)' --template '{rev}\n' $ hg log -r 'follow(foo)' --template '{rev}\n' There's no output. Makes sense. Let's add a file: $ echo a > a $ hg ci -Am a Now, with the working directory at revision 1, let's try to find a and foo: $ hg log -r 'follow(a)' --template '{rev}\n' 0 $ hg log -r 'follow(foo)' --template '{rev}\n' abort: foo@f88987657351: not found in manifest! If we update back to null: $ hg up null $ hg log -r 'follow(a)' --template '{rev}\n' abort: a@000000000000: not found in manifest! $ hg log -r 'follow(foo)' --template '{rev}\n' abort: foo@000000000000: not found in manifest! In every case where I get an error message, I would've expected to get no output instead. After all, file(foo) does that: $ hg log -r 'file(foo)' --template '{rev}\n' Also, note that, even more confusingly, --follow a doesn't behave exactly the same way: $ hg up null $ hg log -f a --template '{rev}\n' 0 $ hg up 0 $ hg log -f a --template '{rev}\n' 0 However, --follow foo does blow up: $ hg log -f foo --template '{rev}\n' abort: cannot follow nonexistent file: "foo" It doesn't seem there's any exact revset equivalent to --follow.
Does this do what you want? diff -r e7119b091809 mercurial/revset.py --- a/mercurial/revset.py Thu Nov 17 23:02:18 2011 -0600 +++ b/mercurial/revset.py Fri Nov 18 15:43:19 2011 -0600 @@ -434,7 +434,10 @@ p = repo['.'].rev() if l: x = getstring(l[0], _("follow expected a filename")) - s = set(ctx.rev() for ctx in repo['.'][x].ancestors()) + if x in repo['.']: + s = set(ctx.rev() for ctx in repo['.'][x].ancestors()) + else: + return [] else: s = set(repo.changelog.ancestors(p))
I think that would make more sense, yeah. The thing I noticed with --follow giving matching a revision when I was at null seems to be an edge case. The default rev range in that case was null:0. Also, it would be nice if there were a way to find a file across renames with a revset without having to have a working copy.
Fixed by http://selenic.com/repo/hg/rev/5edaf47cd462 Matt Mackall <mpm@selenic.com> revset: follow(nosuchfile) should give an empty set (issue3114) (please test the fix)
--- Bug imported by bugzilla@serpentine.com 2012-05-12 09:25 EDT --- This bug was previously known as _bug_ 3114 at http://mercurial.selenic.com/bts/issue3114