439
439
# not present in one of those inventories is unnecessary but not
440
440
# harmful because we are filtering by the revision id marker in the
441
441
# inventory lines : we only select file ids altered in one of those
442
unescape_revid_cache = {}
443
unescape_fileid_cache = {}
445
442
# revisions. We don't need to see all lines in the inventory because
446
443
# only those added in an inventory in rev X can contain a revision=X
445
unescape_revid_cache = {}
446
unescape_fileid_cache = {}
448
# jam 20061218 In a big fetch, this handles hundreds of thousands
449
# of lines, so it has had a lot of inlining and optimizing done.
450
# Sorry that it is a little bit messy.
451
# Move several functions to be local variables, since this is a long
453
search = self._file_ids_altered_regex.search
454
unescape = _unescape_xml
455
setdefault = result.setdefault
448
456
pb = ui.ui_factory.nested_progress_bar()
450
458
for line in w.iter_lines_added_or_present_in_versions(
451
selected_revision_ids, pb=pb):
452
match = self._file_ids_altered_regex.search(line)
459
selected_revision_ids, pb=pb):
453
461
if match is None:
463
# One call to match.group() returning multiple items is quite a
464
# bit faster than 2 calls to match.group() each returning 1
455
465
file_id, revision_id = match.group('file_id', 'revision_id')
456
revision_id = _unescape_xml_cached(revision_id,
457
unescape_revid_cache)
467
# Inlining the cache lookups helps a lot when you make 170,000
468
# lines and 350k ids, versus 8.4 unique ids.
469
# Using a cache helps in 2 ways:
470
# 1) Avoids unnecessary decoding calls
471
# 2) Re-uses cached strings, which helps in future set and
473
# (2) is enough that removing encoding entirely along with
474
# the cache (so we are using plain strings) results in no
475
# performance improvement.
477
revision_id = unescape_revid_cache[revision_id]
479
unescaped = unescape(revision_id)
480
unescape_revid_cache[revision_id] = unescaped
481
revision_id = unescaped
458
483
if revision_id in selected_revision_ids:
459
file_id = _unescape_xml_cached(file_id,
460
unescape_fileid_cache)
461
result.setdefault(file_id, set()).add(revision_id)
485
file_id = unescape_fileid_cache[file_id]
487
unescaped = unescape(file_id)
488
unescape_fileid_cache[file_id] = unescaped
490
setdefault(file_id, set()).add(revision_id)
1249
1278
klass._formats[format.get_format_string()] = format
1281
@deprecated_method(symbol_versioning.zero_fourteen)
1252
1282
def set_default_format(klass, format):
1283
klass._set_default_format(format)
1286
def _set_default_format(klass, format):
1253
1287
klass._default_format = format
1771
1805
# formats which have no format string are not discoverable
1772
1806
# and not independently creatable, so are not registered.
1773
1807
RepositoryFormat.register_format(RepositoryFormat7())
1808
# KEEP in sync with bzrdir.format_registry default
1774
1809
_default_format = RepositoryFormatKnit1()
1775
1810
RepositoryFormat.register_format(_default_format)
1776
1811
RepositoryFormat.register_format(RepositoryFormatKnit2())
1777
RepositoryFormat.set_default_format(_default_format)
1812
RepositoryFormat._set_default_format(_default_format)
1778
1813
_legacy_formats = [RepositoryFormat4(),
1779
1814
RepositoryFormat5(),
1780
1815
RepositoryFormat6()]