def runTest(self): k = Weave() texts = [['header'], ['header', '', 'line from 1'], ['header', '', 'line from 2', 'more from 2'], ['header', '', 'line from 1', 'fixup line', 'line from 2'], ] k.add_lines('text0', [], texts[0]) k.add_lines('text1', ['text0'], texts[1]) k.add_lines('text2', ['text0'], texts[2]) k.add_lines('merge', ['text0', 'text1', 'text2'], texts[3]) for i, t in enumerate(texts): self.assertEqual(k.get_lines(i), t) self.assertEqual(k.annotate('merge'), [('text0', 'header'), ('text1', ''), ('text1', 'line from 1'), ('merge', 'fixup line'), ('text2', 'line from 2'), ]) self.assertEqual(list(k.get_ancestry(['merge'])), ['text0', 'text1', 'text2', 'merge']) self.log('k._weave=' + pformat(k._weave)) self.check_read_write(k)
def runTest(self): # FIXME make the weave, dont poke at it. k = Weave() k._names = ['0', '1', '2'] k._name_map = {'0':0, '1':1, '2':2} k._parents = [frozenset(), frozenset([0]), frozenset([0]), ] k._weave = [('{', 0), "first line", ('}', 0), ('{', 1), "second line", ('}', 1), ('{', 2), "alternative second line", ('}', 2), ] k._sha1s = [sha_string('first line') , sha_string('first linesecond line') , sha_string('first linealternative second line')] self.assertEqual(k.get_lines(0), ["first line"]) self.assertEqual(k.get_lines(1), ["first line", "second line"]) self.assertEqual(k.get_lines('2'), ["first line", "alternative second line"]) self.assertEqual(list(k.get_ancestry(['2'])), ['0', '2'])