225
222
return self.index_name('text', name)
227
224
def _replace_index_with_readonly(self, index_type):
228
unlimited_cache = False
229
if index_type == 'chk':
230
unlimited_cache = True
231
225
setattr(self, index_type + '_index',
232
226
self.index_class(self.index_transport,
233
227
self.index_name(index_type, self.name),
234
self.index_sizes[self.index_offset(index_type)],
235
unlimited_cache=unlimited_cache))
228
self.index_sizes[self.index_offset(index_type)]))
238
231
class ExistingPack(Pack):
239
232
"""An in memory proxy for an existing .pack and its disk indices."""
241
234
def __init__(self, pack_transport, name, revision_index, inventory_index,
242
text_index, signature_index, chk_index=None):
235
text_index, signature_index):
243
236
"""Create an ExistingPack object.
245
238
:param pack_transport: The transport where the pack file resides.
246
239
:param name: The name of the pack on disk in the pack_transport.
248
241
Pack.__init__(self, revision_index, inventory_index, text_index,
249
signature_index, chk_index)
251
244
self.pack_transport = pack_transport
252
245
if None in (revision_index, inventory_index, text_index,
270
263
def __init__(self, name, revision_index, inventory_index, text_index,
271
264
signature_index, upload_transport, pack_transport, index_transport,
272
pack_collection, chk_index=None):
273
266
"""Create a ResumedPack object."""
274
267
ExistingPack.__init__(self, pack_transport, name, revision_index,
275
inventory_index, text_index, signature_index,
268
inventory_index, text_index, signature_index)
277
269
self.upload_transport = upload_transport
278
270
self.index_transport = index_transport
279
271
self.index_sizes = [None, None, None, None]
306
295
self.upload_transport.delete(self.file_name())
307
296
indices = [self.revision_index, self.inventory_index, self.text_index,
308
297
self.signature_index]
309
if self.chk_index is not None:
310
indices.append(self.chk_index)
311
298
for index in indices:
312
299
index._transport.delete(index._name)
314
301
def finish(self):
315
302
self._check_references()
316
index_types = ['revision', 'inventory', 'text', 'signature']
317
if self.chk_index is not None:
318
index_types.append('chk')
319
for index_type in index_types:
303
new_name = '../packs/' + self.file_name()
304
self.upload_transport.rename(self.file_name(), new_name)
305
for index_type in ['revision', 'inventory', 'text', 'signature']:
320
306
old_name = self.index_name(index_type, self.name)
321
307
new_name = '../indices/' + old_name
322
308
self.upload_transport.rename(old_name, new_name)
323
309
self._replace_index_with_readonly(index_type)
324
new_name = '../packs/' + self.file_name()
325
self.upload_transport.rename(self.file_name(), new_name)
326
310
self._state = 'finished'
328
312
def _get_external_refs(self, index):
329
"""Return compression parents for this index that are not present.
331
This returns any compression parents that are referenced by this index,
332
which are not contained *in* this index. They may be present elsewhere.
334
313
return index.external_references(1)
766
726
def open_pack(self):
767
727
"""Open a pack for the pack we are creating."""
768
new_pack = self._pack_collection.pack_factory(self._pack_collection,
769
upload_suffix=self.suffix,
728
return NewPack(self._pack_collection, upload_suffix=self.suffix,
770
729
file_mode=self._pack_collection.repo.bzrdir._get_file_mode())
771
# We know that we will process all nodes in order, and don't need to
772
# query, so don't combine any indices spilled to disk until we are done
773
new_pack.revision_index.set_optimize(combine_backing_indices=False)
774
new_pack.inventory_index.set_optimize(combine_backing_indices=False)
775
new_pack.text_index.set_optimize(combine_backing_indices=False)
776
new_pack.signature_index.set_optimize(combine_backing_indices=False)
779
731
def _update_pack_order(self, entries, index_to_pack_map):
780
732
"""Determine how we want our packs to be ordered.
937
888
time.ctime(), self._pack_collection._upload_transport.base, new_pack.random_name,
938
889
new_pack.signature_index.key_count(),
939
890
time.time() - new_pack.start_time)
941
# NB XXX: how to check CHK references are present? perhaps by yielding
942
# the items? How should that interact with stacked repos?
943
if new_pack.chk_index is not None:
945
if 'pack' in debug.debug_flags:
946
mutter('%s: create_pack: chk content copied: %s%s %d items t+%6.3fs',
947
time.ctime(), self._pack_collection._upload_transport.base,
948
new_pack.random_name,
949
new_pack.chk_index.key_count(),
950
time.time() - new_pack.start_time)
951
891
new_pack._check_references()
952
892
if not self._use_pack(new_pack):
957
897
self._pack_collection.allocate(new_pack)
960
def _copy_chks(self, refs=None):
961
# XXX: Todo, recursive follow-pointers facility when fetching some
963
chk_index_map, chk_indices = self._pack_map_and_index_list(
965
chk_nodes = self._index_contents(chk_indices, refs)
967
# TODO: This isn't strictly tasteful as we are accessing some private
968
# variables (_serializer). Perhaps a better way would be to have
969
# Repository._deserialise_chk_node()
970
search_key_func = chk_map.search_key_registry.get(
971
self._pack_collection.repo._serializer.search_key_name)
972
def accumlate_refs(lines):
973
# XXX: move to a generic location
975
bytes = ''.join(lines)
976
node = chk_map._deserialise(bytes, ("unknown",), search_key_func)
977
new_refs.update(node.refs())
978
self._copy_nodes(chk_nodes, chk_index_map, self.new_pack._writer,
979
self.new_pack.chk_index, output_lines=accumlate_refs)
982
def _copy_nodes(self, nodes, index_map, writer, write_index,
984
"""Copy knit nodes between packs with no graph references.
986
:param output_lines: Output full texts of copied items.
900
def _copy_nodes(self, nodes, index_map, writer, write_index):
901
"""Copy knit nodes between packs with no graph references."""
988
902
pb = ui.ui_factory.nested_progress_bar()
990
904
return self._do_copy_nodes(nodes, index_map, writer,
991
write_index, pb, output_lines=output_lines)
995
def _do_copy_nodes(self, nodes, index_map, writer, write_index, pb,
909
def _do_copy_nodes(self, nodes, index_map, writer, write_index, pb):
997
910
# for record verification
998
911
knit = KnitVersionedFiles(None, None)
999
912
# plan a readv on each source pack:
1399
1303
self._pack_transport = pack_transport
1400
1304
self._index_builder_class = index_builder_class
1401
1305
self._index_class = index_class
1402
self._suffix_offsets = {'.rix': 0, '.iix': 1, '.tix': 2, '.six': 3,
1306
self._suffix_offsets = {'.rix': 0, '.iix': 1, '.tix': 2, '.six': 3}
1404
1307
self.packs = []
1405
1308
# name:Pack mapping
1407
1309
self._packs_by_name = {}
1408
1310
# the previous pack-names content
1409
1311
self._packs_at_load = None
1410
1312
# when a pack is being created by this object, the state of that pack.
1411
1313
self._new_pack = None
1412
1314
# aggregated revision index data
1413
flush = self._flush_new_pack
1414
self.revision_index = AggregateIndex(self.reload_pack_names, flush)
1415
self.inventory_index = AggregateIndex(self.reload_pack_names, flush)
1416
self.text_index = AggregateIndex(self.reload_pack_names, flush)
1417
self.signature_index = AggregateIndex(self.reload_pack_names, flush)
1419
self.chk_index = AggregateIndex(self.reload_pack_names, flush)
1421
# used to determine if we're using a chk_index elsewhere.
1422
self.chk_index = None
1315
self.revision_index = AggregateIndex(self.reload_pack_names)
1316
self.inventory_index = AggregateIndex(self.reload_pack_names)
1317
self.text_index = AggregateIndex(self.reload_pack_names)
1318
self.signature_index = AggregateIndex(self.reload_pack_names)
1423
1319
# resumed packs
1424
1320
self._resumed_packs = []
1427
return '%s(%r)' % (self.__class__.__name__, self.repo)
1429
1322
def add_pack_to_memory(self, pack):
1430
1323
"""Make a Pack object available to the repository to satisfy queries.
1565
1451
self.repo.control_files.lock_write()
1567
def _already_packed(self):
1568
"""Is the collection already packed?"""
1569
return not (self.repo._format.pack_compresses or (len(self._names) > 1))
1571
def pack(self, hint=None):
1572
1454
"""Pack the pack collection totally."""
1573
1455
self.ensure_loaded()
1574
1456
total_packs = len(self._names)
1575
if self._already_packed():
1458
# This is arguably wrong because we might not be optimal, but for
1459
# now lets leave it in. (e.g. reconcile -> one pack. But not
1577
1462
total_revisions = self.revision_index.combined_index.key_count()
1578
1463
# XXX: the following may want to be a class, to pack with a given
1580
1465
mutter('Packing repository %s, which has %d pack files, '
1581
'containing %d revisions with hint %r.', self, total_packs,
1582
total_revisions, hint)
1466
'containing %d revisions into 1 packs.', self, total_packs,
1583
1468
# determine which packs need changing
1469
pack_distribution = [1]
1584
1470
pack_operations = [[0, []]]
1585
1471
for pack in self.all_packs():
1586
if hint is None or pack.name in hint:
1587
# Either no hint was provided (so we are packing everything),
1588
# or this pack was included in the hint.
1589
pack_operations[-1][0] += pack.get_revision_count()
1590
pack_operations[-1][1].append(pack)
1472
pack_operations[-1][0] += pack.get_revision_count()
1473
pack_operations[-1][1].append(pack)
1591
1474
self._execute_pack_operations(pack_operations, OptimisingPacker)
1593
1476
def plan_autopack_combinations(self, existing_packs, pack_distribution):
1707
1578
inv_index = self._make_index(name, '.iix', resume=True)
1708
1579
txt_index = self._make_index(name, '.tix', resume=True)
1709
1580
sig_index = self._make_index(name, '.six', resume=True)
1710
if self.chk_index is not None:
1711
chk_index = self._make_index(name, '.cix', resume=True,
1712
unlimited_cache=True)
1715
result = self.resumed_pack_factory(name, rev_index, inv_index,
1716
txt_index, sig_index, self._upload_transport,
1717
self._pack_transport, self._index_transport, self,
1718
chk_index=chk_index)
1581
result = ResumedPack(name, rev_index, inv_index, txt_index,
1582
sig_index, self._upload_transport, self._pack_transport,
1583
self._index_transport, self)
1719
1584
except errors.NoSuchFile, e:
1720
1585
raise errors.UnresumableWriteGroup(self.repo, [name], str(e))
1721
1586
self.add_pack_to_memory(result)
1789
1653
:param return: None.
1791
1655
for pack in packs:
1793
pack.pack_transport.rename(pack.file_name(),
1794
'../obsolete_packs/' + pack.file_name())
1795
except (errors.PathError, errors.TransportError), e:
1796
# TODO: Should these be warnings or mutters?
1797
mutter("couldn't rename obsolete pack, skipping it:\n%s"
1656
pack.pack_transport.rename(pack.file_name(),
1657
'../obsolete_packs/' + pack.file_name())
1799
1658
# TODO: Probably needs to know all possible indices for this pack
1800
1659
# - or maybe list the directory and move all indices matching this
1801
1660
# name whether we recognize it or not?
1802
suffixes = ['.iix', '.six', '.tix', '.rix']
1803
if self.chk_index is not None:
1804
suffixes.append('.cix')
1805
for suffix in suffixes:
1807
self._index_transport.rename(pack.name + suffix,
1808
'../obsolete_packs/' + pack.name + suffix)
1809
except (errors.PathError, errors.TransportError), e:
1810
mutter("couldn't rename obsolete index, skipping it:\n%s"
1661
for suffix in ('.iix', '.six', '.tix', '.rix'):
1662
self._index_transport.rename(pack.name + suffix,
1663
'../obsolete_packs/' + pack.name + suffix)
1813
1665
def pack_distribution(self, total_revisions):
1814
1666
"""Generate a list of the number of revisions to put in each pack.
1978
1822
builder.add_node(key, value)
1979
1823
self.transport.put_file('pack-names', builder.finish(),
1980
1824
mode=self.repo.bzrdir._get_file_mode())
1825
# move the baseline forward
1981
1826
self._packs_at_load = disk_nodes
1982
1827
if clear_obsolete_packs:
1985
to_preserve = set([o.name for o in obsolete_packs])
1986
already_obsolete = self._clear_obsolete_packs(to_preserve)
1828
self._clear_obsolete_packs()
1988
1830
self._unlock_names()
1989
1831
# synchronise the memory packs list with what we just wrote:
1990
1832
self._syncronize_pack_names_from_disk_nodes(disk_nodes)
1992
# TODO: We could add one more condition here. "if o.name not in
1993
# orig_disk_nodes and o != the new_pack we haven't written to
1994
# disk yet. However, the new pack object is not easily
1995
# accessible here (it would have to be passed through the
1996
# autopacking code, etc.)
1997
obsolete_packs = [o for o in obsolete_packs
1998
if o.name not in already_obsolete]
1999
self._obsolete_packs(obsolete_packs)
2000
return [new_node[0][0] for new_node in new_nodes]
2002
1834
def reload_pack_names(self):
2003
1835
"""Sync our pack listing with what is present in the repository.
2005
1837
This should be called when we find out that something we thought was
2006
1838
present is now missing. This happens when another process re-packs the
2007
1839
repository, etc.
2009
:return: True if the in-memory list of packs has been altered at all.
2011
# The ensure_loaded call is to handle the case where the first call
2012
# made involving the collection was to reload_pack_names, where we
2013
# don't have a view of disk contents. Its a bit of a bandaid, and
2014
# causes two reads of pack-names, but its a rare corner case not struck
2015
# with regular push/pull etc.
2016
first_read = self.ensure_loaded()
1841
# This is functionally similar to _save_pack_names, but we don't write
2019
1842
# out the new value.
2020
(disk_nodes, deleted_nodes, new_nodes,
2021
orig_disk_nodes) = self._diff_pack_names()
2022
# _packs_at_load is meant to be the explicit list of names in
2023
# 'pack-names' at then start. As such, it should not contain any
2024
# pending names that haven't been written out yet.
2025
self._packs_at_load = orig_disk_nodes
1843
disk_nodes, _, _ = self._diff_pack_names()
1844
self._packs_at_load = disk_nodes
2026
1845
(removed, added,
2027
1846
modified) = self._syncronize_pack_names_from_disk_nodes(disk_nodes)
2028
1847
if removed or added or modified:
2038
1857
raise errors.RetryAutopack(self.repo, False, sys.exc_info())
2040
def _clear_obsolete_packs(self, preserve=None):
1859
def _clear_obsolete_packs(self):
2041
1860
"""Delete everything from the obsolete-packs directory.
2043
:return: A list of pack identifiers (the filename without '.pack') that
2044
were found in obsolete_packs.
2047
1862
obsolete_pack_transport = self.transport.clone('obsolete_packs')
2048
if preserve is None:
2050
1863
for filename in obsolete_pack_transport.list_dir('.'):
2051
name, ext = osutils.splitext(filename)
2054
if name in preserve:
2057
1865
obsolete_pack_transport.delete(filename)
2058
1866
except (errors.PathError, errors.TransportError), e:
2059
warning("couldn't delete obsolete pack, skipping it:\n%s"
1867
warning("couldn't delete obsolete pack, skipping it:\n%s" % (e,))
2063
1869
def _start_write_group(self):
2064
1870
# Do not permit preparation for writing if we're not in a 'write lock'.
2065
1871
if not self.repo.is_write_locked():
2066
1872
raise errors.NotWriteLocked(self)
2067
self._new_pack = self.pack_factory(self, upload_suffix='.pack',
1873
self._new_pack = NewPack(self, upload_suffix='.pack',
2068
1874
file_mode=self.repo.bzrdir._get_file_mode())
2069
1875
# allow writing: queue writes to a new index
2070
1876
self.revision_index.add_writable_index(self._new_pack.revision_index,
2256
2038
deltas=True, parents=True, is_locked=self.is_locked),
2257
2039
data_access=self._pack_collection.text_index.data_access,
2258
2040
max_delta_chain=200)
2259
if _format.supports_chks:
2260
# No graph, no compression:- references from chks are between
2261
# different objects not temporal versions of the same; and without
2262
# some sort of temporal structure knit compression will just fail.
2263
self.chk_bytes = KnitVersionedFiles(
2264
_KnitGraphIndex(self._pack_collection.chk_index.combined_index,
2265
add_callback=self._pack_collection.chk_index.add_callback,
2266
deltas=False, parents=False, is_locked=self.is_locked),
2267
data_access=self._pack_collection.chk_index.data_access,
2270
self.chk_bytes = None
2271
2041
# True when the repository object is 'write locked' (as opposed to the
2272
2042
# physical lock only taken out around changes to the pack-names list.)
2273
2043
# Another way to represent this would be a decorator around the control
2280
2050
self._reconcile_fixes_text_parents = True
2281
2051
self._reconcile_backsup_inventory = False
2283
def _warn_if_deprecated(self, branch=None):
2053
def _warn_if_deprecated(self):
2284
2054
# This class isn't deprecated, but one sub-format is
2285
2055
if isinstance(self._format, RepositoryFormatKnitPack5RichRootBroken):
2286
super(KnitPackRepository, self)._warn_if_deprecated(branch)
2056
from bzrlib import repository
2057
if repository._deprecation_warning_done:
2059
repository._deprecation_warning_done = True
2060
warning("Format %s for %s is deprecated - please use"
2061
" 'bzr upgrade --1.6.1-rich-root'"
2062
% (self._format, self.bzrdir.transport.base))
2288
2064
def _abort_write_group(self):
2289
self.revisions._index._key_dependencies.clear()
2290
2065
self._pack_collection._abort_write_group()
2292
def _get_source(self, to_format):
2293
if to_format.network_name() == self._format.network_name():
2294
return KnitPackStreamSource(self, to_format)
2295
return super(KnitPackRepository, self)._get_source(to_format)
2067
def _find_inconsistent_revision_parents(self):
2068
"""Find revisions with incorrectly cached parents.
2070
:returns: an iterator yielding tuples of (revison-id, parents-in-index,
2071
parents-in-revision).
2073
if not self.is_locked():
2074
raise errors.ObjectNotLocked(self)
2075
pb = ui.ui_factory.nested_progress_bar()
2078
revision_nodes = self._pack_collection.revision_index \
2079
.combined_index.iter_all_entries()
2080
index_positions = []
2081
# Get the cached index values for all revisions, and also the location
2082
# in each index of the revision text so we can perform linear IO.
2083
for index, key, value, refs in revision_nodes:
2084
pos, length = value[1:].split(' ')
2085
index_positions.append((index, int(pos), key[0],
2086
tuple(parent[0] for parent in refs[0])))
2087
pb.update("Reading revision index.", 0, 0)
2088
index_positions.sort()
2089
batch_count = len(index_positions) / 1000 + 1
2090
pb.update("Checking cached revision graph.", 0, batch_count)
2091
for offset in xrange(batch_count):
2092
pb.update("Checking cached revision graph.", offset)
2093
to_query = index_positions[offset * 1000:(offset + 1) * 1000]
2096
rev_ids = [item[2] for item in to_query]
2097
revs = self.get_revisions(rev_ids)
2098
for revision, item in zip(revs, to_query):
2099
index_parents = item[3]
2100
rev_parents = tuple(revision.parent_ids)
2101
if index_parents != rev_parents:
2102
result.append((revision.revision_id, index_parents, rev_parents))
2107
@symbol_versioning.deprecated_method(symbol_versioning.one_one)
2108
def get_parents(self, revision_ids):
2109
"""See graph._StackedParentsProvider.get_parents."""
2110
parent_map = self.get_parent_map(revision_ids)
2111
return [parent_map.get(r, None) for r in revision_ids]
2297
2113
def _make_parents_provider(self):
2298
2114
return graph.CachingParentsProvider(self)
2300
2116
def _refresh_data(self):
2301
if not self.is_locked():
2303
self._pack_collection.reload_pack_names()
2117
if self._write_lock_count == 1 or (
2118
self.control_files._lock_count == 1 and
2119
self.control_files._lock_mode == 'r'):
2120
# forget what names there are
2121
self._pack_collection.reset()
2122
# XXX: Better to do an in-memory merge when acquiring a new lock -
2123
# factor out code from _save_pack_names.
2124
self._pack_collection.ensure_loaded()
2305
2126
def _start_write_group(self):
2306
2127
self._pack_collection._start_write_group()
2308
2129
def _commit_write_group(self):
2309
hint = self._pack_collection._commit_write_group()
2310
self.revisions._index._key_dependencies.clear()
2130
return self._pack_collection._commit_write_group()
2313
2132
def suspend_write_group(self):
2314
2133
# XXX check self._write_group is self.get_transaction()?
2315
2134
tokens = self._pack_collection._suspend_write_group()
2316
self.revisions._index._key_dependencies.clear()
2317
2135
self._write_group = None
2320
2138
def _resume_write_group(self, tokens):
2321
2139
self._start_write_group()
2323
self._pack_collection._resume_write_group(tokens)
2324
except errors.UnresumableWriteGroup:
2325
self._abort_write_group()
2327
for pack in self._pack_collection._resumed_packs:
2328
self.revisions._index.scan_unvalidated_index(pack.revision_index)
2140
self._pack_collection._resume_write_group(tokens)
2330
2142
def get_transaction(self):
2331
2143
if self._write_lock_count:
2340
2152
return self._write_lock_count
2342
2154
def lock_write(self, token=None):
2343
locked = self.is_locked()
2344
if not self._write_lock_count and locked:
2155
if not self._write_lock_count and self.is_locked():
2345
2156
raise errors.ReadOnlyError(self)
2346
2157
self._write_lock_count += 1
2347
2158
if self._write_lock_count == 1:
2348
2159
self._transaction = transactions.WriteTransaction()
2350
if 'relock' in debug.debug_flags and self._prev_lock == 'w':
2351
note('%r was write locked again', self)
2352
self._prev_lock = 'w'
2353
2160
for repo in self._fallback_repositories:
2354
2161
# Writes don't affect fallback repos
2355
2162
repo.lock_read()
2356
self._refresh_data()
2163
self._refresh_data()
2358
2165
def lock_read(self):
2359
locked = self.is_locked()
2360
2166
if self._write_lock_count:
2361
2167
self._write_lock_count += 1
2363
2169
self.control_files.lock_read()
2365
if 'relock' in debug.debug_flags and self._prev_lock == 'r':
2366
note('%r was read locked again', self)
2367
self._prev_lock = 'r'
2368
2170
for repo in self._fallback_repositories:
2171
# Writes don't affect fallback repos
2369
2172
repo.lock_read()
2370
self._refresh_data()
2173
self._refresh_data()
2372
2175
def leave_lock_in_place(self):
2373
2176
# not supported - raise an error
2413
2211
transaction = self._transaction
2414
2212
self._transaction = None
2415
2213
transaction.finish()
2214
for repo in self._fallback_repositories:
2417
2217
self.control_files.unlock()
2419
if not self.is_locked():
2420
2218
for repo in self._fallback_repositories:
2424
class KnitPackStreamSource(StreamSource):
2425
"""A StreamSource used to transfer data between same-format KnitPack repos.
2427
This source assumes:
2428
1) Same serialization format for all objects
2429
2) Same root information
2430
3) XML format inventories
2431
4) Atomic inserts (so we can stream inventory texts before text
2436
def __init__(self, from_repository, to_format):
2437
super(KnitPackStreamSource, self).__init__(from_repository, to_format)
2438
self._text_keys = None
2439
self._text_fetch_order = 'unordered'
2441
def _get_filtered_inv_stream(self, revision_ids):
2442
from_repo = self.from_repository
2443
parent_ids = from_repo._find_parent_ids_of_revisions(revision_ids)
2444
parent_keys = [(p,) for p in parent_ids]
2445
find_text_keys = from_repo._find_text_key_references_from_xml_inventory_lines
2446
parent_text_keys = set(find_text_keys(
2447
from_repo._inventory_xml_lines_for_keys(parent_keys)))
2448
content_text_keys = set()
2449
knit = KnitVersionedFiles(None, None)
2450
factory = KnitPlainFactory()
2451
def find_text_keys_from_content(record):
2452
if record.storage_kind not in ('knit-delta-gz', 'knit-ft-gz'):
2453
raise ValueError("Unknown content storage kind for"
2454
" inventory text: %s" % (record.storage_kind,))
2455
# It's a knit record, it has a _raw_record field (even if it was
2456
# reconstituted from a network stream).
2457
raw_data = record._raw_record
2458
# read the entire thing
2459
revision_id = record.key[-1]
2460
content, _ = knit._parse_record(revision_id, raw_data)
2461
if record.storage_kind == 'knit-delta-gz':
2462
line_iterator = factory.get_linedelta_content(content)
2463
elif record.storage_kind == 'knit-ft-gz':
2464
line_iterator = factory.get_fulltext_content(content)
2465
content_text_keys.update(find_text_keys(
2466
[(line, revision_id) for line in line_iterator]))
2467
revision_keys = [(r,) for r in revision_ids]
2468
def _filtered_inv_stream():
2469
source_vf = from_repo.inventories
2470
stream = source_vf.get_record_stream(revision_keys,
2472
for record in stream:
2473
if record.storage_kind == 'absent':
2474
raise errors.NoSuchRevision(from_repo, record.key)
2475
find_text_keys_from_content(record)
2477
self._text_keys = content_text_keys - parent_text_keys
2478
return ('inventories', _filtered_inv_stream())
2480
def _get_text_stream(self):
2481
# Note: We know we don't have to handle adding root keys, because both
2482
# the source and target are the identical network name.
2483
text_stream = self.from_repository.texts.get_record_stream(
2484
self._text_keys, self._text_fetch_order, False)
2485
return ('texts', text_stream)
2487
def get_stream(self, search):
2488
revision_ids = search.get_keys()
2489
for stream_info in self._fetch_revision_texts(revision_ids):
2491
self._revision_keys = [(rev_id,) for rev_id in revision_ids]
2492
yield self._get_filtered_inv_stream(revision_ids)
2493
yield self._get_text_stream()
2497
2222
class RepositoryFormatPack(MetaDirRepositoryFormat):
2498
2223
"""Format logic for pack structured repositories.
2874
2631
return "Packs 6 rich-root (uses btree indexes, requires bzr 1.9)"
2634
class RepositoryFormatPackDevelopment2(RepositoryFormatPack):
2635
"""A no-subtrees development repository.
2637
This format should be retained until the second release after bzr 1.7.
2639
This is pack-1.6.1 with B+Tree indices.
2642
repository_class = KnitPackRepository
2643
_commit_builder_class = PackCommitBuilder
2644
supports_external_lookups = True
2645
# What index classes to use
2646
index_builder_class = BTreeBuilder
2647
index_class = BTreeGraphIndex
2650
def _serializer(self):
2651
return xml5.serializer_v5
2653
def _get_matching_bzrdir(self):
2654
return bzrdir.format_registry.make_bzrdir('development2')
2656
def _ignore_setting_bzrdir(self, format):
2659
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2661
def get_format_string(self):
2662
"""See RepositoryFormat.get_format_string()."""
2663
return "Bazaar development format 2 (needs bzr.dev from before 1.8)\n"
2665
def get_format_description(self):
2666
"""See RepositoryFormat.get_format_description()."""
2667
return ("Development repository format, currently the same as "
2668
"1.6.1 with B+Trees.\n")
2670
def check_conversion_target(self, target_format):
2877
2674
class RepositoryFormatPackDevelopment2Subtree(RepositoryFormatPack):
2878
2675
"""A subtrees development repository.
2880
2677
This format should be retained until the second release after bzr 1.7.
2882
2679
1.6.1-subtree[as it might have been] with B+Tree indices.
2884
This is [now] retained until we have a CHK based subtree format in
2888
2682
repository_class = KnitPackRepository
2901
2695
def _get_matching_bzrdir(self):
2902
2696
return bzrdir.format_registry.make_bzrdir(
2903
'development-subtree')
2697
'development2-subtree')
2905
2699
def _ignore_setting_bzrdir(self, format):
2908
2702
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2704
def check_conversion_target(self, target_format):
2705
if not target_format.rich_root_data:
2706
raise errors.BadConversionTarget(
2707
'Does not support rich root data.', target_format)
2708
if not getattr(target_format, 'supports_tree_reference', False):
2709
raise errors.BadConversionTarget(
2710
'Does not support nested trees', target_format)
2910
2712
def get_format_string(self):
2911
2713
"""See RepositoryFormat.get_format_string()."""
2912
2714
return ("Bazaar development format 2 with subtree support "