~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/pack_repo.py

  • Committer: Martin Pool
  • Date: 2010-02-25 06:17:27 UTC
  • mfrom: (5055 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5057.
  • Revision ID: mbp@sourcefrog.net-20100225061727-4sd9lt0qmdc6087t
merge news

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
from bzrlib import (
26
26
    chk_map,
 
27
    cleanup,
27
28
    debug,
28
29
    graph,
29
30
    osutils,
646
647
        del self.combined_index._indices[:]
647
648
        self.add_callback = None
648
649
 
649
 
    def remove_index(self, index, pack):
 
650
    def remove_index(self, index):
650
651
        """Remove index from the indices used to answer queries.
651
652
 
652
653
        :param index: An index from the pack parameter.
653
 
        :param pack: A Pack instance.
654
654
        """
655
655
        del self.index_to_pack[index]
656
656
        self.combined_index._indices.remove(index)
1840
1840
        self._remove_pack_indices(pack)
1841
1841
        self.packs.remove(pack)
1842
1842
 
1843
 
    def _remove_pack_indices(self, pack):
1844
 
        """Remove the indices for pack from the aggregated indices."""
1845
 
        self.revision_index.remove_index(pack.revision_index, pack)
1846
 
        self.inventory_index.remove_index(pack.inventory_index, pack)
1847
 
        self.text_index.remove_index(pack.text_index, pack)
1848
 
        self.signature_index.remove_index(pack.signature_index, pack)
1849
 
        if self.chk_index is not None:
1850
 
            self.chk_index.remove_index(pack.chk_index, pack)
 
1843
    def _remove_pack_indices(self, pack, ignore_missing=False):
 
1844
        """Remove the indices for pack from the aggregated indices.
 
1845
        
 
1846
        :param ignore_missing: Suppress KeyErrors from calling remove_index.
 
1847
        """
 
1848
        for index_type in Pack.index_definitions.keys():
 
1849
            attr_name = index_type + '_index'
 
1850
            aggregate_index = getattr(self, attr_name)
 
1851
            if aggregate_index is not None:
 
1852
                pack_index = getattr(pack, attr_name)
 
1853
                try:
 
1854
                    aggregate_index.remove_index(pack_index)
 
1855
                except KeyError:
 
1856
                    if ignore_missing:
 
1857
                        continue
 
1858
                    raise
1851
1859
 
1852
1860
    def reset(self):
1853
1861
        """Clear all cached data."""
2091
2099
        # FIXME: just drop the transient index.
2092
2100
        # forget what names there are
2093
2101
        if self._new_pack is not None:
2094
 
            try:
2095
 
                self._new_pack.abort()
2096
 
            finally:
2097
 
                # XXX: If we aborted while in the middle of finishing the write
2098
 
                # group, _remove_pack_indices can fail because the indexes are
2099
 
                # already gone.  If they're not there we shouldn't fail in this
2100
 
                # case.  -- mbp 20081113
2101
 
                self._remove_pack_indices(self._new_pack)
2102
 
                self._new_pack = None
 
2102
            operation = cleanup.OperationWithCleanups(self._new_pack.abort)
 
2103
            operation.add_cleanup(setattr, self, '_new_pack', None)
 
2104
            # If we aborted while in the middle of finishing the write
 
2105
            # group, _remove_pack_indices could fail because the indexes are
 
2106
            # already gone.  But they're not there we shouldn't fail in this
 
2107
            # case, so we pass ignore_missing=True.
 
2108
            operation.add_cleanup(self._remove_pack_indices, self._new_pack,
 
2109
                ignore_missing=True)
 
2110
            operation.run_simple()
2103
2111
        for resumed_pack in self._resumed_packs:
2104
 
            try:
2105
 
                resumed_pack.abort()
2106
 
            finally:
2107
 
                # See comment in previous finally block.
2108
 
                try:
2109
 
                    self._remove_pack_indices(resumed_pack)
2110
 
                except KeyError:
2111
 
                    pass
 
2112
            operation = cleanup.OperationWithCleanups(resumed_pack.abort)
 
2113
            # See comment in previous finally block.
 
2114
            operation.add_cleanup(self._remove_pack_indices, resumed_pack,
 
2115
                ignore_missing=True)
 
2116
            operation.run_simple()
2112
2117
        del self._resumed_packs[:]
2113
2118
 
2114
2119
    def _remove_resumed_pack_indices(self):
2615
2620
    repository_class = KnitPackRepository
2616
2621
    _commit_builder_class = PackRootCommitBuilder
2617
2622
    rich_root_data = True
 
2623
    experimental = True
2618
2624
    supports_tree_reference = True
2619
2625
    @property
2620
2626
    def _serializer(self):
2888
2894
    repository_class = KnitPackRepository
2889
2895
    _commit_builder_class = PackRootCommitBuilder
2890
2896
    rich_root_data = True
 
2897
    experimental = True
2891
2898
    supports_tree_reference = True
2892
2899
    supports_external_lookups = True
2893
2900
    # What index classes to use