log: fix log -f slow path to actually follow history stable
authorDurham Goode <durham@fb.com>
Fri, 05 Dec 2014 14:27:32 -0800
branchstable
changeset 23500 9601229ed361
parent 23478 30b602168c3b
child 23501 424d669118d3
log: fix log -f slow path to actually follow history The revset created when -f was used with a slow path (for patterns and directories) did not actually contain any logic to enforce follow. Instead it was depending on the passed in subset to already be limited (which was limited to :. but not ::.). This fixes it by adding a '& ::.' to any -f log revset. hg log -f <file> is still broken, in that it can return results that aren't actually ancestors of the current file, but fixing that has major perf implications, so we'll deal with it later.
mercurial/cmdutil.py
tests/test-glog.t
tests/test-log.t
--- a/mercurial/cmdutil.py	Sun Nov 16 23:41:44 2014 -0800
+++ b/mercurial/cmdutil.py	Fri Dec 05 14:27:32 2014 -0800
@@ -1745,6 +1745,9 @@
             else:
                 slowpath = False
 
+    fpats = ('_patsfollow', '_patsfollowfirst')
+    fnopats = (('_ancestors', '_fancestors'),
+               ('_descendants', '_fdescendants'))
     if slowpath:
         # See walkchangerevs() slow path.
         #
@@ -1763,11 +1766,10 @@
             matchargs.append('x:' + p)
         matchargs = ','.join(('%r' % p) for p in matchargs)
         opts['_matchfiles'] = matchargs
+        if follow:
+            opts[fnopats[0][followfirst]] = '.'
     else:
         if follow:
-            fpats = ('_patsfollow', '_patsfollowfirst')
-            fnopats = (('_ancestors', '_fancestors'),
-                       ('_descendants', '_fdescendants'))
             if pats:
                 # follow() revset interprets its file argument as a
                 # manifest entry, so use match.files(), not pats.
--- a/tests/test-glog.t	Sun Nov 16 23:41:44 2014 -0800
+++ b/tests/test-glog.t	Fri Dec 05 14:27:32 2014 -0800
@@ -1658,13 +1658,17 @@
   $ testlog -f dir
   []
   (group
-    (func
-      ('symbol', '_matchfiles')
-      (list
+    (and
+      (func
+        ('symbol', '_matchfiles')
         (list
-          ('string', 'r:')
-          ('string', 'd:relpath'))
-        ('string', 'p:dir'))))
+          (list
+            ('string', 'r:')
+            ('string', 'd:relpath'))
+          ('string', 'p:dir')))
+      (func
+        ('symbol', 'ancestors')
+        ('symbol', '.'))))
   $ hg up -q tip
 
 Test --follow on file not in parent revision
@@ -1679,13 +1683,17 @@
   $ testlog -f 'glob:*'
   []
   (group
-    (func
-      ('symbol', '_matchfiles')
-      (list
+    (and
+      (func
+        ('symbol', '_matchfiles')
         (list
-          ('string', 'r:')
-          ('string', 'd:relpath'))
-        ('string', 'p:glob:*'))))
+          (list
+            ('string', 'r:')
+            ('string', 'd:relpath'))
+          ('string', 'p:glob:*')))
+      (func
+        ('symbol', 'ancestors')
+        ('symbol', '.'))))
 
 Test --follow on a single rename
 
@@ -1852,13 +1860,17 @@
   $ testlog --removed --follow a
   []
   (group
-    (func
-      ('symbol', '_matchfiles')
-      (list
+    (and
+      (func
+        ('symbol', '_matchfiles')
         (list
-          ('string', 'r:')
-          ('string', 'd:relpath'))
-        ('string', 'p:a'))))
+          (list
+            ('string', 'r:')
+            ('string', 'd:relpath'))
+          ('string', 'p:a')))
+      (func
+        ('symbol', 'ancestors')
+        ('symbol', '.'))))
 
 Test --patch and --stat with --follow and --follow-first
 
--- a/tests/test-log.t	Sun Nov 16 23:41:44 2014 -0800
+++ b/tests/test-log.t	Fri Dec 05 14:27:32 2014 -0800
@@ -1543,3 +1543,24 @@
   
 
   $ cd ..
+
+hg log -f dir across branches
+
+  $ hg init acrossbranches
+  $ cd acrossbranches
+  $ mkdir d
+  $ echo a > d/a && hg ci -Aqm a
+  $ echo b > d/a && hg ci -Aqm b
+  $ hg up -q 0
+  $ echo b > d/a && hg ci -Aqm c
+  $ hg log -f d -T '{desc}' -G
+  @  c
+  |
+  o  a
+  
+  $ hg log -f d/a -T '{desc}' -G
+  o  b
+  |
+  o  a
+  
+  $ cd ..