Rev 3840: (abentley) Fix RemoteRepository.get_parent_map when stacked in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Nov 18 22:21:34 GMT 2008
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 3840
revision-id: pqm at pqm.ubuntu.com-20081118222130-vczdog5my1bc6ta4
parent: pqm at pqm.ubuntu.com-20081117224017-jb8tr2wok8jjxn7r
parent: aaron at aaronbentley.com-20081118214336-53wku2p6og6kvl5r
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2008-11-18 22:21:30 +0000
message:
(abentley) Fix RemoteRepository.get_parent_map when stacked
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
------------------------------------------------------------
revno: 3835.1.7
revision-id: aaron at aaronbentley.com-20081118214336-53wku2p6og6kvl5r
parent: aaron at aaronbentley.com-20081118175606-195u5kcnjnedebny
committer: Aaron Bentley <aaron at aaronbentley.com>
branch nick: remote-stacking-graph
timestamp: Tue 2008-11-18 16:43:36 -0500
message:
Updates from review
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
------------------------------------------------------------
revno: 3835.1.6
revision-id: aaron at aaronbentley.com-20081118175606-195u5kcnjnedebny
parent: aaron at aaronbentley.com-20081118171200-ajuln6fdb87yd8sa
committer: Aaron Bentley <aaron at aaronbentley.com>
branch nick: remote-stacking-graph
timestamp: Tue 2008-11-18 12:56:06 -0500
message:
Reduce inefficiency when doing make_parents_provider frequently
modified:
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
------------------------------------------------------------
revno: 3835.1.5
revision-id: aaron at aaronbentley.com-20081118171200-ajuln6fdb87yd8sa
parent: aaron at aaronbentley.com-20081118170633-krfe08xg3nn2q6wr
committer: Aaron Bentley <aaron at aaronbentley.com>
branch nick: remote-stacking-graph
timestamp: Tue 2008-11-18 12:12:00 -0500
message:
Fix make_parents_provider
modified:
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
------------------------------------------------------------
revno: 3835.1.4
revision-id: aaron at aaronbentley.com-20081118170633-krfe08xg3nn2q6wr
parent: aaron at aaronbentley.com-20081118045428-iqnvgupw1j1nysxu
parent: pqm at pqm.ubuntu.com-20081117224017-jb8tr2wok8jjxn7r
committer: Aaron Bentley <aaron at aaronbentley.com>
branch nick: remote-stacking-graph
timestamp: Tue 2008-11-18 12:06:33 -0500
message:
Merge bzr.dev info remote-stacking-graph
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/option.py option.py-20051014052914-661fb36e76e7362f
bzrlib/plugins/launchpad/account.py account.py-20071011033320-50y6vfftywf4yllw-1
bzrlib/plugins/launchpad/lp_directory.py lp_indirect.py-20070126012204-de5rugwlt22c7u7e-1
bzrlib/plugins/launchpad/test_account.py test_account.py-20071011033320-50y6vfftywf4yllw-2
bzrlib/repofmt/pack_repo.py pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
bzrlib/shelf_ui.py shelver.py-20081005210102-33worgzwrtdw0yrm-1
bzrlib/tests/test_shelf_ui.py test_shelf_ui.py-20081027155203-wtcuazg85wp9u4fv-1
------------------------------------------------------------
revno: 3835.1.3
revision-id: aaron at aaronbentley.com-20081118045428-iqnvgupw1j1nysxu
parent: aaron at aaronbentley.com-20081118044717-t6tx15x58dl3d1f9
committer: Aaron Bentley <aaron at aaronbentley.com>
branch nick: remote-stacking-graph
timestamp: Mon 2008-11-17 23:54:28 -0500
message:
Add NEWS entry
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
------------------------------------------------------------
revno: 3835.1.2
revision-id: aaron at aaronbentley.com-20081118044717-t6tx15x58dl3d1f9
parent: aaron at aaronbentley.com-20081117142319-uy77nvajbqw87cfv
committer: Aaron Bentley <aaron at aaronbentley.com>
branch nick: remote-stacking-graph
timestamp: Mon 2008-11-17 23:47:17 -0500
message:
Add tests for get_parent_map
modified:
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
------------------------------------------------------------
revno: 3835.1.1
revision-id: aaron at aaronbentley.com-20081117142319-uy77nvajbqw87cfv
parent: pqm at pqm.ubuntu.com-20081113075004-skgl7ma39awgyjze
committer: Aaron Bentley <aaron at aaronbentley.com>
branch nick: remote-stacking-graph
timestamp: Mon 2008-11-17 09:23:19 -0500
message:
Stack get_parent_map on fallback repos
modified:
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
=== modified file 'NEWS'
--- a/NEWS 2008-11-14 02:13:07 +0000
+++ b/NEWS 2008-11-18 21:43:36 +0000
@@ -34,6 +34,9 @@
tries to abort a write group. This allows the root cause (e.g. a
network interruption) to be reported. (Andrew Bennetts, #297014)
+ * RemoteRepository.get_parent_map now uses fallback repositories.
+ (Aaron Bentley, #297991?, #293679?)
+
DOCUMENTATION:
API CHANGES:
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2008-11-13 07:50:04 +0000
+++ b/bzrlib/remote.py 2008-11-18 21:43:36 +0000
@@ -287,6 +287,17 @@
'Does not support nested trees', target_format)
+class _UnstackedParentsProvider(object):
+ """ParentsProvider for RemoteRepository that ignores stacking."""
+
+ def __init__(self, remote_repository):
+ self._remote_repository = remote_repository
+
+ def get_parent_map(self, revision_ids):
+ """See RemoteRepository.get_parent_map."""
+ return self._remote_repository._get_parent_map(revision_ids)
+
+
class RemoteRepository(_RpcHelper):
"""Repository accessed over rpc.
@@ -462,10 +473,10 @@
def has_same_location(self, other):
return (self.__class__ == other.__class__ and
self.bzrdir.transport.base == other.bzrdir.transport.base)
-
+
def get_graph(self, other_repository=None):
"""Return the graph for this repository format"""
- parents_provider = self
+ parents_provider = self._make_parents_provider()
if (other_repository is not None and
other_repository.bzrdir.transport.base !=
self.bzrdir.transport.base):
@@ -882,8 +893,12 @@
self._ensure_real()
return self._real_repository._fetch_reconcile
- def get_parent_map(self, keys):
+ def get_parent_map(self, revision_ids):
"""See bzrlib.Graph.get_parent_map()."""
+ return self._make_parents_provider().get_parent_map(revision_ids)
+
+ def _get_parent_map(self, keys):
+ """Implementation of get_parent_map() that ignores fallbacks."""
# Hack to build up the caching logic.
ancestry = self._parents_map
if ancestry is None:
@@ -893,7 +908,7 @@
else:
missing_revisions = set(key for key in keys if key not in ancestry)
if missing_revisions:
- parent_map = self._get_parent_map(missing_revisions)
+ parent_map = self._get_parent_map_rpc(missing_revisions)
if 'hpss' in debug.debug_flags:
mutter('retransmitted revisions: %d of %d',
len(set(ancestry).intersection(parent_map)),
@@ -907,7 +922,7 @@
100.0 * len(self._requested_parents) / len(ancestry))
return dict((k, ancestry[k]) for k in present_keys)
- def _get_parent_map(self, keys):
+ def _get_parent_map_rpc(self, keys):
"""Helper for get_parent_map that performs the RPC."""
medium = self._client._medium
if medium._is_remote_before((1, 2)):
@@ -1208,7 +1223,10 @@
return self._real_repository._check_for_inconsistent_revision_parents()
def _make_parents_provider(self):
- return self
+ providers = [_UnstackedParentsProvider(self)]
+ providers.extend(r._make_parents_provider() for r in
+ self._fallback_repositories)
+ return graph._StackedParentsProvider(providers)
def _serialise_search_recipe(self, recipe):
"""Serialise a graph search recipe.
=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py 2008-10-31 01:57:16 +0000
+++ b/bzrlib/tests/test_remote.py 2008-11-18 21:43:36 +0000
@@ -1116,12 +1116,11 @@
class TestRepositoryGetGraph(TestRemoteRepository):
def test_get_graph(self):
- # get_graph returns a graph with the repository as the
- # parents_provider.
+ # get_graph returns a graph with a custom parents provider.
transport_path = 'quack'
repo, client = self.setup_fake_client_and_repository(transport_path)
graph = repo.get_graph()
- self.assertEqual(graph._parents_provider, repo)
+ self.assertNotEqual(graph._parents_provider, repo)
class TestRepositoryGetParentMap(TestRemoteRepository):
@@ -1750,3 +1749,28 @@
'message')
finally:
remote_repo.unlock()
+
+ def prepare_stacked_remote_branch(self):
+ smart_server = server.SmartTCPServer_for_testing()
+ smart_server.setUp()
+ self.addCleanup(smart_server.tearDown)
+ tree1 = self.make_branch_and_tree('tree1')
+ tree1.commit('rev1', rev_id='rev1')
+ tree2 = self.make_branch_and_tree('tree2', format='1.6')
+ tree2.branch.set_stacked_on_url(tree1.branch.base)
+ branch2 = Branch.open(smart_server.get_url() + '/tree2')
+ branch2.lock_read()
+ self.addCleanup(branch2.unlock)
+ return branch2
+
+ def test_stacked_get_parent_map(self):
+ # the public implementation of get_parent_map obeys stacking
+ branch = self.prepare_stacked_remote_branch()
+ repo = branch.repository
+ self.assertEqual(['rev1'], repo.get_parent_map(['rev1']).keys())
+
+ def test_stacked__get_parent_map(self):
+ # the private variant of _get_parent_map ignores stacking
+ branch = self.prepare_stacked_remote_branch()
+ repo = branch.repository
+ self.assertEqual([], repo._get_parent_map(['rev1']).keys())
More information about the bazaar-commits
mailing list