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,
587
self.assertEqual([], progress.updates)
588
except AssertionError:
589
self.assertEqual(expected,
571
lines = iter_with_versions(['child', 'otherchild'])
592
lines = iter_with_versions(['child', 'otherchild'],
593
[('Walking content.', 0, 2),
594
('Walking content.', 0, 2),
595
('Walking content.', 3, 2),
596
('Walking content.', 2, 2)])
572
597
# we must see child and otherchild
573
598
self.assertTrue(lines['child\n'] > 0)
574
599
self.assertTrue(lines['otherchild\n'] > 0)
575
600
# we dont care if we got more than that.
578
lines = iter_with_versions(None)
603
lines = iter_with_versions(None, [('Walking content.', 0, 5),
604
('Walking content.', 0, 5),
605
('Walking content.', 1, 5),
606
('Walking content.', 2, 5),
607
('Walking content.', 2, 5),
608
('Walking content.', 3, 5),
609
('Walking content.', 5, 5)])
579
610
# all lines must be seen at least once
580
611
self.assertTrue(lines['base\n'] > 0)
581
612
self.assertTrue(lines['lancestor\n'] > 0)