Rev 5167: (lifeless) Don't allow RemoteRepository to stack on an incompatible-format repository. (#562380) (Andrew Bennetts) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Apr 20 05:16:55 BST 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5167 [merge]
revision-id: pqm at pqm.ubuntu.com-20100420041650-t13bfii1es5mh3x9
parent: pqm at pqm.ubuntu.com-20100420001656-qq6or4qe130cvtlk
parent: andrew.bennetts at canonical.com-20100420002000-xwwdz7m32af5lm81
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2010-04-20 05:16:50 +0100
message:
(lifeless) 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-19 13:04:30 +0000
+++ b/NEWS 2010-04-20 04:16:50 +0000
@@ -60,6 +60,12 @@
which is not installed any more" error.
(Martin Pool, James Westby, #528114)
+* 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)
+
* Reset ``siginterrupt`` flag to False every time we handle a signal
installed with ``set_signal_handler(..., restart_syscall=True)`` (from
``bzrlib.osutils``. Reduces the likelihood of "Interrupted System Call"
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2010-04-19 13:04:30 +0000
+++ b/bzrlib/remote.py 2010-04-20 04:16:50 +0000
@@ -27,6 +27,7 @@
lock,
lockdir,
repository,
+ repository as _mod_repository,
revision,
revision as _mod_revision,
static_tuple,
@@ -1227,6 +1228,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
@@ -1237,6 +1239,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-16 06:51:59 +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-16 02:51:37 +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-23 07:43:11 +0000
+++ b/bzrlib/tests/test_remote.py 2010-04-20 00:20:00 +0000
@@ -1223,8 +1223,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()
@@ -1235,7 +1235,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/',),
@@ -2191,12 +2191,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