~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_versionedfile.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-07-01 04:21:23 UTC
  • mfrom: (3350.8.14 stacking-knits)
  • Revision ID: pqm@pqm.ubuntu.com-20080701042123-zcmqzb7o6znwjx34
(robertc) Teach KnitVersionedFiles how to stack on other
        VersionedFile objects. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
501
501
        for version in multiparent.topo_iter(vf):
502
502
            mpdiff = vf.make_mpdiffs([version])[0]
503
503
            new_vf.add_mpdiffs([(version, vf.get_parent_map([version])[version],
504
 
                                 vf.get_sha1s([version])[0], mpdiff)])
 
504
                                 vf.get_sha1s([version])[version], mpdiff)])
505
505
            self.assertEqualDiff(vf.get_text(version),
506
506
                                 new_vf.get_text(version))
507
507
 
840
840
        vf.add_lines('b', ['a'], ['a\n'])
841
841
        # a file differing only in last newline.
842
842
        vf.add_lines('c', [], ['a'])
843
 
        self.assertEqual(['3f786850e387550fdab836ed7e6dc881de23001b',
844
 
                          '86f7e437faa5a7fce15d1ddcb9eaeaea377667b8',
845
 
                          '3f786850e387550fdab836ed7e6dc881de23001b'],
846
 
                          vf.get_sha1s(['a', 'c', 'b']))
 
843
        self.assertEqual({
 
844
            'a': '3f786850e387550fdab836ed7e6dc881de23001b',
 
845
            'c': '86f7e437faa5a7fce15d1ddcb9eaeaea377667b8',
 
846
            'b': '3f786850e387550fdab836ed7e6dc881de23001b',
 
847
            },
 
848
            vf.get_sha1s(['a', 'c', 'b']))
847
849
        
848
850
 
849
851
class TestWeave(TestCaseWithMemoryTransport, VersionedFileTestMixIn):
1562
1564
        for factory in entries:
1563
1565
            on_seen(factory.key)
1564
1566
            self.assertValidStorageKind(factory.storage_kind)
1565
 
            self.assertEqual(f.get_sha1s([factory.key])[0], factory.sha1)
 
1567
            self.assertEqual(f.get_sha1s([factory.key])[factory.key],
 
1568
                factory.sha1)
1566
1569
            self.assertEqual(parents[factory.key], factory.parents)
1567
1570
            self.assertIsInstance(factory.get_bytes_as(factory.storage_kind),
1568
1571
                str)
1627
1630
        for factory in entries:
1628
1631
            seen.append(factory.key)
1629
1632
            self.assertValidStorageKind(factory.storage_kind)
1630
 
            self.assertSubset([factory.sha1], [None, files.get_sha1s([factory.key])[0]])
 
1633
            self.assertSubset([factory.sha1],
 
1634
                [None, files.get_sha1s([factory.key])[factory.key]])
1631
1635
            self.assertEqual(parent_map[factory.key], factory.parents)
1632
1636
            # self.assertEqual(files.get_text(factory.key),
1633
1637
            self.assertIsInstance(factory.get_bytes_as('fulltext'), str)
1671
1675
        for factory in entries:
1672
1676
            seen.add(factory.key)
1673
1677
            self.assertValidStorageKind(factory.storage_kind)
1674
 
            self.assertEqual(files.get_sha1s([factory.key])[0], factory.sha1)
 
1678
            self.assertEqual(files.get_sha1s([factory.key])[factory.key],
 
1679
                factory.sha1)
1675
1680
            self.assertEqual(parent_map[factory.key], factory.parents)
1676
1681
            # currently no stream emits mpdiff
1677
1682
            self.assertRaises(errors.UnavailableRepresentation,
1710
1715
                self.assertEqual(None, factory.parents)
1711
1716
            else:
1712
1717
                self.assertValidStorageKind(factory.storage_kind)
1713
 
                self.assertEqual(files.get_sha1s([factory.key])[0], factory.sha1)
 
1718
                self.assertEqual(files.get_sha1s([factory.key])[factory.key],
 
1719
                    factory.sha1)
1714
1720
                self.assertEqual(parents[factory.key], factory.parents)
1715
1721
                self.assertIsInstance(factory.get_bytes_as(factory.storage_kind),
1716
1722
                    str)
1798
1804
                ('FileA', 'base'), ('FileB', 'origin'), ('FileA', 'left'),
1799
1805
                ('FileA', 'merged'), ('FileB', 'right'),
1800
1806
                ]
1801
 
        self.assertEqual([
1802
 
            '51c64a6f4fc375daf0d24aafbabe4d91b6f4bb44',
1803
 
            '00e364d235126be43292ab09cb4686cf703ddc17',
1804
 
            'a8478686da38e370e32e42e8a0c220e33ee9132f',
1805
 
            'ed8bce375198ea62444dc71952b22cfc2b09226d',
1806
 
            '9ef09dfa9d86780bdec9219a22560c6ece8e0ef1',
1807
 
            ],
 
1807
        self.assertEqual({
 
1808
            keys[0]: '51c64a6f4fc375daf0d24aafbabe4d91b6f4bb44',
 
1809
            keys[1]: '00e364d235126be43292ab09cb4686cf703ddc17',
 
1810
            keys[2]: 'a8478686da38e370e32e42e8a0c220e33ee9132f',
 
1811
            keys[3]: 'ed8bce375198ea62444dc71952b22cfc2b09226d',
 
1812
            keys[4]: '9ef09dfa9d86780bdec9219a22560c6ece8e0ef1',
 
1813
            },
1808
1814
            files.get_sha1s(keys))
1809
1815
        
1810
1816
    def test_insert_record_stream_empty(self):
2132
2138
            mpdiff = files.make_mpdiffs([key])[0]
2133
2139
            parents = files.get_parent_map([key])[key] or []
2134
2140
            target.add_mpdiffs(
2135
 
                [(key, parents, files.get_sha1s([key])[0], mpdiff)])
 
2141
                [(key, parents, files.get_sha1s([key])[key], mpdiff)])
2136
2142
            self.assertEqualDiff(
2137
2143
                files.get_record_stream([key], 'unordered',
2138
2144
                    True).next().get_bytes_as('fulltext'),