Rev 2654: Make InterKnitOptimiser be used between any same-model knit repository. in http://people.ubuntu.com/~robertc/baz2.0/repository
Robert Collins
robertc at robertcollins.net
Sun Jul 15 05:10:56 BST 2007
At http://people.ubuntu.com/~robertc/baz2.0/repository
------------------------------------------------------------
revno: 2654
revision-id: robertc at robertcollins.net-20070715041046-c1jgc3fjq3v4rvdy
parent: robertc at robertcollins.net-20070714154926-g773i1j0pxjkouis
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Sun 2007-07-15 14:10:46 +1000
message:
Make InterKnitOptimiser be used between any same-model knit repository.
modified:
bzrlib/repofmt/knitrepo.py knitrepo.py-20070206081537-pyy4a00xdas0j4pf-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
=== modified file 'bzrlib/repofmt/knitrepo.py'
--- a/bzrlib/repofmt/knitrepo.py 2007-07-14 15:15:35 +0000
+++ b/bzrlib/repofmt/knitrepo.py 2007-07-15 04:10:46 +0000
@@ -335,7 +335,8 @@
index_transport, 'index')
self.repo._revision_indices.load()
indices = []
- for name in self.repo._revision_indices.names():
+ def _cmp(x, y): return cmp(int(x), int(y))
+ for name in sorted(self.repo._revision_indices.names(), cmp=_cmp, reverse=True):
# TODO: maybe this should expose size to us to allow
# sorting of the indices for better performance ?
indices.append(GraphIndex(index_transport, name))
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2007-07-14 08:51:20 +0000
+++ b/bzrlib/repository.py 2007-07-15 04:10:46 +0000
@@ -1433,6 +1433,15 @@
# that we've decided we need.
return [rev_id for rev_id in source_ids if rev_id in result_set]
+ @staticmethod
+ def _same_model(source, target):
+ """True if source and target have the same data representation."""
+ if source.supports_rich_root() != target.supports_rich_root():
+ return False
+ if source._serializer != target._serializer:
+ return False
+ return True
+
class InterSameDataRepository(InterRepository):
"""Code for converting between repositories that represent the same data.
@@ -1447,11 +1456,7 @@
@staticmethod
def is_compatible(source, target):
- if source.supports_rich_root() != target.supports_rich_root():
- return False
- if source._serializer != target._serializer:
- return False
- return True
+ return InterRepository._same_model(source, target)
@needs_write_lock
def copy_content(self, revision_id=None):
@@ -1630,12 +1635,13 @@
could lead to confusing results, and there is no need to be
overly general.
"""
- from bzrlib.repofmt.knitrepo import RepositoryFormatKnit1
+ from bzrlib.repofmt.knitrepo import RepositoryFormatKnit
try:
- return (isinstance(source._format, (RepositoryFormatKnit1)) and
- isinstance(target._format, (RepositoryFormatKnit1)))
+ 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_write_lock
def fetch(self, revision_id=None, pb=None):
More information about the bazaar-commits
mailing list