543
546
# versions in the weave
544
547
# the ordering here is to make a tree so that dumb searches have
545
548
# more changes to muck up.
550
class InstrumentedProgress(progress.DummyProgress):
554
progress.DummyProgress.__init__(self)
557
def update(self, msg=None, current=None, total=None):
558
self.updates.append((msg, current, total))
546
560
vf = self.get_file()
547
561
# add a base to get included
548
562
vf.add_lines('base', [], ['base\n'])
556
570
vf.add_lines('otherchild',
557
571
['lancestor', 'base'],
558
572
['base\n', 'lancestor\n', 'otherchild\n'])
559
def iter_with_versions(versions):
573
def iter_with_versions(versions, expected):
560
574
# now we need to see what lines are returned, and how often.
561
575
lines = {'base\n':0,
565
579
'otherchild\n':0,
581
progress = InstrumentedProgress()
567
582
# iterate over the lines
568
for line in vf.iter_lines_added_or_present_in_versions(versions):
583
for line in vf.iter_lines_added_or_present_in_versions(versions,
586
if []!= progress.updates:
587
self.assertEqual(expected, progress.updates)
571
lines = iter_with_versions(['child', 'otherchild'])
589
lines = iter_with_versions(['child', 'otherchild'],
590
[('Walking content.', 0, 2),
591
('Walking content.', 0, 2),
592
('Walking content.', 3, 2),
593
('Walking content.', 2, 2)])
572
594
# we must see child and otherchild
573
595
self.assertTrue(lines['child\n'] > 0)
574
596
self.assertTrue(lines['otherchild\n'] > 0)
575
597
# we dont care if we got more than that.
578
lines = iter_with_versions(None)
600
lines = iter_with_versions(None, [('Walking content.', 0, 5),
601
('Walking content.', 0, 5),
602
('Walking content.', 1, 5),
603
('Walking content.', 2, 5),
604
('Walking content.', 2, 5),
605
('Walking content.', 3, 5),
606
('Walking content.', 5, 5)])
579
607
# all lines must be seen at least once
580
608
self.assertTrue(lines['base\n'] > 0)
581
609
self.assertTrue(lines['lancestor\n'] > 0)