revset: include the correct first ancestor change for follow(file) stable
authorMatt Mackall <mpm@selenic.com>
Fri, 20 Jan 2012 23:52:31 -0600
branchstable
changeset 15966 610c4434973b
parent 15965 57738b9130ae
child 15967 295f8aeab363
child 15974 cd4504d26695
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'.
mercurial/revset.py
--- 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):