53
48
from bzrlib.decorators import needs_read_lock, needs_write_lock
54
49
from bzrlib.repository import (
56
RepositoryFormatMetaDir,
51
MetaDirVersionedFileRepository,
52
MetaDirRepositoryFormat,
58
56
from bzrlib.store.text import TextStore
57
from bzrlib.tuned_gzip import GzipFile, bytes_to_gzip
59
58
from bzrlib.versionedfile import (
60
59
AbsentContentFactory,
61
60
FulltextContentFactory,
64
from bzrlib.vf_repository import (
65
InterSameDataRepository,
66
VersionedFileCommitBuilder,
67
VersionedFileRepository,
68
VersionedFileRepositoryFormat,
69
MetaDirVersionedFileRepository,
70
MetaDirVersionedFileRepositoryFormat,
73
from bzrlib.plugins.weave_fmt import bzrdir as weave_bzrdir
76
class AllInOneRepository(VersionedFileRepository):
65
class AllInOneRepository(Repository):
77
66
"""Legacy support - the repository behaviour for all-in-one branches."""
152
141
def get_commit_builder(self, branch, parents, config, timestamp=None,
153
142
timezone=None, committer=None, revprops=None,
154
revision_id=None, lossy=False):
155
144
self._check_ascii_revisionid(revision_id, self.get_commit_builder)
156
result = VersionedFileCommitBuilder(self, parents, config, timestamp,
157
timezone, committer, revprops, revision_id, lossy=lossy)
145
result = CommitBuilder(self, parents, config, timestamp, timezone,
146
committer, revprops, revision_id)
158
147
self.start_write_group()
241
235
def get_commit_builder(self, branch, parents, config, timestamp=None,
242
236
timezone=None, committer=None, revprops=None,
243
revision_id=None, lossy=False):
244
238
self._check_ascii_revisionid(revision_id, self.get_commit_builder)
245
result = VersionedFileCommitBuilder(self, parents, config, timestamp,
246
timezone, committer, revprops, revision_id, lossy=lossy)
239
result = CommitBuilder(self, parents, config, timestamp, timezone,
240
committer, revprops, revision_id)
247
241
self.start_write_group()
759
738
paths = list(relpaths)
760
739
return set([self._mapper.unmap(path) for path in paths])
763
class InterWeaveRepo(InterSameDataRepository):
764
"""Optimised code paths between Weave based repositories.
768
def _get_repo_format_to_test(self):
769
return RepositoryFormat7()
772
def is_compatible(source, target):
773
"""Be compatible with known Weave formats.
775
We don't test for the stores being of specific types because that
776
could lead to confusing results, and there is no need to be
780
return (isinstance(source._format, (RepositoryFormat5,
782
RepositoryFormat7)) and
783
isinstance(target._format, (RepositoryFormat5,
786
except AttributeError:
790
def copy_content(self, revision_id=None):
791
"""See InterRepository.copy_content()."""
792
# weave specific optimised path:
794
self.target.set_make_working_trees(self.source.make_working_trees())
795
except (errors.RepositoryUpgradeRequired, NotImplemented):
798
if self.source._transport.listable():
799
pb = ui.ui_factory.nested_progress_bar()
801
self.target.texts.insert_record_stream(
802
self.source.texts.get_record_stream(
803
self.source.texts.keys(), 'topological', False))
804
pb.update('Copying inventory', 0, 1)
805
self.target.inventories.insert_record_stream(
806
self.source.inventories.get_record_stream(
807
self.source.inventories.keys(), 'topological', False))
808
self.target.signatures.insert_record_stream(
809
self.source.signatures.get_record_stream(
810
self.source.signatures.keys(),
812
self.target.revisions.insert_record_stream(
813
self.source.revisions.get_record_stream(
814
self.source.revisions.keys(),
815
'topological', True))
819
self.target.fetch(self.source, revision_id=revision_id)
822
def search_missing_revision_ids(self,
823
revision_id=symbol_versioning.DEPRECATED_PARAMETER,
824
find_ghosts=True, revision_ids=None, if_present_ids=None,
826
"""See InterRepository.search_missing_revision_ids()."""
827
# we want all revisions to satisfy revision_id in source.
828
# but we don't want to stat every file here and there.
829
# we want then, all revisions other needs to satisfy revision_id
830
# checked, but not those that we have locally.
831
# so the first thing is to get a subset of the revisions to
832
# satisfy revision_id in source, and then eliminate those that
833
# we do already have.
834
# this is slow on high latency connection to self, but as this
835
# disk format scales terribly for push anyway due to rewriting
836
# inventory.weave, this is considered acceptable.
838
if symbol_versioning.deprecated_passed(revision_id):
839
symbol_versioning.warn(
840
'search_missing_revision_ids(revision_id=...) was '
841
'deprecated in 2.4. Use revision_ids=[...] instead.',
842
DeprecationWarning, stacklevel=2)
843
if revision_ids is not None:
844
raise AssertionError(
845
'revision_ids is mutually exclusive with revision_id')
846
if revision_id is not None:
847
revision_ids = [revision_id]
849
source_ids_set = self._present_source_revisions_for(
850
revision_ids, if_present_ids)
851
# source_ids is the worst possible case we may need to pull.
852
# now we want to filter source_ids against what we actually
853
# have in target, but don't try to check for existence where we know
854
# we do not have a revision as that would be pointless.
855
target_ids = set(self.target._all_possible_ids())
856
possibly_present_revisions = target_ids.intersection(source_ids_set)
857
actually_present_revisions = set(
858
self.target._eliminate_revisions_not_present(possibly_present_revisions))
859
required_revisions = source_ids_set.difference(actually_present_revisions)
860
if revision_ids is not None:
861
# we used get_ancestry to determine source_ids then we are assured all
862
# revisions referenced are present as they are installed in topological order.
863
# and the tip revision was validated by get_ancestry.
864
result_set = required_revisions
866
# if we just grabbed the possibly available ids, then
867
# we only have an estimate of whats available and need to validate
868
# that against the revision records.
870
self.source._eliminate_revisions_not_present(required_revisions))
871
if limit is not None:
872
topo_ordered = self.get_graph().iter_topo_order(result_set)
873
result_set = set(itertools.islice(topo_ordered, limit))
874
return self.source.revision_ids_to_search_result(result_set)
877
InterRepository.register_optimiser(InterWeaveRepo)
880
def get_extra_interrepo_test_combinations():
881
from bzrlib.repofmt import knitrepo
882
return [(InterRepository, RepositoryFormat5(),
883
knitrepo.RepositoryFormatKnit3())]
741
_legacy_formats = [RepositoryFormat4(),