646
647
del self.combined_index._indices[:]
647
648
self.add_callback = None
649
def remove_index(self, index, pack):
650
def remove_index(self, index):
650
651
"""Remove index from the indices used to answer queries.
652
653
:param index: An index from the pack parameter.
653
:param pack: A Pack instance.
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)
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.
1846
:param ignore_missing: Suppress KeyErrors from calling remove_index.
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)
1854
aggregate_index.remove_index(pack_index)
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:
2095
self._new_pack.abort()
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:
2105
resumed_pack.abort()
2107
# See comment in previous finally block.
2109
self._remove_pack_indices(resumed_pack)
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[:]
2114
2119
def _remove_resumed_pack_indices(self):
2888
2894
repository_class = KnitPackRepository
2889
2895
_commit_builder_class = PackRootCommitBuilder
2890
2896
rich_root_data = True
2891
2898
supports_tree_reference = True
2892
2899
supports_external_lookups = True
2893
2900
# What index classes to use