Patchwork [1,of,2,STABLE] log: unroll loop that populates file paths for --patch --follow matcher

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 24, 2016, 2 p.m.
Message ID <bf616dd17b4244d4d5fc.1474725637@mimosa>
Download mbox | patch
Permalink /patch/16777/
State Accepted
Headers show

Comments

Yuya Nishihara - Sept. 24, 2016, 2 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1474714322 -32400
#      Sat Sep 24 19:52:02 2016 +0900
# Branch stable
# Node ID bf616dd17b4244d4d5fc92b0ada65404596fe4b2
# Parent  e7766022a61a66a7c4218526b647f96bd442a4ce
# EXP-Topic followmatcher
log: unroll loop that populates file paths for --patch --follow matcher

We can't handle the first fctx in the same manner as its ancestors. Also,
I think the original code was too tricky.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1948,9 +1948,10 @@  def _makefollowlogfilematcher(repo, file
 
     def populate():
         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())
+            fctx = pctx[fn]
+            fcache.setdefault(fctx.linkrev(), set()).add(fctx.path())
+            for c in fctx.ancestors(followfirst=followfirst):
+                fcache.setdefault(c.linkrev(), set()).add(c.path())
 
     def filematcher(rev):
         if not fcacheready[0]: