durin42 created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers.
REVISION SUMMARY In order to adequately smoke out any legacy consumers of the method, we rename it to _matches so it's clear that it's class-private. To my amazement, all consumers of this method really only wanted matching filenames, not a full filtered manifest. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D8085 AFFECTED FILES mercurial/interfaces/repository.py mercurial/manifest.py tests/test-manifest.py CHANGE DETAILS 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() diff --git a/mercurial/manifest.py b/mercurial/manifest.py --- a/mercurial/manifest.py +++ b/mercurial/manifest.py @@ -544,7 +544,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() @@ -577,8 +577,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) @@ -1073,8 +1073,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() @@ -1120,9 +1120,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(): @@ -1165,16 +1162,11 @@ 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() visit = match.visitchildrenset(self._dir[:-1]) if visit == b'all': @@ -1229,8 +1221,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/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. """ To: durin42, #hg-reviewers Cc: mercurial-devel _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel