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