# HG changeset patch # User Matt Mackall # Date 2012-01-21 05:52:31 # Node ID 610c4434973b9a5086d5853b69febd4cebc81a4d # Parent 57738b9130ae7a795be364b08fea40701173bc52 revset: include the correct first ancestor change for follow(file) Previously we always included '.', which may not touch a file. Instead, find the file revision present in '.' and add its linkrev. This matches the results of 'hg log --follow file'. diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -449,17 +449,20 @@ def follow(repo, subset, x): """ # i18n: "follow" is a keyword l = getargs(x, 0, 1, _("follow takes no arguments or a filename")) - p = repo['.'].rev() + c = repo['.'] if l: x = getstring(l[0], _("follow expected a filename")) - if x in repo['.']: - s = set(ctx.rev() for ctx in repo['.'][x].ancestors()) + if x in c: + cx = c[x] + s = set(ctx.rev() for ctx in cx.ancestors()) + # include the revision responsible for the most recent version + s.add(cx.linkrev()) else: return [] else: - s = set(repo.changelog.ancestors(p)) + s = set(repo.changelog.ancestors(c.rev())) + s.add(c.rev()) - s |= set([p]) return [r for r in subset if r in s] def getall(repo, subset, x):