Patchwork [2,of,4] copies: replace _nonoverlap() by calls to manifestdict.filesnotin()

login
register
mail settings
Submitter Martin von Zweigbergk
Date Feb. 27, 2015, 10:46 p.m.
Message ID <89f810fb00184d3a1dd4.1425077210@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/7856/
State Accepted
Commit 3a3806fe3ddfd6180998504c5990cb362ce35ae6
Headers show

Comments

Martin von Zweigbergk - Feb. 27, 2015, 10:46 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1425074550 28800
#      Fri Feb 27 14:02:30 2015 -0800
# Node ID 89f810fb00184d3a1dd49412d0c3256a596ddca8
# Parent  53f0a056475d56b7b33f8f8b8b7ebadec047ca40
copies: replace _nonoverlap() by calls to manifestdict.filesnotin()

Now that we have manifestdict.filesnotin(), we can write _nonoverlap()
in terms of that method instead, enabling future speedups when
filesnotin() gets optimized, and perhaps making the code a little
clearer at the same time.

Patch

diff -r 53f0a056475d -r 89f810fb0018 mercurial/copies.py
--- a/mercurial/copies.py	Fri Feb 27 13:57:37 2015 -0800
+++ b/mercurial/copies.py	Fri Feb 27 14:02:30 2015 -0800
@@ -8,10 +8,6 @@ 
 import util
 import heapq
 
-def _nonoverlap(d1, d2, d3):
-    "Return list of elements in d1 not in d2 or d3"
-    return sorted([d for d in d1 if d not in d3 and d not in d2])
-
 def _dirname(f):
     s = f.rfind("/")
     if s == -1:
@@ -218,8 +214,10 @@ 
     This is its own function so extensions can easily wrap this call to see what
     files mergecopies is about to process.
     """
-    u1 = _nonoverlap(m1, m2, ma)
-    u2 = _nonoverlap(m2, m1, ma)
+    addedinm1 = m1.filesnotin(ma)
+    addedinm2 = m2.filesnotin(ma)
+    u1 = sorted(addedinm1 - addedinm2)
+    u2 = sorted(addedinm2 - addedinm1)
 
     if u1:
         repo.ui.debug("  unmatched files in local:\n   %s\n"