137
140
except NotImplementedError:
143
def test_add_reserved(self):
145
self.assertRaises(errors.ReservedId,
146
vf.add_lines, 'a:', [], ['a\n', 'b\n', 'c\n'])
148
self.assertRaises(errors.ReservedId,
149
vf.add_delta, 'a:', [], None, 'sha1', False, ((0, 0, 0, []),))
151
def test_get_reserved(self):
153
self.assertRaises(errors.ReservedId, vf.get_delta, 'b:')
154
self.assertRaises(errors.ReservedId, vf.get_texts, ['b:'])
155
self.assertRaises(errors.ReservedId, vf.get_lines, 'b:')
156
self.assertRaises(errors.ReservedId, vf.get_text, 'b:')
140
158
def test_get_delta(self):
141
159
f = self.get_file()
142
160
sha1s = self._setup_for_deltas(f)
543
561
# versions in the weave
544
562
# the ordering here is to make a tree so that dumb searches have
545
563
# more changes to muck up.
565
class InstrumentedProgress(progress.DummyProgress):
569
progress.DummyProgress.__init__(self)
572
def update(self, msg=None, current=None, total=None):
573
self.updates.append((msg, current, total))
546
575
vf = self.get_file()
547
576
# add a base to get included
548
577
vf.add_lines('base', [], ['base\n'])
556
585
vf.add_lines('otherchild',
557
586
['lancestor', 'base'],
558
587
['base\n', 'lancestor\n', 'otherchild\n'])
559
def iter_with_versions(versions):
588
def iter_with_versions(versions, expected):
560
589
# now we need to see what lines are returned, and how often.
561
590
lines = {'base\n':0,
565
594
'otherchild\n':0,
596
progress = InstrumentedProgress()
567
597
# iterate over the lines
568
for line in vf.iter_lines_added_or_present_in_versions(versions):
598
for line in vf.iter_lines_added_or_present_in_versions(versions,
601
if []!= progress.updates:
602
self.assertEqual(expected, progress.updates)
571
lines = iter_with_versions(['child', 'otherchild'])
604
lines = iter_with_versions(['child', 'otherchild'],
605
[('Walking content.', 0, 2),
606
('Walking content.', 1, 2),
607
('Walking content.', 2, 2)])
572
608
# we must see child and otherchild
573
609
self.assertTrue(lines['child\n'] > 0)
574
610
self.assertTrue(lines['otherchild\n'] > 0)
575
611
# we dont care if we got more than that.
578
lines = iter_with_versions(None)
614
lines = iter_with_versions(None, [('Walking content.', 0, 5),
615
('Walking content.', 1, 5),
616
('Walking content.', 2, 5),
617
('Walking content.', 3, 5),
618
('Walking content.', 4, 5),
619
('Walking content.', 5, 5)])
579
620
# all lines must be seen at least once
580
621
self.assertTrue(lines['base\n'] > 0)
581
622
self.assertTrue(lines['lancestor\n'] > 0)
636
677
self.assertRaises(NotImplementedError, vf.get_parents_with_ghosts, 'foo')
637
678
self.assertRaises(NotImplementedError, vf.get_graph_with_ghosts)
680
vf = self.reopen_file()
639
681
# test key graph related apis: getncestry, _graph, get_parents
641
683
# - these are ghost unaware and must not be reflect ghosts