~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/pack_repo.py

  • Committer: John Arbash Meinel
  • Date: 2010-08-05 19:25:52 UTC
  • mto: This revision was merged to the branch mainline in revision 5390.
  • Revision ID: john@arbash-meinel.com-20100805192552-sqoq0ux1juy9giru
Add some tests that check the leaf factory is correct.

I'm not really happy about how this is getting exposed. I'll ask in review.

Show diffs side-by-side

added added

removed removed

Lines of Context:
228
228
        unlimited_cache = False
229
229
        if index_type == 'chk':
230
230
            unlimited_cache = True
231
 
        setattr(self, index_type + '_index',
232
 
            self.index_class(self.index_transport,
233
 
                self.index_name(index_type, self.name),
234
 
                self.index_sizes[self.index_offset(index_type)],
235
 
                unlimited_cache=unlimited_cache))
 
231
        index = self.index_class(self.index_transport,
 
232
                    self.index_name(index_type, self.name),
 
233
                    self.index_sizes[self.index_offset(index_type)],
 
234
                    unlimited_cache=unlimited_cache)
 
235
        if index_type == 'chk':
 
236
            index._leaf_factory = btree_index._gcchk_factory
 
237
        setattr(self, index_type + '_index', index)
236
238
 
237
239
 
238
240
class ExistingPack(Pack):
1677
1679
            txt_index = self._make_index(name, '.tix')
1678
1680
            sig_index = self._make_index(name, '.six')
1679
1681
            if self.chk_index is not None:
1680
 
                chk_index = self._make_index(name, '.cix', unlimited_cache=True)
1681
 
                chk_index._leaf_factory = btree_index._gcchk_factory
 
1682
                chk_index = self._make_index(name, '.cix', is_chk=True)
1682
1683
            else:
1683
1684
                chk_index = None
1684
1685
            result = ExistingPack(self._pack_transport, name, rev_index,
1704
1705
            sig_index = self._make_index(name, '.six', resume=True)
1705
1706
            if self.chk_index is not None:
1706
1707
                chk_index = self._make_index(name, '.cix', resume=True,
1707
 
                                             unlimited_cache=True)
 
1708
                                             is_chk=True)
1708
1709
            else:
1709
1710
                chk_index = None
1710
1711
            result = self.resumed_pack_factory(name, rev_index, inv_index,
1740
1741
        return self._index_class(self.transport, 'pack-names', None
1741
1742
                ).iter_all_entries()
1742
1743
 
1743
 
    def _make_index(self, name, suffix, resume=False, unlimited_cache=False):
 
1744
    def _make_index(self, name, suffix, resume=False, is_chk=False):
1744
1745
        size_offset = self._suffix_offsets[suffix]
1745
1746
        index_name = name + suffix
1746
1747
        if resume:
1749
1750
        else:
1750
1751
            transport = self._index_transport
1751
1752
            index_size = self._names[name][size_offset]
1752
 
        return self._index_class(transport, index_name, index_size,
1753
 
                                 unlimited_cache=unlimited_cache)
 
1753
        index = self._index_class(transport, index_name, index_size,
 
1754
                                  unlimited_cache=is_chk)
 
1755
        if is_chk and self._index_class is btree_index.BTreeGraphIndex: 
 
1756
            index._leaf_factory = btree_index._gcchk_factory
 
1757
        return index
1754
1758
 
1755
1759
    def _max_pack_count(self, total_revisions):
1756
1760
        """Return the maximum number of packs to use for total revisions.