changeset 42488:c0b51449bf6b

copies: avoid calling matcher if matcher.always() When storing copy information in the changesets (experimental.copies.read-from=changeset-only), this patch speeds up hg debugpathcopies FENNEC_58_0_2_BUILD1 FIREFOX_59_0b8_BUILD2 from 5.9s to 4.7s. At the start of this series (b162229e), that command took 18min. Differential Revision: https://phab.mercurial-scm.org/D6422
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 02 May 2019 23:39:33 -0700
parents 5ceb91136ebe
children cf445a212b9c
files mercurial/copies.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/copies.py	Thu Apr 18 21:21:44 2019 -0700
+++ b/mercurial/copies.py	Thu May 02 23:39:33 2019 -0700
@@ -270,6 +270,7 @@
     # came from.
     work = [(r, 1, {}) for r in roots]
     heapq.heapify(work)
+    alwaysmatch = match.always()
     while work:
         r, i1, copies1 = heapq.heappop(work)
         if work and work[0][0] == r:
@@ -280,7 +281,7 @@
             # TODO: perhaps this filtering should be done as long as ctx
             # is merge, whether or not we're tracing from both parent.
             for dst in allcopies:
-                if not match(dst):
+                if not alwaysmatch and not match(dst):
                     continue
                 # Unlike when copies are stored in the filelog, we consider
                 # it a copy even if the destination already existed on the
@@ -306,7 +307,7 @@
                 assert r == childctx.p2().rev()
                 parent = 2
                 childcopies = childctx.p2copies()
-            if not match.always():
+            if not alwaysmatch:
                 childcopies = {dst: src for dst, src in childcopies.items()
                                if match(dst)}
             # Copy the dict only if later iterations will also need it