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