/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_knit.py

  • Committer: Robert Collins
  • Date: 2009-05-23 20:57:12 UTC
  • mfrom: (4371 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4441.
  • Revision ID: robertc@robertcollins.net-20090523205712-lcwbfqk6vwavinuv
MergeĀ .dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Tests for Knit data structure"""
18
18
 
368
368
        """
369
369
        tree = self.make_branch_and_memory_tree('tree')
370
370
        tree.lock_write()
371
 
        try:
372
 
            tree.add([''], ['root-id'])
373
 
            tree.commit('one', rev_id='rev-1')
374
 
            tree.commit('two', rev_id='rev-2')
375
 
            tree.commit('three', rev_id='rev-3')
376
 
            # Pack these two revisions into another pack file, but don't remove
377
 
            # the originials
378
 
            repo = tree.branch.repository
379
 
            collection = repo._pack_collection
380
 
            collection.ensure_loaded()
381
 
            orig_packs = collection.packs
382
 
            packer = pack_repo.Packer(collection, orig_packs, '.testpack')
383
 
            new_pack = packer.pack()
384
 
 
385
 
            vf = tree.branch.repository.revisions
386
 
        finally:
387
 
            tree.unlock()
388
 
        tree.branch.repository.lock_read()
389
 
        self.addCleanup(tree.branch.repository.unlock)
390
 
        del tree
 
371
        self.addCleanup(tree.unlock)
 
372
        tree.add([''], ['root-id'])
 
373
        tree.commit('one', rev_id='rev-1')
 
374
        tree.commit('two', rev_id='rev-2')
 
375
        tree.commit('three', rev_id='rev-3')
 
376
        # Pack these three revisions into another pack file, but don't remove
 
377
        # the originals
 
378
        repo = tree.branch.repository
 
379
        collection = repo._pack_collection
 
380
        collection.ensure_loaded()
 
381
        orig_packs = collection.packs
 
382
        packer = pack_repo.Packer(collection, orig_packs, '.testpack')
 
383
        new_pack = packer.pack()
 
384
        # forget about the new pack
 
385
        collection.reset()
 
386
        repo.refresh_data()
 
387
        vf = tree.branch.repository.revisions
391
388
        # Set up a reload() function that switches to using the new pack file
392
389
        new_index = new_pack.revision_index
393
390
        access_tuple = new_pack.access_tuple()
1639
1636
              ([('missing-parent', ), ('ghost', )], [('missing-parent', )]))])
1640
1637
        return graph_index
1641
1638
 
 
1639
    def make_g_index_missing_parent(self):
 
1640
        graph_index = self.make_g_index('missing_parent', 2,
 
1641
            [(('parent', ), ' 100 78', ([], [])),
 
1642
             (('tip', ), ' 100 78',
 
1643
              ([('parent', ), ('missing-parent', )], [('parent', )])),
 
1644
              ])
 
1645
        return graph_index
 
1646
 
1642
1647
    def make_g_index_no_external_refs(self):
1643
1648
        graph_index = self.make_g_index('no_external_refs', 2,
1644
1649
            [(('rev', ), ' 100 78',
1652
1657
        index.scan_unvalidated_index(unvalidated)
1653
1658
        self.assertEqual(frozenset(), index.get_missing_compression_parents())
1654
1659
 
1655
 
    def test_add_incomplete_unvalidated_index(self):
 
1660
    def test_add_missing_compression_parent_unvalidated_index(self):
1656
1661
        unvalidated = self.make_g_index_missing_compression_parent()
1657
1662
        combined = CombinedGraphIndex([unvalidated])
1658
1663
        index = _KnitGraphIndex(combined, lambda: True, deltas=True)
1664
1669
            frozenset([('missing-parent',)]),
1665
1670
            index.get_missing_compression_parents())
1666
1671
 
 
1672
    def test_add_missing_noncompression_parent_unvalidated_index(self):
 
1673
        unvalidated = self.make_g_index_missing_parent()
 
1674
        combined = CombinedGraphIndex([unvalidated])
 
1675
        index = _KnitGraphIndex(combined, lambda: True, deltas=True,
 
1676
            track_external_parent_refs=True)
 
1677
        index.scan_unvalidated_index(unvalidated)
 
1678
        self.assertEqual(
 
1679
            frozenset([('missing-parent',)]), index.get_missing_parents())
 
1680
 
 
1681
    def test_track_external_parent_refs(self):
 
1682
        g_index = self.make_g_index('empty', 2, [])
 
1683
        combined = CombinedGraphIndex([g_index])
 
1684
        index = _KnitGraphIndex(combined, lambda: True, deltas=True,
 
1685
            add_callback=self.catch_add, track_external_parent_refs=True)
 
1686
        self.caught_entries = []
 
1687
        index.add_records([
 
1688
            (('new-key',), 'fulltext,no-eol', (None, 50, 60),
 
1689
             [('parent-1',), ('parent-2',)])])
 
1690
        self.assertEqual(
 
1691
            frozenset([('parent-1',), ('parent-2',)]),
 
1692
            index.get_missing_parents())
 
1693
 
1667
1694
    def test_add_unvalidated_index_with_present_external_references(self):
1668
1695
        index = self.two_graph_index(deltas=True)
1669
1696
        # Ugly hack to get at one of the underlying GraphIndex objects that