Rev 4836: (vila) Don't allow RemoteRepository to stack on an incompatible-format repository. (#562380) (Andrew Bennetts) in file:///home/pqm/archives/thelove/bzr/2.1/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Apr 23 16:33:50 BST 2010
At file:///home/pqm/archives/thelove/bzr/2.1/
------------------------------------------------------------
revno: 4836 [merge]
revision-id: pqm at pqm.ubuntu.com-20100423153340-61z9lszb75goby7h
parent: pqm at pqm.ubuntu.com-20100423024000-nz2l54lvvajex20f
parent: andrew.bennetts at canonical.com-20100423052835-jhbdy6x1wbsaptlt
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.1
timestamp: Fri 2010-04-23 16:33:40 +0100
message:
(vila) Don't allow RemoteRepository to stack on an incompatible-format repository. (#562380) (Andrew Bennetts)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/tests/per_repository_reference/__init__.py __init__.py-20080220025549-nnm2s80it1lvcwnc-2
bzrlib/tests/per_repository_reference/test_default_stacking.py test_default_stackin-20090311055345-9ajahgm58oq3wh6h-1
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
=== modified file 'NEWS'
--- a/NEWS 2010-04-15 12:02:11 +0000
+++ b/NEWS 2010-04-23 05:28:35 +0000
@@ -38,6 +38,12 @@
problems importing bzrlib from a non-main thread.
(Elliot Murphy, #521989)
+* Repositories accessed via a smart server now reject being stacked on a
+ repository in an incompatible format, as is the case when accessing them
+ via other methods. This was causing fetches from those repositories via
+ a smart server (e.g. using ``bzr branch``) to receive invalid data.
+ (Andrew Bennetts, #562380)
+
* Standardize the error handling when creating a new ``StaticTuple``
(problems will raise TypeError). (Matt Nordhoff, #457979)
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2010-02-17 17:11:16 +0000
+++ b/bzrlib/remote.py 2010-04-23 05:28:35 +0000
@@ -27,6 +27,7 @@
lock,
lockdir,
repository,
+ repository as _mod_repository,
revision,
revision as _mod_revision,
symbol_versioning,
@@ -1214,6 +1215,7 @@
# state, so always add a lock here. If a caller passes us a locked
# repository, they are responsible for unlocking it later.
repository.lock_read()
+ self._check_fallback_repository(repository)
self._fallback_repositories.append(repository)
# If self._real_repository was parameterised already (e.g. because a
# _real_branch had its get_stacked_on_url method called), then the
@@ -1224,6 +1226,16 @@
if repository.bzrdir.root_transport.base not in fallback_locations:
self._real_repository.add_fallback_repository(repository)
+ def _check_fallback_repository(self, repository):
+ """Check that this repository can fallback to repository safely.
+
+ Raise an error if not.
+
+ :param repository: A repository to fallback to.
+ """
+ return _mod_repository.InterRepository._assert_same_model(
+ self, repository)
+
def add_inventory(self, revid, inv, parents):
self._ensure_real()
return self._real_repository.add_inventory(revid, inv, parents)
=== modified file 'bzrlib/tests/per_repository_reference/__init__.py'
--- a/bzrlib/tests/per_repository_reference/__init__.py 2009-07-15 17:51:40 +0000
+++ b/bzrlib/tests/per_repository_reference/__init__.py 2010-04-23 05:28:35 +0000
@@ -23,6 +23,7 @@
"""
from bzrlib import (
+ errors,
repository,
remote,
)
@@ -66,6 +67,22 @@
self.repository_format.__class__)
+class TestIncompatibleStacking(TestCaseWithRepository):
+
+ def test_add_fallback_repository_rejects_incompatible(self):
+ # Repository.add_fallback_repository raises IncompatibleRepositories if
+ # you take two repositories in different serializations and try to
+ # stack them.
+ if self.make_repository('test')._format.supports_chks:
+ different_fmt = '1.9'
+ else:
+ different_fmt = '2a'
+ repo = self.make_repository('repo', format=different_fmt)
+ referring = self.make_repository('referring')
+ self.assertRaises(errors.IncompatibleRepositories,
+ referring.add_fallback_repository, repo)
+
+
def external_reference_test_scenarios():
"""Generate test scenarios for repositories supporting external references.
"""
=== modified file 'bzrlib/tests/per_repository_reference/test_default_stacking.py'
--- a/bzrlib/tests/per_repository_reference/test_default_stacking.py 2009-06-10 03:56:49 +0000
+++ b/bzrlib/tests/per_repository_reference/test_default_stacking.py 2010-04-23 05:28:35 +0000
@@ -15,7 +15,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-from bzrlib.smart import server
from bzrlib.tests.per_repository import TestCaseWithRepository
=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py 2010-02-17 17:11:16 +0000
+++ b/bzrlib/tests/test_remote.py 2010-04-23 05:28:35 +0000
@@ -1222,8 +1222,8 @@
len(branch.repository._real_repository._fallback_repositories))
def test_get_stacked_on_real_branch(self):
- base_branch = self.make_branch('base', format='1.6')
- stacked_branch = self.make_branch('stacked', format='1.6')
+ base_branch = self.make_branch('base')
+ stacked_branch = self.make_branch('stacked')
stacked_branch.set_stacked_on_url('../base')
reference_format = self.get_repo_format()
network_name = reference_format.network_name()
@@ -1234,7 +1234,7 @@
'success', ('branch', branch_network_name))
client.add_expected_call(
'BzrDir.find_repositoryV3', ('stacked/',),
- 'success', ('ok', '', 'no', 'no', 'yes', network_name))
+ 'success', ('ok', '', 'yes', 'no', 'yes', network_name))
# called twice, once from constructor and then again by us
client.add_expected_call(
'Branch.get_stacked_on_url', ('stacked/',),
@@ -2193,12 +2193,13 @@
"""
# Make a repo with a fallback repo, both using a FakeClient.
format = remote.response_tuple_to_repo_format(
- ('yes', 'no', 'yes', 'fake-network-name'))
+ ('yes', 'no', 'yes', self.get_repo_format().network_name()))
repo, client = self.setup_fake_client_and_repository('quack')
repo._format = format
fallback_repo, ignored = self.setup_fake_client_and_repository(
'fallback')
fallback_repo._client = client
+ fallback_repo._format = format
repo.add_fallback_repository(fallback_repo)
# First the client should ask the primary repo
client.add_expected_call(
More information about the bazaar-commits
mailing list