##// END OF EJS Templates
manifest: move matches method to be outside the interface...
Augie Fackler -
r44826:0bf3b5e8 default
parent child Browse files
Show More
@@ -985,18 +985,9 b' class imanifestdict(interfaceutil.Interf'
985 985 def hasdir(dir):
986 986 """Returns a bool indicating if a directory is in this manifest."""
987 987
988 def matches(match):
989 """Generate a new manifest filtered through a matcher.
990
991 Returns an object conforming to the ``imanifestdict`` interface.
992 """
993
994 988 def walk(match):
995 989 """Generator of paths in manifest satisfying a matcher.
996 990
997 This is equivalent to ``self.matches(match).iterkeys()`` except a new
998 manifest object is not created.
999
1000 991 If the matcher has explicit files listed and they don't exist in
1001 992 the manifest, ``match.bad()`` is called for each missing file.
1002 993 """
@@ -545,7 +545,7 b' class manifestdict(object):'
545 545 if not self.hasdir(fn):
546 546 match.bad(fn, None)
547 547
548 def matches(self, match):
548 def _matches(self, match):
549 549 '''generate a new manifest filtered by the match argument'''
550 550 if match.always():
551 551 return self.copy()
@@ -578,8 +578,8 b' class manifestdict(object):'
578 578 string.
579 579 '''
580 580 if match:
581 m1 = self.matches(match)
582 m2 = m2.matches(match)
581 m1 = self._matches(match)
582 m2 = m2._matches(match)
583 583 return m1.diff(m2, clean=clean)
584 584 return self._lm.diff(m2._lm, clean)
585 585
@@ -1075,8 +1075,8 b' class treemanifest(object):'
1075 1075 def filesnotin(self, m2, match=None):
1076 1076 '''Set of files in this manifest that are not in the other'''
1077 1077 if match and not match.always():
1078 m1 = self.matches(match)
1079 m2 = m2.matches(match)
1078 m1 = self._matches(match)
1079 m2 = m2._matches(match)
1080 1080 return m1.filesnotin(m2)
1081 1081
1082 1082 files = set()
@@ -1122,9 +1122,6 b' class treemanifest(object):'
1122 1122 def walk(self, match):
1123 1123 '''Generates matching file names.
1124 1124
1125 Equivalent to manifest.matches(match).iterkeys(), but without creating
1126 an entirely new manifest.
1127
1128 1125 It also reports nonexistent files by marking them bad with match.bad().
1129 1126 '''
1130 1127 if match.always():
@@ -1167,16 +1164,16 b' class treemanifest(object):'
1167 1164 for f in self._dirs[p]._walk(match):
1168 1165 yield f
1169 1166
1170 def matches(self, match):
1171 '''generate a new manifest filtered by the match argument'''
1172 if match.always():
1173 return self.copy()
1174
1175 return self._matches(match)
1176
1177 1167 def _matches(self, match):
1178 1168 '''recursively generate a new manifest filtered by the match argument.
1179 1169 '''
1170 if match.always():
1171 return self.copy()
1172 return self._matches_inner(match)
1173
1174 def _matches_inner(self, match):
1175 if match.always():
1176 return self.copy()
1180 1177
1181 1178 visit = match.visitchildrenset(self._dir[:-1])
1182 1179 if visit == b'all':
@@ -1207,7 +1204,7 b' class treemanifest(object):'
1207 1204 for dir, subm in pycompat.iteritems(self._dirs):
1208 1205 if visit and dir[:-1] not in visit:
1209 1206 continue
1210 m = subm._matches(match)
1207 m = subm._matches_inner(match)
1211 1208 if not m._isempty():
1212 1209 ret._dirs[dir] = m
1213 1210
@@ -1231,8 +1228,8 b' class treemanifest(object):'
1231 1228 string.
1232 1229 '''
1233 1230 if match and not match.always():
1234 m1 = self.matches(match)
1235 m2 = m2.matches(match)
1231 m1 = self._matches(match)
1232 m2 = m2._matches(match)
1236 1233 return m1.diff(m2, clean=clean)
1237 1234 result = {}
1238 1235 emptytree = treemanifest()
@@ -171,7 +171,7 b' class basemanifesttests(object):'
171 171 self.assertEqual(want, m[b'foo'])
172 172 # make sure the suffix survives a copy
173 173 match = matchmod.match(util.localpath(b'/repo'), b'', [b're:foo'])
174 m2 = m.matches(match)
174 m2 = m._matches(match)
175 175 self.assertEqual(want, m2[b'foo'])
176 176 self.assertEqual(1, len(m2))
177 177 m2 = m.copy()
@@ -196,7 +196,7 b' class basemanifesttests(object):'
196 196
197 197 match.matchfn = filt
198 198 with self.assertRaises(AssertionError):
199 m.matches(match)
199 m._matches(match)
200 200
201 201 def testRemoveItem(self):
202 202 m = self.parsemanifest(A_SHORT_MANIFEST)
@@ -300,7 +300,7 b' class basemanifesttests(object):'
300 300 m = self.parsemanifest(A_HUGE_MANIFEST)
301 301
302 302 match = matchmod.exact([b'file1', b'file200', b'file300'])
303 m2 = m.matches(match)
303 m2 = m._matches(match)
304 304
305 305 w = (b'file1\0%sx\n' b'file200\0%sl\n' b'file300\0%s\n') % (
306 306 HASH_2,
@@ -318,7 +318,7 b' class basemanifesttests(object):'
318 318 match = matchmod.exact(
319 319 [b'a/b/c/bar.txt', b'a/b/d/qux.py', b'readme.txt', b'nonexistent']
320 320 )
321 m2 = m.matches(match)
321 m2 = m._matches(match)
322 322
323 323 self.assertEqual(
324 324 [b'a/b/c/bar.txt', b'a/b/d/qux.py', b'readme.txt'], m2.keys()
@@ -332,7 +332,7 b' class basemanifesttests(object):'
332 332 match = matchmod.match(
333 333 util.localpath(b'/repo'), b'', [b'a/f'], default=b'relpath'
334 334 )
335 m2 = m.matches(match)
335 m2 = m._matches(match)
336 336
337 337 self.assertEqual([], m2.keys())
338 338
@@ -343,7 +343,7 b' class basemanifesttests(object):'
343 343
344 344 flist = m.keys()[80:300]
345 345 match = matchmod.exact(flist)
346 m2 = m.matches(match)
346 m2 = m._matches(match)
347 347
348 348 self.assertEqual(flist, m2.keys())
349 349
@@ -352,7 +352,7 b' class basemanifesttests(object):'
352 352 m = self.parsemanifest(A_DEEPER_MANIFEST)
353 353
354 354 match = matchmod.match(util.localpath(b'/repo'), b'', [b''])
355 m2 = m.matches(match)
355 m2 = m._matches(match)
356 356
357 357 self.assertEqual(m.keys(), m2.keys())
358 358
@@ -364,7 +364,7 b' class basemanifesttests(object):'
364 364 match = matchmod.match(
365 365 util.localpath(b'/repo'), b'', [b'a/b'], default=b'relpath'
366 366 )
367 m2 = m.matches(match)
367 m2 = m._matches(match)
368 368
369 369 self.assertEqual(
370 370 [
@@ -388,7 +388,7 b' class basemanifesttests(object):'
388 388 m = self.parsemanifest(A_DEEPER_MANIFEST)
389 389
390 390 match = matchmod.exact([b'a/b'])
391 m2 = m.matches(match)
391 m2 = m._matches(match)
392 392
393 393 self.assertEqual([], m2.keys())
394 394
@@ -400,7 +400,7 b' class basemanifesttests(object):'
400 400 match = matchmod.match(
401 401 util.localpath(b'/repo'), b'a/b', [b'.'], default=b'relpath'
402 402 )
403 m2 = m.matches(match)
403 m2 = m._matches(match)
404 404
405 405 self.assertEqual(
406 406 [
@@ -423,7 +423,7 b' class basemanifesttests(object):'
423 423 m = self.parsemanifest(A_DEEPER_MANIFEST)
424 424
425 425 match = matchmod.match(util.localpath(b'/repo'), b'', [b'a/b/*/*.txt'])
426 m2 = m.matches(match)
426 m2 = m._matches(match)
427 427
428 428 self.assertEqual(
429 429 [b'a/b/c/bar.txt', b'a/b/c/foo.txt', b'a/b/d/ten.txt'], m2.keys()
General Comments 0
You need to be logged in to leave comments. Login now