Patchwork [1,of,4] copies: move code into new manifestdict.filesnotin() method

login
register
mail settings
Submitter Martin von Zweigbergk
Date Feb. 27, 2015, 10:46 p.m.
Message ID <53f0a056475d56b7b33f.1425077209@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/7854/
State Accepted
Commit cd66080ef6d4889d513ea0571defa8dd69ae71ab
Headers show

Comments

Martin von Zweigbergk - Feb. 27, 2015, 10:46 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1425074257 28800
#      Fri Feb 27 13:57:37 2015 -0800
# Node ID 53f0a056475d56b7b33f8f8b8b7ebadec047ca40
# Parent  545378f73f321290454af60f71e0f1ed3215de99
copies: move code into new manifestdict.filesnotin() method

copies._computeforwardmissing() finds files in one context that is not
in the other. Let's move this code into a new method on manifestdict,
so m1.filesnotin(m2) can be optimized for various types of manifests
(we expect more types of manifests soon).

Patch

diff -r 545378f73f32 -r 53f0a056475d mercurial/copies.py
--- a/mercurial/copies.py	Tue Feb 24 10:36:11 2015 -0800
+++ b/mercurial/copies.py	Fri Feb 27 13:57:37 2015 -0800
@@ -149,9 +149,7 @@ 
     This is its own function so extensions can easily wrap this call to see what
     files _forwardcopies is about to process.
     """
-    missing = set(b.manifest().iterkeys())
-    missing.difference_update(a.manifest().iterkeys())
-    return missing
+    return b.manifest().filesnotin(a.manifest())
 
 def _forwardcopies(a, b):
     '''find {dst@b: src@a} copy mapping where a is an ancestor of b'''
diff -r 545378f73f32 -r 53f0a056475d mercurial/manifest.py
--- a/mercurial/manifest.py	Tue Feb 24 10:36:11 2015 -0800
+++ b/mercurial/manifest.py	Fri Feb 27 13:57:37 2015 -0800
@@ -38,6 +38,12 @@ 
                     ret._flags[fn] = flags
         return ret
 
+    def filesnotin(self, m2):
+        '''Set of files in this manifest that are not in the other'''
+        files = set(self.iterkeys())
+        files.difference_update(m2.iterkeys())
+        return files
+
     def matches(self, match):
         '''generate a new manifest filtered by the match argument'''
         if match.always():