Rev 2615: Add restrict_revisions parameter to VersionedFile.join() and in file:///data/jelmer/bzr/shallow/
Jelmer Vernooij
jelmer at samba.org
Fri Jul 13 18:15:21 BST 2007
At file:///data/jelmer/bzr/shallow/
------------------------------------------------------------
revno: 2615
revision-id: jelmer at samba.org-20070713171444-00gl8k8t8j43rl3m
parent: jelmer at samba.org-20070713165319-o3ljh4pqc7z08w0z
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: shallow
timestamp: Fri 2007-07-13 20:14:44 +0300
message:
Add restrict_revisions parameter to VersionedFile.join() and
InterVersionedFile.join().
modified:
bzrlib/fetch.py fetch.py-20050818234941-26fea6105696365d
bzrlib/knit.py knit.py-20051212171256-f056ac8f0fbe1bd9
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tests/interversionedfile_implementations/test_join.py test_join.py-20060302012326-9b5e9b0f0a03fedc
bzrlib/tests/test_knit.py test_knit.py-20051212171302-95d4c00dd5f11f2b
bzrlib/versionedfile.py versionedfile.py-20060222045106-5039c71ee3b65490
bzrlib/weave.py knit.py-20050627021749-759c29984154256b
=== modified file 'bzrlib/fetch.py'
--- a/bzrlib/fetch.py 2007-04-20 04:18:37 +0000
+++ b/bzrlib/fetch.py 2007-07-13 17:14:44 +0000
@@ -267,6 +267,12 @@
copy revision texts.
"""
+ def __init__(self, to_repository, from_repository, last_revision=None, pb=None,
+ limit_to_revisions=None):
+ self._limit_to_revisions = limit_to_revisions
+ super(KnitRepoFetcher, self).__init__(to_repository, from_repository,
+ last_revision, pb)
+
def _fetch_revision_texts(self, revs):
# may need to be a InterRevisionStore call here.
from_transaction = self.from_repository.get_transaction()
@@ -280,7 +286,11 @@
to_transaction)
from_rf = self.from_repository._revision_store.get_revision_file(
from_transaction)
- to_rf.join(from_rf, version_ids=revs)
+ if self._limit_to_revisions is not None:
+ to_rf.join(from_rf, version_ids=self._limit_to_revisions,
+ restrict_revisions=True)
+ else:
+ to_rf.join(from_rf, version_ids=revs)
class Inter1and2Helper(object):
=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py 2007-06-27 07:37:53 +0000
+++ b/bzrlib/knit.py 2007-07-13 17:14:44 +0000
@@ -1634,7 +1634,8 @@
except AttributeError:
return False
- def join(self, pb=None, msg=None, version_ids=None, ignore_missing=False):
+ def join(self, pb=None, msg=None, version_ids=None, ignore_missing=False,
+ restrict_revisions=False):
"""See InterVersionedFile.join."""
assert isinstance(self.source, KnitVersionedFile)
assert isinstance(self.target, KnitVersionedFile)
@@ -1644,6 +1645,10 @@
if not version_ids:
return 0
+ if restrict_revisions and self.source.delta:
+ # Partial cloning from delta-knits is not supported yet
+ raise errors.PartialCloningNotSupported(self)
+
pb = ui.ui_factory.nested_progress_bar()
try:
version_ids = list(version_ids)
@@ -1751,7 +1756,8 @@
except AttributeError:
return False
- def join(self, pb=None, msg=None, version_ids=None, ignore_missing=False):
+ def join(self, pb=None, msg=None, version_ids=None, ignore_missing=False,
+ restrict_revisions=False):
"""See InterVersionedFile.join."""
assert isinstance(self.source, bzrlib.weave.Weave)
assert isinstance(self.target, KnitVersionedFile)
@@ -1761,6 +1767,9 @@
if not version_ids:
return 0
+ if restrict_revisions:
+ raise errors.PartialCloningNotSupported(self)
+
pb = ui.ui_factory.nested_progress_bar()
try:
version_ids = list(version_ids)
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2007-07-12 15:24:23 +0000
+++ b/bzrlib/repository.py 2007-07-13 17:14:44 +0000
@@ -1626,13 +1626,12 @@
from bzrlib.fetch import KnitRepoFetcher
mutter("Using fetch logic to copy between %s(%s) and %s(%s)",
self.source, self.source._format, self.target, self.target._format)
- if limit_to_revisions is not None:
- raise errors.PartialCloningNotSupported(self)
# TODO: jam 20070210 This should be an assert, not a translate
revision_id = osutils.safe_revision_id(revision_id)
f = KnitRepoFetcher(to_repository=self.target,
from_repository=self.source,
last_revision=revision_id,
+ limit_to_revisions=limit_to_revisions,
pb=pb)
return f.count_copied, f.failed_revisions
=== modified file 'bzrlib/tests/interversionedfile_implementations/test_join.py'
--- a/bzrlib/tests/interversionedfile_implementations/test_join.py 2006-10-11 23:08:27 +0000
+++ b/bzrlib/tests/interversionedfile_implementations/test_join.py 2007-07-13 17:14:44 +0000
@@ -62,6 +62,21 @@
#self.assertTrue(f4.has_version('r0'))
#self.assertFalse(f4.has_version('r1'))
+ def test_join_restrict_revisions(self):
+ f1 = self.get_source()
+ f1.add_lines('r0', [], ['a\n', 'b\n'])
+ f1.add_lines('r1', ['r0'], ['c\n', 'b\n'])
+ f2 = self.get_target()
+ f1.add_lines('r3', [], ['d\n', 'b\n'])
+ try:
+ f2.join(f1, version_ids=['r1'],
+ restrict_revisions=True)
+ except errors.PartialCloningNotSupported:
+ return # Not all VersionedFile implementations support
+ # restrict_revisions
+ self.assertEquals(["r1", "r3"],
+ f2.versions())
+
def test_gets_expected_inter_worker(self):
source = self.get_source()
target = self.get_target()
=== modified file 'bzrlib/tests/test_knit.py'
--- a/bzrlib/tests/test_knit.py 2007-03-09 22:14:55 +0000
+++ b/bzrlib/tests/test_knit.py 2007-07-13 17:14:44 +0000
@@ -884,6 +884,40 @@
self.assertTrue(k2.has_version('text-a'))
self.assertTrue(k2.has_version('text-c'))
+ def test_knit_join_restrict_delta(self):
+ """Joining a knit with restrict_revisions set should error out on delta knits."""
+ k1 = KnitVersionedFile('test1', get_transport('.'),
+ factory=KnitPlainFactory(), create=True)
+ k1.add_lines('text-a', [], split_lines(TEXT_1))
+ k1.add_lines('text-b', ['text-a'], split_lines(TEXT_1))
+
+ k1.add_lines('text-c', [], split_lines(TEXT_1))
+ k1.add_lines('text-d', ['text-c'], split_lines(TEXT_1))
+
+ k1.add_lines('text-m', ['text-b', 'text-d'], split_lines(TEXT_1))
+ k2 = KnitVersionedFile('test2', get_transport('.'),
+ factory=KnitPlainFactory(), create=True)
+ self.assertRaises(errors.PartialCloningNotSupported,
+ k2.join, k1, version_ids=['text-m'], restrict_revisions=True)
+
+ def test_knit_join_restrict(self):
+ """Joining a knit with restrict_revisions set should not copy any
+ other revisions."""
+ k1 = KnitVersionedFile('test1', get_transport('.'), delta=False,
+ factory=KnitPlainFactory(), create=True)
+ k1.add_lines('text-a', [], split_lines(TEXT_1))
+ k1.add_lines('text-b', ['text-a'], split_lines(TEXT_1))
+
+ k1.add_lines('text-c', [], split_lines(TEXT_1))
+ k1.add_lines('text-d', ['text-c'], split_lines(TEXT_1))
+
+ k1.add_lines('text-m', ['text-b', 'text-d'], split_lines(TEXT_1))
+ k2 = KnitVersionedFile('test2', get_transport('.'),
+ factory=KnitPlainFactory(), create=True, delta=False)
+ k2.add_lines('text-a', [], split_lines(TEXT_1))
+ k2.join(k1, version_ids=['text-m'], restrict_revisions=True)
+ self.assertEquals(["text-a", "text-m"], k2.versions())
+
def test_reannotate(self):
k1 = KnitVersionedFile('knit1', get_transport('.'),
factory=KnitAnnotateFactory(), create=True)
=== modified file 'bzrlib/versionedfile.py'
--- a/bzrlib/versionedfile.py 2007-06-28 06:16:19 +0000
+++ b/bzrlib/versionedfile.py 2007-07-13 17:14:44 +0000
@@ -407,7 +407,7 @@
return lines
def join(self, other, pb=None, msg=None, version_ids=None,
- ignore_missing=False):
+ ignore_missing=False, restrict_revisions=False):
"""Integrate versions from other into this versioned file.
If version_ids is None all versions from other should be
@@ -419,10 +419,7 @@
"""
self._check_write_ok()
return InterVersionedFile.get(other, self).join(
- pb,
- msg,
- version_ids,
- ignore_missing)
+ pb, msg, version_ids, ignore_missing, restrict_revisions)
def iter_lines_added_or_present_in_versions(self, version_ids=None,
pb=None):
@@ -587,7 +584,8 @@
_optimisers = []
"""The available optimised InterVersionedFile types."""
- def join(self, pb=None, msg=None, version_ids=None, ignore_missing=False):
+ def join(self, pb=None, msg=None, version_ids=None, ignore_missing=False,
+ restrict_revisions=False):
"""Integrate versions from self.source into self.target.
If version_ids is None all versions from source should be
@@ -597,6 +595,8 @@
are not present in the other files history unless ignore_missing is
supplied when they are silently skipped.
"""
+ if restrict_revisions:
+ raise errors.PartialCloningNotSupported(self)
# the default join:
# - if the target is empty, just add all the versions from
# source to target, otherwise:
=== modified file 'bzrlib/weave.py'
--- a/bzrlib/weave.py 2007-06-17 17:07:04 +0000
+++ b/bzrlib/weave.py 2007-07-13 17:14:44 +0000
@@ -1145,9 +1145,10 @@
return [WeaveFile.WEAVE_SUFFIX]
def join(self, other, pb=None, msg=None, version_ids=None,
- ignore_missing=False):
+ ignore_missing=False, restrict_revisions=False):
"""Join other into self and save."""
- super(WeaveFile, self).join(other, pb, msg, version_ids, ignore_missing)
+ super(WeaveFile, self).join(other, pb, msg, version_ids, ignore_missing,
+ restrict_revisions)
self._save()
@@ -1435,8 +1436,11 @@
except AttributeError:
return False
- def join(self, pb=None, msg=None, version_ids=None, ignore_missing=False):
+ def join(self, pb=None, msg=None, version_ids=None, ignore_missing=False,
+ restrict_revisions=False):
"""See InterVersionedFile.join."""
+ if restrict_revisions:
+ raise errors.PartialCloningNotSupported(self)
version_ids = self._get_source_version_ids(version_ids, ignore_missing)
if self.target.versions() == [] and version_ids is None:
self.target._copy_weave_content(self.source)
More information about the bazaar-commits
mailing list