##// END OF EJS Templates
match: teach diffmatcher.visitdir() to return 'all' if possible...
Pulkit Goyal -
r41669:b7a0efb3 default
parent child Browse files
Show More
@@ -677,6 +677,9 b' class differencematcher(basematcher):'
677 def visitdir(self, dir):
677 def visitdir(self, dir):
678 if self._m2.visitdir(dir) == 'all':
678 if self._m2.visitdir(dir) == 'all':
679 return False
679 return False
680 elif not self._m2.visitdir(dir):
681 # m2 does not match dir, we can return 'all' here if possible
682 return self._m1.visitdir(dir)
680 return bool(self._m1.visitdir(dir))
683 return bool(self._m1.visitdir(dir))
681
684
682 def visitchildrenset(self, dir):
685 def visitchildrenset(self, dir):
@@ -255,20 +255,19 b' class DifferenceMatcherTests(unittest.Te'
255 m1 = matchmod.alwaysmatcher(b'', b'')
255 m1 = matchmod.alwaysmatcher(b'', b'')
256 m2 = matchmod.nevermatcher(b'', b'')
256 m2 = matchmod.nevermatcher(b'', b'')
257 dm = matchmod.differencematcher(m1, m2)
257 dm = matchmod.differencematcher(m1, m2)
258 # dm should be equivalent to a alwaysmatcher. OPT: if m2 is a
258 # dm should be equivalent to a alwaysmatcher.
259 # nevermatcher, we could return 'all' for these.
260 #
259 #
261 # We're testing Equal-to-True instead of just 'assertTrue' since
260 # We're testing Equal-to-True instead of just 'assertTrue' since
262 # assertTrue does NOT verify that it's a bool, just that it's truthy.
261 # assertTrue does NOT verify that it's a bool, just that it's truthy.
263 # While we may want to eventually make these return 'all', they should
262 # While we may want to eventually make these return 'all', they should
264 # not currently do so.
263 # not currently do so.
265 self.assertEqual(dm.visitdir(b'.'), True)
264 self.assertEqual(dm.visitdir(b'.'), 'all')
266 self.assertEqual(dm.visitdir(b'dir'), True)
265 self.assertEqual(dm.visitdir(b'dir'), 'all')
267 self.assertEqual(dm.visitdir(b'dir/subdir'), True)
266 self.assertEqual(dm.visitdir(b'dir/subdir'), 'all')
268 self.assertEqual(dm.visitdir(b'dir/subdir/z'), True)
267 self.assertEqual(dm.visitdir(b'dir/subdir/z'), 'all')
269 self.assertEqual(dm.visitdir(b'dir/foo'), True)
268 self.assertEqual(dm.visitdir(b'dir/foo'), 'all')
270 self.assertEqual(dm.visitdir(b'dir/subdir/x'), True)
269 self.assertEqual(dm.visitdir(b'dir/subdir/x'), 'all')
271 self.assertEqual(dm.visitdir(b'folder'), True)
270 self.assertEqual(dm.visitdir(b'folder'), 'all')
272
271
273 def testVisitchildrensetM2never(self):
272 def testVisitchildrensetM2never(self):
274 m1 = matchmod.alwaysmatcher(b'', b'')
273 m1 = matchmod.alwaysmatcher(b'', b'')
@@ -295,9 +294,8 b' class DifferenceMatcherTests(unittest.Te'
295 # an 'all' pattern, just True.
294 # an 'all' pattern, just True.
296 self.assertEqual(dm.visitdir(b'dir/subdir/z'), True)
295 self.assertEqual(dm.visitdir(b'dir/subdir/z'), True)
297 self.assertEqual(dm.visitdir(b'dir/subdir/x'), True)
296 self.assertEqual(dm.visitdir(b'dir/subdir/x'), True)
298 # OPT: We could return 'all' for these.
297 self.assertEqual(dm.visitdir(b'dir/foo'), 'all')
299 self.assertEqual(dm.visitdir(b'dir/foo'), True)
298 self.assertEqual(dm.visitdir(b'folder'), 'all')
300 self.assertEqual(dm.visitdir(b'folder'), True)
301
299
302 def testVisitchildrensetM2SubdirPrefix(self):
300 def testVisitchildrensetM2SubdirPrefix(self):
303 m1 = matchmod.alwaysmatcher(b'', b'')
301 m1 = matchmod.alwaysmatcher(b'', b'')
@@ -322,7 +320,7 b' class DifferenceMatcherTests(unittest.Te'
322 dm = matchmod.differencematcher(m1, m2)
320 dm = matchmod.differencematcher(m1, m2)
323 self.assertEqual(dm.visitdir(b'.'), True)
321 self.assertEqual(dm.visitdir(b'.'), True)
324 self.assertEqual(dm.visitdir(b'dir'), True)
322 self.assertEqual(dm.visitdir(b'dir'), True)
325 self.assertEqual(dm.visitdir(b'dir/subdir'), True)
323 self.assertEqual(dm.visitdir(b'dir/subdir'), 'all')
326 self.assertFalse(dm.visitdir(b'dir/foo'))
324 self.assertFalse(dm.visitdir(b'dir/foo'))
327 self.assertFalse(dm.visitdir(b'folder'))
325 self.assertFalse(dm.visitdir(b'folder'))
328 # OPT: We should probably return False for these; we don't because
326 # OPT: We should probably return False for these; we don't because
General Comments 0
You need to be logged in to leave comments. Login now