~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/pack_repo.py

Merge bzr.dev.

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,
28
27
    debug,
29
28
    graph,
30
29
    osutils,
647
646
        del self.combined_index._indices[:]
648
647
        self.add_callback = None
649
648
 
650
 
    def remove_index(self, index):
 
649
    def remove_index(self, index, pack):
651
650
        """Remove index from the indices used to answer queries.
652
651
 
653
652
        :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, 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
 
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)
1859
1851
 
1860
1852
    def reset(self):
1861
1853
        """Clear all cached data."""
2099
2091
        # FIXME: just drop the transient index.
2100
2092
        # forget what names there are
2101
2093
        if self._new_pack is not 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()
 
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
2111
2103
        for resumed_pack in self._resumed_packs:
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()
 
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
2117
2112
        del self._resumed_packs[:]
2118
2113
 
2119
2114
    def _remove_resumed_pack_indices(self):
2620
2615
    repository_class = KnitPackRepository
2621
2616
    _commit_builder_class = PackRootCommitBuilder
2622
2617
    rich_root_data = True
2623
 
    experimental = True
2624
2618
    supports_tree_reference = True
2625
2619
    @property
2626
2620
    def _serializer(self):
2894
2888
    repository_class = KnitPackRepository
2895
2889
    _commit_builder_class = PackRootCommitBuilder
2896
2890
    rich_root_data = True
2897
 
    experimental = True
2898
2891
    supports_tree_reference = True
2899
2892
    supports_external_lookups = True
2900
2893
    # What index classes to use