Rev 5548: (spiv) Move InterKnitRepo and InterWeaveRepo out of bzrlib/repository.py in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Mon Nov 22 22:27:59 GMT 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5548 [merge]
revision-id: pqm at pqm.ubuntu.com-20101122222758-wr1j89eb778ypclt
parent: pqm at pqm.ubuntu.com-20101122215424-tfww6o1rayiyq1m7
parent: jelmer at samba.org-20101120214105-4g88c3i133alubkb
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2010-11-22 22:27:58 +0000
message:
(spiv) Move InterKnitRepo and InterWeaveRepo out of bzrlib/repository.py
(Jelmer Vernooij)
modified:
bzrlib/repofmt/knitrepo.py knitrepo.py-20070206081537-pyy4a00xdas0j4pf-1
bzrlib/repofmt/weaverepo.py presplitout.py-20070125045333-wfav3tsh73oxu3zk-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
=== modified file 'bzrlib/repofmt/knitrepo.py'
--- a/bzrlib/repofmt/knitrepo.py 2010-08-25 10:20:41 +0000
+++ b/bzrlib/repofmt/knitrepo.py 2010-11-20 21:41:05 +0000
@@ -32,12 +32,11 @@
xml7,
)
""")
-from bzrlib import (
- symbol_versioning,
- )
from bzrlib.decorators import needs_read_lock, needs_write_lock
from bzrlib.repository import (
CommitBuilder,
+ InterRepository,
+ InterSameDataRepository,
IsInWriteGroupError,
MetaDirRepository,
MetaDirRepositoryFormat,
@@ -510,3 +509,62 @@
def get_format_description(self):
"""See RepositoryFormat.get_format_description()."""
return "Knit repository format 4"
+
+
+class InterKnitRepo(InterSameDataRepository):
+ """Optimised code paths between Knit based repositories."""
+
+ @classmethod
+ def _get_repo_format_to_test(self):
+ return RepositoryFormatKnit1()
+
+ @staticmethod
+ def is_compatible(source, target):
+ """Be compatible with known Knit formats.
+
+ We don't test for the stores being of specific types because that
+ could lead to confusing results, and there is no need to be
+ overly general.
+ """
+ try:
+ are_knits = (isinstance(source._format, RepositoryFormatKnit) and
+ isinstance(target._format, RepositoryFormatKnit))
+ except AttributeError:
+ return False
+ return are_knits and InterRepository._same_model(source, target)
+
+ @needs_read_lock
+ def search_missing_revision_ids(self, revision_id=None, find_ghosts=True):
+ """See InterRepository.missing_revision_ids()."""
+ if revision_id is not None:
+ source_ids = self.source.get_ancestry(revision_id)
+ if source_ids[0] is not None:
+ raise AssertionError()
+ source_ids.pop(0)
+ else:
+ source_ids = self.source.all_revision_ids()
+ source_ids_set = set(source_ids)
+ # source_ids is the worst possible case we may need to pull.
+ # now we want to filter source_ids against what we actually
+ # have in target, but don't try to check for existence where we know
+ # we do not have a revision as that would be pointless.
+ target_ids = set(self.target.all_revision_ids())
+ possibly_present_revisions = target_ids.intersection(source_ids_set)
+ actually_present_revisions = set(
+ self.target._eliminate_revisions_not_present(possibly_present_revisions))
+ required_revisions = source_ids_set.difference(actually_present_revisions)
+ if revision_id is not None:
+ # we used get_ancestry to determine source_ids then we are assured all
+ # revisions referenced are present as they are installed in topological order.
+ # and the tip revision was validated by get_ancestry.
+ result_set = required_revisions
+ else:
+ # if we just grabbed the possibly available ids, then
+ # we only have an estimate of whats available and need to validate
+ # that against the revision records.
+ result_set = set(
+ self.source._eliminate_revisions_not_present(required_revisions))
+ return self.source.revision_ids_to_search_result(result_set)
+
+
+InterRepository.register_optimiser(InterKnitRepo)
=== modified file 'bzrlib/repofmt/weaverepo.py'
--- a/bzrlib/repofmt/weaverepo.py 2010-08-25 10:20:41 +0000
+++ b/bzrlib/repofmt/weaverepo.py 2010-11-20 21:41:05 +0000
@@ -29,6 +29,7 @@
from bzrlib import (
xml5,
graph as _mod_graph,
+ ui,
)
""")
from bzrlib import (
@@ -38,7 +39,6 @@
lockable_files,
lockdir,
osutils,
- revision as _mod_revision,
trace,
urlutils,
versionedfile,
@@ -48,6 +48,8 @@
from bzrlib.decorators import needs_read_lock, needs_write_lock
from bzrlib.repository import (
CommitBuilder,
+ InterRepository,
+ InterSameDataRepository,
MetaDirVersionedFileRepository,
MetaDirRepositoryFormat,
Repository,
@@ -738,6 +740,116 @@
paths = list(relpaths)
return set([self._mapper.unmap(path) for path in paths])
+
+class InterWeaveRepo(InterSameDataRepository):
+ """Optimised code paths between Weave based repositories.
+
+ This should be in bzrlib/repofmt/weaverepo.py but we have not yet
+ implemented lazy inter-object optimisation.
+ """
+
+ @classmethod
+ def _get_repo_format_to_test(self):
+ return RepositoryFormat7()
+
+ @staticmethod
+ def is_compatible(source, target):
+ """Be compatible with known Weave formats.
+
+ We don't test for the stores being of specific types because that
+ could lead to confusing results, and there is no need to be
+ overly general.
+ """
+ try:
+ return (isinstance(source._format, (RepositoryFormat5,
+ RepositoryFormat6,
+ RepositoryFormat7)) and
+ isinstance(target._format, (RepositoryFormat5,
+ RepositoryFormat6,
+ RepositoryFormat7)))
+ except AttributeError:
+ return False
+
+ @needs_write_lock
+ def copy_content(self, revision_id=None):
+ """See InterRepository.copy_content()."""
+ # weave specific optimised path:
+ try:
+ self.target.set_make_working_trees(self.source.make_working_trees())
+ except (errors.RepositoryUpgradeRequired, NotImplemented):
+ pass
+ # FIXME do not peek!
+ if self.source._transport.listable():
+ pb = ui.ui_factory.nested_progress_bar()
+ try:
+ self.target.texts.insert_record_stream(
+ self.source.texts.get_record_stream(
+ self.source.texts.keys(), 'topological', False))
+ pb.update('Copying inventory', 0, 1)
+ self.target.inventories.insert_record_stream(
+ self.source.inventories.get_record_stream(
+ self.source.inventories.keys(), 'topological', False))
+ self.target.signatures.insert_record_stream(
+ self.source.signatures.get_record_stream(
+ self.source.signatures.keys(),
+ 'unordered', True))
+ self.target.revisions.insert_record_stream(
+ self.source.revisions.get_record_stream(
+ self.source.revisions.keys(),
+ 'topological', True))
+ finally:
+ pb.finished()
+ else:
+ self.target.fetch(self.source, revision_id=revision_id)
+
+ @needs_read_lock
+ def search_missing_revision_ids(self, revision_id=None, find_ghosts=True):
+ """See InterRepository.missing_revision_ids()."""
+ # we want all revisions to satisfy revision_id in source.
+ # but we don't want to stat every file here and there.
+ # we want then, all revisions other needs to satisfy revision_id
+ # checked, but not those that we have locally.
+ # so the first thing is to get a subset of the revisions to
+ # satisfy revision_id in source, and then eliminate those that
+ # we do already have.
+ # this is slow on high latency connection to self, but as this
+ # disk format scales terribly for push anyway due to rewriting
+ # inventory.weave, this is considered acceptable.
+ # - RBC 20060209
+ if revision_id is not None:
+ source_ids = self.source.get_ancestry(revision_id)
+ if source_ids[0] is not None:
+ raise AssertionError()
+ source_ids.pop(0)
+ else:
+ source_ids = self.source._all_possible_ids()
+ source_ids_set = set(source_ids)
+ # source_ids is the worst possible case we may need to pull.
+ # now we want to filter source_ids against what we actually
+ # have in target, but don't try to check for existence where we know
+ # we do not have a revision as that would be pointless.
+ target_ids = set(self.target._all_possible_ids())
+ possibly_present_revisions = target_ids.intersection(source_ids_set)
+ actually_present_revisions = set(
+ self.target._eliminate_revisions_not_present(possibly_present_revisions))
+ required_revisions = source_ids_set.difference(actually_present_revisions)
+ if revision_id is not None:
+ # we used get_ancestry to determine source_ids then we are assured all
+ # revisions referenced are present as they are installed in topological order.
+ # and the tip revision was validated by get_ancestry.
+ result_set = required_revisions
+ else:
+ # if we just grabbed the possibly available ids, then
+ # we only have an estimate of whats available and need to validate
+ # that against the revision records.
+ result_set = set(
+ self.source._eliminate_revisions_not_present(required_revisions))
+ return self.source.revision_ids_to_search_result(result_set)
+
+
_legacy_formats = [RepositoryFormat4(),
RepositoryFormat5(),
RepositoryFormat6()]
+
+
+InterRepository.register_optimiser(InterWeaveRepo)
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2010-11-22 03:35:24 +0000
+++ b/bzrlib/repository.py 2010-11-22 22:27:58 +0000
@@ -3553,176 +3553,6 @@
return InterRepository._same_model(source, target)
-class InterWeaveRepo(InterSameDataRepository):
- """Optimised code paths between Weave based repositories.
-
- This should be in bzrlib/repofmt/weaverepo.py but we have not yet
- implemented lazy inter-object optimisation.
- """
-
- @classmethod
- def _get_repo_format_to_test(self):
- from bzrlib.repofmt import weaverepo
- return weaverepo.RepositoryFormat7()
-
- @staticmethod
- def is_compatible(source, target):
- """Be compatible with known Weave formats.
-
- We don't test for the stores being of specific types because that
- could lead to confusing results, and there is no need to be
- overly general.
- """
- from bzrlib.repofmt.weaverepo import (
- RepositoryFormat5,
- RepositoryFormat6,
- RepositoryFormat7,
- )
- try:
- return (isinstance(source._format, (RepositoryFormat5,
- RepositoryFormat6,
- RepositoryFormat7)) and
- isinstance(target._format, (RepositoryFormat5,
- RepositoryFormat6,
- RepositoryFormat7)))
- except AttributeError:
- return False
-
- @needs_write_lock
- def copy_content(self, revision_id=None):
- """See InterRepository.copy_content()."""
- # weave specific optimised path:
- try:
- self.target.set_make_working_trees(self.source.make_working_trees())
- except (errors.RepositoryUpgradeRequired, NotImplemented):
- pass
- # FIXME do not peek!
- if self.source._transport.listable():
- pb = ui.ui_factory.nested_progress_bar()
- try:
- self.target.texts.insert_record_stream(
- self.source.texts.get_record_stream(
- self.source.texts.keys(), 'topological', False))
- pb.update('Copying inventory', 0, 1)
- self.target.inventories.insert_record_stream(
- self.source.inventories.get_record_stream(
- self.source.inventories.keys(), 'topological', False))
- self.target.signatures.insert_record_stream(
- self.source.signatures.get_record_stream(
- self.source.signatures.keys(),
- 'unordered', True))
- self.target.revisions.insert_record_stream(
- self.source.revisions.get_record_stream(
- self.source.revisions.keys(),
- 'topological', True))
- finally:
- pb.finished()
- else:
- self.target.fetch(self.source, revision_id=revision_id)
-
- @needs_read_lock
- def search_missing_revision_ids(self, revision_id=None, find_ghosts=True):
- """See InterRepository.missing_revision_ids()."""
- # we want all revisions to satisfy revision_id in source.
- # but we don't want to stat every file here and there.
- # we want then, all revisions other needs to satisfy revision_id
- # checked, but not those that we have locally.
- # so the first thing is to get a subset of the revisions to
- # satisfy revision_id in source, and then eliminate those that
- # we do already have.
- # this is slow on high latency connection to self, but as this
- # disk format scales terribly for push anyway due to rewriting
- # inventory.weave, this is considered acceptable.
- # - RBC 20060209
- if revision_id is not None:
- source_ids = self.source.get_ancestry(revision_id)
- if source_ids[0] is not None:
- raise AssertionError()
- source_ids.pop(0)
- else:
- source_ids = self.source._all_possible_ids()
- source_ids_set = set(source_ids)
- # source_ids is the worst possible case we may need to pull.
- # now we want to filter source_ids against what we actually
- # have in target, but don't try to check for existence where we know
- # we do not have a revision as that would be pointless.
- target_ids = set(self.target._all_possible_ids())
- possibly_present_revisions = target_ids.intersection(source_ids_set)
- actually_present_revisions = set(
- self.target._eliminate_revisions_not_present(possibly_present_revisions))
- required_revisions = source_ids_set.difference(actually_present_revisions)
- if revision_id is not None:
- # we used get_ancestry to determine source_ids then we are assured all
- # revisions referenced are present as they are installed in topological order.
- # and the tip revision was validated by get_ancestry.
- result_set = required_revisions
- else:
- # if we just grabbed the possibly available ids, then
- # we only have an estimate of whats available and need to validate
- # that against the revision records.
- result_set = set(
- self.source._eliminate_revisions_not_present(required_revisions))
- return self.source.revision_ids_to_search_result(result_set)
-
-
-class InterKnitRepo(InterSameDataRepository):
- """Optimised code paths between Knit based repositories."""
-
- @classmethod
- def _get_repo_format_to_test(self):
- from bzrlib.repofmt import knitrepo
- return knitrepo.RepositoryFormatKnit1()
-
- @staticmethod
- def is_compatible(source, target):
- """Be compatible with known Knit formats.
-
- We don't test for the stores being of specific types because that
- could lead to confusing results, and there is no need to be
- overly general.
- """
- from bzrlib.repofmt.knitrepo import RepositoryFormatKnit
- try:
- are_knits = (isinstance(source._format, RepositoryFormatKnit) and
- isinstance(target._format, RepositoryFormatKnit))
- except AttributeError:
- return False
- return are_knits and InterRepository._same_model(source, target)
-
- @needs_read_lock
- def search_missing_revision_ids(self, revision_id=None, find_ghosts=True):
- """See InterRepository.missing_revision_ids()."""
- if revision_id is not None:
- source_ids = self.source.get_ancestry(revision_id)
- if source_ids[0] is not None:
- raise AssertionError()
- source_ids.pop(0)
- else:
- source_ids = self.source.all_revision_ids()
- source_ids_set = set(source_ids)
- # source_ids is the worst possible case we may need to pull.
- # now we want to filter source_ids against what we actually
- # have in target, but don't try to check for existence where we know
- # we do not have a revision as that would be pointless.
- target_ids = set(self.target.all_revision_ids())
- possibly_present_revisions = target_ids.intersection(source_ids_set)
- actually_present_revisions = set(
- self.target._eliminate_revisions_not_present(possibly_present_revisions))
- required_revisions = source_ids_set.difference(actually_present_revisions)
- if revision_id is not None:
- # we used get_ancestry to determine source_ids then we are assured all
- # revisions referenced are present as they are installed in topological order.
- # and the tip revision was validated by get_ancestry.
- result_set = required_revisions
- else:
- # if we just grabbed the possibly available ids, then
- # we only have an estimate of whats available and need to validate
- # that against the revision records.
- result_set = set(
- self.source._eliminate_revisions_not_present(required_revisions))
- return self.source.revision_ids_to_search_result(result_set)
-
-
class InterDifferingSerializer(InterRepository):
@classmethod
@@ -4064,8 +3894,6 @@
InterRepository.register_optimiser(InterDifferingSerializer)
InterRepository.register_optimiser(InterSameDataRepository)
-InterRepository.register_optimiser(InterWeaveRepo)
-InterRepository.register_optimiser(InterKnitRepo)
class CopyConverter(object):
=== modified file 'bzrlib/tests/test_repository.py'
--- a/bzrlib/tests/test_repository.py 2010-11-22 03:35:24 +0000
+++ b/bzrlib/tests/test_repository.py 2010-11-22 22:27:58 +0000
@@ -586,7 +586,7 @@
]
repo_a = self.make_repository('a')
repo_b = self.make_repository('b')
- is_compatible = repository.InterWeaveRepo.is_compatible
+ is_compatible = weaverepo.InterWeaveRepo.is_compatible
for source in incompatible_formats:
# force incompatible left then right
repo_a._format = source
@@ -598,7 +598,7 @@
for target in formats:
repo_b._format = target
self.assertTrue(is_compatible(repo_a, repo_b))
- self.assertEqual(repository.InterWeaveRepo,
+ self.assertEqual(weaverepo.InterWeaveRepo,
repository.InterRepository.get(repo_a,
repo_b).__class__)
More information about the bazaar-commits
mailing list