diff --git a/mercurial/interfaces/repository.py b/mercurial/interfaces/repository.py --- a/mercurial/interfaces/repository.py +++ b/mercurial/interfaces/repository.py @@ -985,18 +985,9 @@ def hasdir(dir): """Returns a bool indicating if a directory is in this manifest.""" - def matches(match): - """Generate a new manifest filtered through a matcher. - - Returns an object conforming to the ``imanifestdict`` interface. - """ - def walk(match): """Generator of paths in manifest satisfying a matcher. - This is equivalent to ``self.matches(match).iterkeys()`` except a new - manifest object is not created. - If the matcher has explicit files listed and they don't exist in the manifest, ``match.bad()`` is called for each missing file. """ diff --git a/mercurial/manifest.py b/mercurial/manifest.py --- a/mercurial/manifest.py +++ b/mercurial/manifest.py @@ -545,7 +545,7 @@ if not self.hasdir(fn): match.bad(fn, None) - def matches(self, match): + def _matches(self, match): '''generate a new manifest filtered by the match argument''' if match.always(): return self.copy() @@ -578,8 +578,8 @@ string. ''' if match: - m1 = self.matches(match) - m2 = m2.matches(match) + m1 = self._matches(match) + m2 = m2._matches(match) return m1.diff(m2, clean=clean) return self._lm.diff(m2._lm, clean) @@ -1075,8 +1075,8 @@ def filesnotin(self, m2, match=None): '''Set of files in this manifest that are not in the other''' if match and not match.always(): - m1 = self.matches(match) - m2 = m2.matches(match) + m1 = self._matches(match) + m2 = m2._matches(match) return m1.filesnotin(m2) files = set() @@ -1122,9 +1122,6 @@ def walk(self, match): '''Generates matching file names. - Equivalent to manifest.matches(match).iterkeys(), but without creating - an entirely new manifest. - It also reports nonexistent files by marking them bad with match.bad(). ''' if match.always(): @@ -1167,16 +1164,16 @@ for f in self._dirs[p]._walk(match): yield f - def matches(self, match): - '''generate a new manifest filtered by the match argument''' - if match.always(): - return self.copy() - - return self._matches(match) - def _matches(self, match): '''recursively generate a new manifest filtered by the match argument. ''' + if match.always(): + return self.copy() + return self._matches_inner(match) + + def _matches_inner(self, match): + if match.always(): + return self.copy() visit = match.visitchildrenset(self._dir[:-1]) if visit == b'all': @@ -1207,7 +1204,7 @@ for dir, subm in pycompat.iteritems(self._dirs): if visit and dir[:-1] not in visit: continue - m = subm._matches(match) + m = subm._matches_inner(match) if not m._isempty(): ret._dirs[dir] = m @@ -1231,8 +1228,8 @@ string. ''' if match and not match.always(): - m1 = self.matches(match) - m2 = m2.matches(match) + m1 = self._matches(match) + m2 = m2._matches(match) return m1.diff(m2, clean=clean) result = {} emptytree = treemanifest() diff --git a/tests/test-manifest.py b/tests/test-manifest.py --- a/tests/test-manifest.py +++ b/tests/test-manifest.py @@ -171,7 +171,7 @@ self.assertEqual(want, m[b'foo']) # make sure the suffix survives a copy match = matchmod.match(util.localpath(b'/repo'), b'', [b're:foo']) - m2 = m.matches(match) + m2 = m._matches(match) self.assertEqual(want, m2[b'foo']) self.assertEqual(1, len(m2)) m2 = m.copy() @@ -196,7 +196,7 @@ match.matchfn = filt with self.assertRaises(AssertionError): - m.matches(match) + m._matches(match) def testRemoveItem(self): m = self.parsemanifest(A_SHORT_MANIFEST) @@ -300,7 +300,7 @@ m = self.parsemanifest(A_HUGE_MANIFEST) match = matchmod.exact([b'file1', b'file200', b'file300']) - m2 = m.matches(match) + m2 = m._matches(match) w = (b'file1\0%sx\n' b'file200\0%sl\n' b'file300\0%s\n') % ( HASH_2, @@ -318,7 +318,7 @@ match = matchmod.exact( [b'a/b/c/bar.txt', b'a/b/d/qux.py', b'readme.txt', b'nonexistent'] ) - m2 = m.matches(match) + m2 = m._matches(match) self.assertEqual( [b'a/b/c/bar.txt', b'a/b/d/qux.py', b'readme.txt'], m2.keys() @@ -332,7 +332,7 @@ match = matchmod.match( util.localpath(b'/repo'), b'', [b'a/f'], default=b'relpath' ) - m2 = m.matches(match) + m2 = m._matches(match) self.assertEqual([], m2.keys()) @@ -343,7 +343,7 @@ flist = m.keys()[80:300] match = matchmod.exact(flist) - m2 = m.matches(match) + m2 = m._matches(match) self.assertEqual(flist, m2.keys()) @@ -352,7 +352,7 @@ m = self.parsemanifest(A_DEEPER_MANIFEST) match = matchmod.match(util.localpath(b'/repo'), b'', [b'']) - m2 = m.matches(match) + m2 = m._matches(match) self.assertEqual(m.keys(), m2.keys()) @@ -364,7 +364,7 @@ match = matchmod.match( util.localpath(b'/repo'), b'', [b'a/b'], default=b'relpath' ) - m2 = m.matches(match) + m2 = m._matches(match) self.assertEqual( [ @@ -388,7 +388,7 @@ m = self.parsemanifest(A_DEEPER_MANIFEST) match = matchmod.exact([b'a/b']) - m2 = m.matches(match) + m2 = m._matches(match) self.assertEqual([], m2.keys()) @@ -400,7 +400,7 @@ match = matchmod.match( util.localpath(b'/repo'), b'a/b', [b'.'], default=b'relpath' ) - m2 = m.matches(match) + m2 = m._matches(match) self.assertEqual( [ @@ -423,7 +423,7 @@ m = self.parsemanifest(A_DEEPER_MANIFEST) match = matchmod.match(util.localpath(b'/repo'), b'', [b'a/b/*/*.txt']) - m2 = m.matches(match) + m2 = m._matches(match) self.assertEqual( [b'a/b/c/bar.txt', b'a/b/c/foo.txt', b'a/b/d/ten.txt'], m2.keys()