Patchwork manifest: make manifest.intersectfiles() internal

login
register
mail settings
Submitter Drew Gottlieb
Date March 30, 2015, 7:43 p.m.
Message ID <8fe64d42c44db7842b29.1427744634@waste.org>
Download mbox | patch
Permalink /patch/8373/
State Accepted
Headers show

Comments

Drew Gottlieb - March 30, 2015, 7:43 p.m.
# HG changeset patch
# User Drew Gottlieb <drgott@google.com>
# Date 1427737432 25200
#      Mon Mar 30 10:43:52 2015 -0700
# Node ID 8fe64d42c44db7842b29755db0ef986b77a6413f
# Parent  efa094701a05d58d505c3b0c3b3c73dba4e51e97
manifest: make manifest.intersectfiles() internal

manifest.intersectfiles() is just a utility used by manifest.matches(), and
a future commit removes intersectfiles for treemanifest for optimization
purposes.

This commit makes the intersectfiles methods on manifestdict and treemanifest
internal, and converts its test to a more generic testMatches(), which has the
exact same coverage.
Matt Mackall - March 30, 2015, 9:22 p.m.
On Mon, 2015-03-30 at 14:43 -0500, Drew Gottlieb wrote:
> # HG changeset patch
> # User Drew Gottlieb <drgott@google.com>
> # Date 1427737432 25200
> #      Mon Mar 30 10:43:52 2015 -0700
> # Node ID 8fe64d42c44db7842b29755db0ef986b77a6413f
> # Parent  efa094701a05d58d505c3b0c3b3c73dba4e51e97
> manifest: make manifest.intersectfiles() internal

Queued for default, thanks.
Pierre-Yves David - March 30, 2015, 9:58 p.m.
On 03/30/2015 12:43 PM, Drew Gottlieb wrote:
> # HG changeset patch
> # User Drew Gottlieb <drgott@google.com>
> # Date 1427737432 25200
> #      Mon Mar 30 10:43:52 2015 -0700
> # Node ID 8fe64d42c44db7842b29755db0ef986b77a6413f
> # Parent  efa094701a05d58d505c3b0c3b3c73dba4e51e97
> manifest: make manifest.intersectfiles() internal

Pushed to the clowncopter, thanks

Patch

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -131,7 +131,7 @@ 
     def keys(self):
         return list(self.iterkeys())
 
-    def intersectfiles(self, files):
+    def _intersectfiles(self, files):
         '''make a new lazymanifest with the intersection of self with files
 
         The algorithm assumes that files is much smaller than self.'''
@@ -166,7 +166,7 @@ 
         files = match.files()
         if (len(files) < 100 and (match.isexact() or
             (not match.anypats() and util.all(fn in self for fn in files)))):
-            return self.intersectfiles(files)
+            return self._intersectfiles(files)
 
         lm = manifestdict('')
         lm._lm = self._lm.filtercopy(match)
@@ -467,7 +467,7 @@ 
         copy._flags = dict.copy(self._flags)
         return copy
 
-    def intersectfiles(self, files):
+    def _intersectfiles(self, files):
         '''make a new treemanifest with the intersection of self with files
 
         The algorithm assumes that files is much smaller than self.'''
@@ -521,7 +521,7 @@ 
         files = match.files()
         if (match.isexact() or
             (not match.anypats() and util.all(fn in self for fn in files))):
-            return self.intersectfiles(files)
+            return self._intersectfiles(files)
 
         m = self.copy()
         for fn in m.keys():
diff --git a/tests/test-manifest.py b/tests/test-manifest.py
--- a/tests/test-manifest.py
+++ b/tests/test-manifest.py
@@ -250,9 +250,13 @@ 
         self.assertEqual(HUGE_MANIFEST_ENTRIES, len(m))
         self.assertEqual(len(m), len(list(m)))
 
-    def testIntersectFiles(self):
+    def testMatches(self):
         m = parsemanifest(A_HUGE_MANIFEST)
-        m2 = m.intersectfiles(['file1', 'file200', 'file300'])
+
+        match = matchmod.match('/', '',
+                ['file1', 'file200', 'file300'], exact=True)
+        m2 = m.matches(match)
+
         w = ('file1\0%sx\n'
              'file200\0%sl\n'
              'file300\0%s\n') % (HASH_2, HASH_1, HASH_1)