[PATCH 4 of 4] copies: only calculate 'addedinm[12]' sets once

Martin von Zweigbergk martinvonz at google.com
Fri Feb 27 16:46:52 CST 2015


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1425075982 28800
#      Fri Feb 27 14:26:22 2015 -0800
# Node ID ec60e0d4a6a938c62b1ffe5f8e5d1ece6da2b145
# Parent  b3bcf58446fdebf3672edbbc55c24509e549eb22
copies: only calculate 'addedinm[12]' sets once

Pass the addedinm1 and addedinm2 instead of m1, m2, ma into
_computenonoverlap() instead of calculating the sets twice.

diff -r b3bcf58446fd -r ec60e0d4a6a9 mercurial/copies.py
--- a/mercurial/copies.py	Fri Feb 27 14:03:01 2015 -0800
+++ b/mercurial/copies.py	Fri Feb 27 14:26:22 2015 -0800
@@ -209,13 +209,11 @@
         return _backwardrenames(x, y)
     return _chain(x, y, _backwardrenames(x, a), _forwardcopies(a, y))
 
-def _computenonoverlap(repo, m1, m2, ma):
-    """Computes the files exclusive to m1 and m2.
-    This is its own function so extensions can easily wrap this call to see what
-    files mergecopies is about to process.
+def _computenonoverlap(repo, addedinm1, addedinm2):
+    """Computes, based on addedinm1 and addedinm2, the files exclusive to m1
+    and m2. This is its own function so extensions can easily wrap this call
+    to see what files mergecopies is about to process.
     """
-    addedinm1 = m1.filesnotin(ma)
-    addedinm2 = m2.filesnotin(ma)
     u1 = sorted(addedinm1 - addedinm2)
     u2 = sorted(addedinm2 - addedinm1)
 
@@ -280,7 +278,9 @@
 
     repo.ui.debug("  searching for copies back to rev %d\n" % limit)
 
-    u1, u2 = _computenonoverlap(repo, m1, m2, ma)
+    addedinm1 = m1.filesnotin(ma)
+    addedinm2 = m2.filesnotin(ma)
+    u1, u2 = _computenonoverlap(repo, addedinm1, addedinm2)
 
     for f in u1:
         checkcopies(ctx, f, m1, m2, ca, limit, diverge, copy, fullcopy)
@@ -302,8 +302,6 @@
         else:
             diverge2.update(fl) # reverse map for below
 
-    addedinm1 = m1.filesnotin(ma)
-    addedinm2 = m2.filesnotin(ma)
     bothnew = sorted(addedinm1 & addedinm2)
     if bothnew:
         repo.ui.debug("  unmatched files new in both:\n   %s\n"


More information about the Mercurial-devel mailing list