Exemplo n.º 1
0
    def runTest(self):
        k = Weave()

        k.add_lines('text0', [], ['line 1'])
        k.add_lines('text1', ['text0'], ['line 1', 'line 2'])

        self.assertEqual(k.annotate('text0'),
                         [('text0', 'line 1')])

        self.assertEqual(k.get_lines(1),
                         ['line 1',
                          'line 2'])

        self.assertEqual(k.annotate('text1'),
                         [('text0', 'line 1'),
                          ('text1', 'line 2')])

        k.add_lines('text2', ['text0'], ['line 1', 'diverged line'])

        self.assertEqual(k.annotate('text2'),
                         [('text0', 'line 1'),
                          ('text2', 'diverged line')])

        text3 = ['line 1', 'middle line', 'line 2']
        k.add_lines('text3',
              ['text0', 'text1'],
              text3)

        # self.log("changes to text3: " + pformat(list(k._delta(set([0, 1]), text3))))

        self.log("k._weave=" + pformat(k._weave))

        self.assertEqual(k.annotate('text3'),
                         [('text0', 'line 1'),
                          ('text3', 'middle line'),
                          ('text1', 'line 2')])

        # now multiple insertions at different places
        k.add_lines('text4',
              ['text0', 'text1', 'text3'],
              ['line 1', 'aaa', 'middle line', 'bbb', 'line 2', 'ccc'])

        self.assertEqual(k.annotate('text4'),
                         [('text0', 'line 1'),
                          ('text4', 'aaa'),
                          ('text3', 'middle line'),
                          ('text4', 'bbb'),
                          ('text1', 'line 2'),
                          ('text4', 'ccc')])
Exemplo n.º 2
0
    def runTest(self):
        k = Weave()

        k.add_lines('text0', [], ['line 1'])
        k.add_lines('text1', ['text0'], ['line 1', 'line 2'])

        self.assertEqual(k.annotate('text0'),
                         [('text0', 'line 1')])

        self.assertEqual(k.get_lines(1),
                         ['line 1',
                          'line 2'])

        self.assertEqual(k.annotate('text1'),
                         [('text0', 'line 1'),
                          ('text1', 'line 2')])

        k.add_lines('text2', ['text0'], ['line 1', 'diverged line'])

        self.assertEqual(k.annotate('text2'),
                         [('text0', 'line 1'),
                          ('text2', 'diverged line')])

        text3 = ['line 1', 'middle line', 'line 2']
        k.add_lines('text3',
              ['text0', 'text1'],
              text3)

        # self.log("changes to text3: " + pformat(list(k._delta(set([0, 1]), text3))))

        self.log("k._weave=" + pformat(k._weave))

        self.assertEqual(k.annotate('text3'),
                         [('text0', 'line 1'),
                          ('text3', 'middle line'),
                          ('text1', 'line 2')])

        # now multiple insertions at different places
        k.add_lines('text4',
              ['text0', 'text1', 'text3'],
              ['line 1', 'aaa', 'middle line', 'bbb', 'line 2', 'ccc'])

        self.assertEqual(k.annotate('text4'), 
                         [('text0', 'line 1'),
                          ('text4', 'aaa'),
                          ('text3', 'middle line'),
                          ('text4', 'bbb'),
                          ('text1', 'line 2'),
                          ('text4', 'ccc')])
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    def runTest(self):
        k = Weave()

        k.add_lines('text0', [], ["line the first",
                   "line 2",
                   "line 3",
                   "fine"])

        self.assertEqual(len(k.get_lines(0)), 4)

        k.add_lines('text1', ['text0'], ["line the first",
                   "fine"])

        self.assertEqual(k.get_lines(1),
                         ["line the first",
                          "fine"])

        self.assertEqual(k.annotate('text1'),
                         [('text0', "line the first"),
                          ('text0', "fine")])
Exemplo n.º 6
0
    def runTest(self):
        k = Weave()

        k.add_lines('text0', [], ["line the first",
                   "line 2",
                   "line 3",
                   "fine"])

        self.assertEqual(len(k.get_lines(0)), 4)

        k.add_lines('text1', ['text0'], ["line the first",
                   "fine"])

        self.assertEqual(k.get_lines(1),
                         ["line the first",
                          "fine"])

        self.assertEqual(k.annotate('text1'),
                         [('text0', "line the first"),
                          ('text0', "fine")])
Exemplo n.º 7
0
 def runTest(self):
     k = Weave()
     k.add_lines('text0', [], TEXT_0)
     self.assertEqual(k.annotate('text0'),
                      [('text0', TEXT_0[0])])
Exemplo n.º 8
0
 def runTest(self):
     k = Weave()
     k.add_lines('text0', [], TEXT_0)
     self.assertEqual(k.annotate('text0'),
                      [('text0', TEXT_0[0])])