changeset 15966:610c4434973b stable

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'.
author Matt Mackall <mpm@selenic.com>
date Fri, 20 Jan 2012 23:52:31 -0600
parents 57738b9130ae
children 295f8aeab363 cd4504d26695
files mercurial/revset.py
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Fri Jan 20 23:10:13 2012 -0600
+++ b/mercurial/revset.py	Fri Jan 20 23:52:31 2012 -0600
@@ -449,17 +449,20 @@
     """
     # 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):