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

        k._parents = [frozenset(),
                frozenset([0]),
                frozenset([0]),
                frozenset([0,1,2]),
                ]
        k._weave = [('{', 0),
                'foo {',
                ('{', 1),
                '  added in version 1',
                ('{', 1),
                '  more in 1',
                ('}', 1),
                ('}', 1),
                ('}', 0)]


        # this is not currently enforced by get
        return  ##########################################

        self.assertRaises(WeaveFormatError,
                          k.get,
                          0)

        self.assertRaises(WeaveFormatError,
                          k.get,
                          1)
Exemplo n.º 2
0
    def runTest(self):
        k = Weave()

        k._parents = [frozenset(),
                ]
        k._weave = ['bad line',
                ('{', 0),
                'foo {',
                ('{', 1),
                '  added in version 1',
                ('{', 2),
                '  added in v2',
                ('}', 2),
                '  also from v1',
                ('}', 1),
                '}',
                ('}', 0)]

        ################################### SKIPPED
        # Weave.get doesn't trap this anymore
        return 


        self.assertRaises(WeaveFormatError,
                          k.get,
                          0)
Exemplo n.º 3
0
    def runTest(self):
        k = Weave()

        k._parents = [frozenset(),
                frozenset([0]),
                ]
        k._weave = [('{', 0),
                'first line',
                ('[', 1),
                'line to be deleted',
                (']', 1),
                ('{', 1),
                'replacement line',                
                ('}', 1),
                'last line',
                ('}', 0),
                ]
        k._sha1s = [sha_string('first lineline to be deletedlast line')
                  , sha_string('first linereplacement linelast line')]

        self.assertEqual(k.get_lines(0),
                         ['first line',
                          'line to be deleted',
                          'last line',
                          ])

        self.assertEqual(k.get_lines(1),
                         ['first line',
                          'replacement line',
                          'last line',
                          ])
Exemplo n.º 4
0
    def runTest(self):
        k = Weave()

        k._parents = [frozenset(),
                frozenset([0]),
                frozenset([0]),
                frozenset([0,1,2]),
                ]
        k._weave = [('{', 0),
                'foo {',
                ('{', 1),
                '  added in version 1',
                ('{', 2),
                '  added in v2',
                ('}', 2),
                '  also from v1',
                ('}', 1),
                '}',
                ('}', 0)]

        k._sha1s = [sha_string('foo {}')
                  , sha_string('foo {  added in version 1  also from v1}')
                  , sha_string('foo {  added in v2}')
                  , sha_string('foo {  added in version 1  added in v2  also from v1}')
                  ]

        self.assertEqual(k.get_lines(0),
                         ['foo {',
                          '}'])

        self.assertEqual(k.get_lines(1),
                         ['foo {',
                          '  added in version 1',
                          '  also from v1',
                          '}'])
                       
        self.assertEqual(k.get_lines(2),
                         ['foo {',
                          '  added in v2',
                          '}'])

        self.assertEqual(k.get_lines(3),
                         ['foo {',
                          '  added in version 1',
                          '  added in v2',
                          '  also from v1',
                          '}'])
Exemplo n.º 5
0
    def runTest(self):
        k = Weave()

        k._parents = [(),
                ]
        k._weave = [('{', 0),
                'first line',
                ('[', 0),
                'deleted in 0',
                (']', 0),
                ('}', 0),
                ]
        ################################### SKIPPED
        # Weave.get doesn't trap this anymore
        return 

        self.assertRaises(WeaveFormatError,
                          k.get_lines,
                          0)        
Exemplo n.º 6
0
    def runTest(self):
        k = Weave()

        k._parents = [frozenset(), frozenset([0])]
        k._weave = [('{', 0),
                "first line",
                ('}', 0),
                ('{', 1),
                "second line",
                ('}', 1)]

        k._sha1s = [sha_string('first line')
                  , sha_string('first linesecond line')]

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

        self.assertEqual(k.get_lines(0),
                         ["first line"])
Exemplo n.º 7
0
    def runTest(self):
        k = Weave()

        k._parents = [frozenset(), frozenset([0])]
        k._weave = [('{', 0),
                "first line",
                ('}', 0),
                ('{', 1),
                "second line",
                ('}', 1)]

        k._sha1s = [sha_string('first line')
                  , sha_string('first linesecond line')]

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

        self.assertEqual(k.get_lines(0),
                         ["first line"])
Exemplo n.º 8
0
    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'])
Exemplo n.º 9
0
    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'])