diff mercurial/cmdutil.py @ 21876:584bbfd1b50d stable

log: make --patch --follow work inside a subdirectory Previously, the 'patch' code for hg log --patch --follow would try to resolve patterns relative to the repository root rather than the current working directory. Fix that by using match.files instead of pats, as done elsewhere nearby.
author Siddharth Agarwal <sid0@fb.com>
date Sat, 12 Jul 2014 02:23:17 -0700
parents 3666331164bb
children dbbae63865a6
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Mon Jul 14 23:33:59 2014 +0900
+++ b/mercurial/cmdutil.py	Sat Jul 12 02:23:17 2014 -0700
@@ -1457,7 +1457,7 @@
 
     return iterate()
 
-def _makelogfilematcher(repo, pats, followfirst):
+def _makelogfilematcher(repo, files, followfirst):
     # When displaying a revision with --patch --follow FILE, we have
     # to know which file of the revision must be diffed. With
     # --follow, we want the names of the ancestors of FILE in the
@@ -1471,7 +1471,7 @@
     wctx = repo[None]
 
     def populate():
-        for fn in pats:
+        for fn in files:
             for i in ((pctx[fn],), pctx[fn].ancestors(followfirst=followfirst)):
                 for c in i:
                     fcache.setdefault(c.linkrev(), set()).add(c.path())
@@ -1596,7 +1596,9 @@
     filematcher = None
     if opts.get('patch') or opts.get('stat'):
         if follow:
-            filematcher = _makelogfilematcher(repo, pats, followfirst)
+            # _makelogfilematcher expects its files argument to be relative to
+            # the repo root, so use match.files(), not pats.
+            filematcher = _makelogfilematcher(repo, match.files(), followfirst)
         else:
             filematcher = lambda rev: match