~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/pack_repo.py

  • Committer: Gary van der Merwe
  • Date: 2010-08-02 19:56:52 UTC
  • mfrom: (5050.3.18 2.2)
  • mto: (5050.3.19 2.2)
  • mto: This revision was merged to the branch mainline in revision 5371.
  • Revision ID: garyvdm@gmail.com-20100802195652-o1ppjemhwrr98i61
MergeĀ lp:bzr/2.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
""")
50
50
from bzrlib import (
51
51
    bzrdir,
52
 
    btree_index,
53
52
    errors,
54
53
    lockable_files,
55
54
    lockdir,
57
56
    )
58
57
 
59
58
from bzrlib.decorators import needs_write_lock, only_raises
 
59
from bzrlib.btree_index import (
 
60
    BTreeGraphIndex,
 
61
    BTreeBuilder,
 
62
    )
60
63
from bzrlib.index import (
61
64
    GraphIndex,
62
65
    InMemoryGraphIndex,
228
231
        unlimited_cache = False
229
232
        if index_type == 'chk':
230
233
            unlimited_cache = True
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)
 
234
        setattr(self, index_type + '_index',
 
235
            self.index_class(self.index_transport,
 
236
                self.index_name(index_type, self.name),
 
237
                self.index_sizes[self.index_offset(index_type)],
 
238
                unlimited_cache=unlimited_cache))
238
239
 
239
240
 
240
241
class ExistingPack(Pack):
722
723
        :return: A Pack object, or None if nothing was copied.
723
724
        """
724
725
        # open a pack - using the same name as the last temporary file
725
 
        # - which has already been flushed, so it's safe.
 
726
        # - which has already been flushed, so its safe.
726
727
        # XXX: - duplicate code warning with start_write_group; fix before
727
728
        #      considering 'done'.
728
729
        if self._pack_collection._new_pack is not None:
1292
1293
        # reinserted, and if d3 has incorrect parents it will also be
1293
1294
        # reinserted. If we insert d3 first, d2 is present (as it was bulk
1294
1295
        # copied), so we will try to delta, but d2 is not currently able to be
1295
 
        # extracted because its basis d1 is not present. Topologically sorting
 
1296
        # extracted because it's basis d1 is not present. Topologically sorting
1296
1297
        # addresses this. The following generates a sort for all the texts that
1297
1298
        # are being inserted without having to reference the entire text key
1298
1299
        # space (we only topo sort the revisions, which is smaller).
1600
1601
        pack_operations = [[0, []]]
1601
1602
        # plan out what packs to keep, and what to reorganise
1602
1603
        while len(existing_packs):
1603
 
            # take the largest pack, and if it's less than the head of the
 
1604
            # take the largest pack, and if its less than the head of the
1604
1605
            # distribution chart we will include its contents in the new pack
1605
 
            # for that position. If it's larger, we remove its size from the
 
1606
            # for that position. If its larger, we remove its size from the
1606
1607
            # distribution chart
1607
1608
            next_pack_rev_count, next_pack = existing_packs.pop(0)
1608
1609
            if next_pack_rev_count >= pack_distribution[0]:
1643
1644
 
1644
1645
        :return: True if the disk names had not been previously read.
1645
1646
        """
1646
 
        # NB: if you see an assertion error here, it's probably access against
 
1647
        # NB: if you see an assertion error here, its probably access against
1647
1648
        # an unlocked repo. Naughty.
1648
1649
        if not self.repo.is_locked():
1649
1650
            raise errors.ObjectNotLocked(self.repo)
1679
1680
            txt_index = self._make_index(name, '.tix')
1680
1681
            sig_index = self._make_index(name, '.six')
1681
1682
            if self.chk_index is not None:
1682
 
                chk_index = self._make_index(name, '.cix', is_chk=True)
 
1683
                chk_index = self._make_index(name, '.cix', unlimited_cache=True)
1683
1684
            else:
1684
1685
                chk_index = None
1685
1686
            result = ExistingPack(self._pack_transport, name, rev_index,
1705
1706
            sig_index = self._make_index(name, '.six', resume=True)
1706
1707
            if self.chk_index is not None:
1707
1708
                chk_index = self._make_index(name, '.cix', resume=True,
1708
 
                                             is_chk=True)
 
1709
                                             unlimited_cache=True)
1709
1710
            else:
1710
1711
                chk_index = None
1711
1712
            result = self.resumed_pack_factory(name, rev_index, inv_index,
1741
1742
        return self._index_class(self.transport, 'pack-names', None
1742
1743
                ).iter_all_entries()
1743
1744
 
1744
 
    def _make_index(self, name, suffix, resume=False, is_chk=False):
 
1745
    def _make_index(self, name, suffix, resume=False, unlimited_cache=False):
1745
1746
        size_offset = self._suffix_offsets[suffix]
1746
1747
        index_name = name + suffix
1747
1748
        if resume:
1750
1751
        else:
1751
1752
            transport = self._index_transport
1752
1753
            index_size = self._names[name][size_offset]
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
        return self._index_class(transport, index_name, index_size,
 
1755
                                 unlimited_cache=unlimited_cache)
1758
1756
 
1759
1757
    def _max_pack_count(self, total_revisions):
1760
1758
        """Return the maximum number of packs to use for total revisions.
1946
1944
                    # disk index because the set values are the same, unless
1947
1945
                    # the only index shows up as deleted by the set difference
1948
1946
                    # - which it may. Until there is a specific test for this,
1949
 
                    # assume it's broken. RBC 20071017.
 
1947
                    # assume its broken. RBC 20071017.
1950
1948
                    self._remove_pack_from_memory(self.get_pack_by_name(name))
1951
1949
                    self._names[name] = sizes
1952
1950
                    self.get_pack_by_name(name)
2017
2015
        """
2018
2016
        # The ensure_loaded call is to handle the case where the first call
2019
2017
        # made involving the collection was to reload_pack_names, where we 
2020
 
        # don't have a view of disk contents. It's a bit of a bandaid, and
2021
 
        # causes two reads of pack-names, but it's a rare corner case not
2022
 
        # struck with regular push/pull etc.
 
2018
        # don't have a view of disk contents. Its a bit of a bandaid, and
 
2019
        # causes two reads of pack-names, but its a rare corner case not struck
 
2020
        # with regular push/pull etc.
2023
2021
        first_read = self.ensure_loaded()
2024
2022
        if first_read:
2025
2023
            return True
2831
2829
    _commit_builder_class = PackCommitBuilder
2832
2830
    supports_external_lookups = True
2833
2831
    # What index classes to use
2834
 
    index_builder_class = btree_index.BTreeBuilder
2835
 
    index_class = btree_index.BTreeGraphIndex
 
2832
    index_builder_class = BTreeBuilder
 
2833
    index_class = BTreeGraphIndex
2836
2834
 
2837
2835
    @property
2838
2836
    def _serializer(self):
2867
2865
    supports_tree_reference = False # no subtrees
2868
2866
    supports_external_lookups = True
2869
2867
    # What index classes to use
2870
 
    index_builder_class = btree_index.BTreeBuilder
2871
 
    index_class = btree_index.BTreeGraphIndex
 
2868
    index_builder_class = BTreeBuilder
 
2869
    index_class = BTreeGraphIndex
2872
2870
 
2873
2871
    @property
2874
2872
    def _serializer(self):
2909
2907
    supports_tree_reference = True
2910
2908
    supports_external_lookups = True
2911
2909
    # What index classes to use
2912
 
    index_builder_class = btree_index.BTreeBuilder
2913
 
    index_class = btree_index.BTreeGraphIndex
 
2910
    index_builder_class = BTreeBuilder
 
2911
    index_class = BTreeGraphIndex
2914
2912
 
2915
2913
    @property
2916
2914
    def _serializer(self):
2918
2916
 
2919
2917
    def _get_matching_bzrdir(self):
2920
2918
        return bzrdir.format_registry.make_bzrdir(
2921
 
            'development5-subtree')
 
2919
            'development-subtree')
2922
2920
 
2923
2921
    def _ignore_setting_bzrdir(self, format):
2924
2922
        pass