comparison tests/test-manifest.py @ 31876:94c1d3c1aea2

treemanifest: add walksubtrees api Adds a new function to treemanifest that allows walking over the directories in the tree. Currently it only accepts a matcher to prune the walk, but in the future it will also accept a list of trees and will only walk over subtrees that differ from the versions in the list. This will be useful for identifying what parts of the tree are new to this revision, which is useful when deciding the minimal set of trees to send to a client given that they have a certain tree already. Since this is intended for an extension to use, the only current consumer is a test. In the future this function may be useful for implementing other algorithms like diff and changegroup generation.
author Durham Goode <durham@fb.com>
date Mon, 10 Apr 2017 13:07:47 -0700
parents 959ebff3505a
children 68c43a416585
comparison
equal deleted inserted replaced
31875:b6d792a9bd11 31876:94c1d3c1aea2
465 465
466 class testtreemanifest(unittest.TestCase, basemanifesttests): 466 class testtreemanifest(unittest.TestCase, basemanifesttests):
467 def parsemanifest(self, text): 467 def parsemanifest(self, text):
468 return manifestmod.treemanifest('', text) 468 return manifestmod.treemanifest('', text)
469 469
470 def testWalkSubtrees(self):
471 m = self.parsemanifest(A_DEEPER_MANIFEST)
472
473 dirs = [s._dir for s in m.walksubtrees()]
474 self.assertEqual(
475 sorted(['', 'a/', 'a/c/', 'a/d/', 'a/b/', 'a/b/c/', 'a/b/d/']),
476 sorted(dirs)
477 )
478
479 match = matchmod.match('/', '', ['path:a/b/'])
480 dirs = [s._dir for s in m.walksubtrees(matcher=match)]
481 self.assertEqual(
482 sorted(['a/b/', 'a/b/c/', 'a/b/d/']),
483 sorted(dirs)
484 )
485
470 if __name__ == '__main__': 486 if __name__ == '__main__':
471 silenttestrunner.main(__name__) 487 silenttestrunner.main(__name__)