Rev 4432: (andrew) Fix branch.revision_history() (and 'bzr pull -r 123') from in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Jun 11 10:11:26 BST 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4432
revision-id: pqm at pqm.ubuntu.com-20090611091121-s2u2yy5qa9yh4bm1
parent: pqm at pqm.ubuntu.com-20090611052211-b6b2pu471mdja7zz
parent: andrew.bennetts at canonical.com-20090611074356-y5o4aqx4grx62vo8
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2009-06-11 10:11:21 +0100
message:
(andrew) Fix branch.revision_history() (and 'bzr pull -r 123') from
stacked branch via HPSS.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/tests/blackbox/test_pull.py test_pull.py-20051201144907-64959364f629947f
bzrlib/tests/branch_implementations/test_stacking.py test_stacking.py-20080214020755-msjlkb7urobwly0f-1
------------------------------------------------------------
revno: 4419.1.6
revision-id: andrew.bennetts at canonical.com-20090611074356-y5o4aqx4grx62vo8
parent: andrew.bennetts at canonical.com-20090611074005-o0rbje2jxio6gxh0
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: bug-380314
timestamp: Thu 2009-06-11 17:43:56 +1000
message:
Add comments requested by Martin's review.
modified:
bzrlib/tests/blackbox/test_pull.py test_pull.py-20051201144907-64959364f629947f
bzrlib/tests/branch_implementations/test_stacking.py test_stacking.py-20080214020755-msjlkb7urobwly0f-1
------------------------------------------------------------
revno: 4419.1.5
revision-id: andrew.bennetts at canonical.com-20090611074005-o0rbje2jxio6gxh0
parent: andrew.bennetts at canonical.com-20090610052951-g3lf1k53ux6vzfix
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: bug-380314
timestamp: Thu 2009-06-11 17:40:05 +1000
message:
Add NEWS entry.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
------------------------------------------------------------
revno: 4419.1.4
revision-id: andrew.bennetts at canonical.com-20090610052951-g3lf1k53ux6vzfix
parent: andrew.bennetts at canonical.com-20090610030917-l1izzqtby8p2s9hy
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: stacking-friendly-revision-history-verb
timestamp: Wed 2009-06-10 15:29:51 +1000
message:
Set the test_pull_smart_stacked_streaming_acceptance to 43, its current value.
modified:
bzrlib/tests/blackbox/test_pull.py test_pull.py-20051201144907-64959364f629947f
------------------------------------------------------------
revno: 4419.1.3
revision-id: andrew.bennetts at canonical.com-20090610030917-l1izzqtby8p2s9hy
parent: andrew.bennetts at canonical.com-20090610030039-v5nhrstaaymj93ea
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: stacking-friendly-revision-history-verb
timestamp: Wed 2009-06-10 13:09:17 +1000
message:
Quick fix by using self._ensure_real.
modified:
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
------------------------------------------------------------
revno: 4419.1.2
revision-id: andrew.bennetts at canonical.com-20090610030039-v5nhrstaaymj93ea
parent: andrew.bennetts at canonical.com-20090610010533-dzm89j2o4yw0erj1
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: stacking-friendly-revision-history-verb
timestamp: Wed 2009-06-10 13:00:39 +1000
message:
Add branch_implementations test for revision_history() on a stacked branch.
modified:
bzrlib/tests/branch_implementations/test_stacking.py test_stacking.py-20080214020755-msjlkb7urobwly0f-1
------------------------------------------------------------
revno: 4419.1.1
revision-id: andrew.bennetts at canonical.com-20090610010533-dzm89j2o4yw0erj1
parent: pqm at pqm.ubuntu.com-20090609062641-6hs0exctaa1sz12m
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: stacking-friendly-revision-history-verb
timestamp: Wed 2009-06-10 11:05:33 +1000
message:
Failing blackbox acceptance test for bug 380314.
modified:
bzrlib/tests/blackbox/test_pull.py test_pull.py-20051201144907-64959364f629947f
=== modified file 'NEWS'
--- a/NEWS 2009-06-11 05:22:11 +0000
+++ b/NEWS 2009-06-11 09:11:21 +0000
@@ -69,6 +69,10 @@
* Better message in ``bzr add`` output suggesting using ``bzr ignored`` to
see which files can also be added. (Jason Spashett, #76616)
+* ``bzr pull -r 123`` from a stacked branch on a smart server no longer fails.
+ Also, the ``Branch.revision_history()`` API now works in the same
+ situation. (Andrew Bennetts, #380314)
+
* ``bzr serve`` on Windows no longer displays a traceback simply because a
TCP client disconnected. (Andrew Bennetts)
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2009-06-10 03:56:49 +0000
+++ b/bzrlib/remote.py 2009-06-11 09:11:21 +0000
@@ -1970,6 +1970,7 @@
hooks = branch.Branch.hooks['open']
for hook in hooks:
hook(self)
+ self._is_stacked = False
if setup_stacking:
self._setup_stacking()
@@ -1981,6 +1982,7 @@
except (errors.NotStacked, errors.UnstackableBranchFormat,
errors.UnstackableRepositoryFormat), e:
return
+ self._is_stacked = True
self._activate_fallback_location(fallback_url)
def _get_config(self):
@@ -2088,6 +2090,13 @@
raise errors.UnexpectedSmartServerResponse(response)
return response[1]
+ def set_stacked_on_url(self, url):
+ branch.Branch.set_stacked_on_url(self, url)
+ if not url:
+ self._is_stacked = False
+ else:
+ self._is_stacked = True
+
def _vfs_get_tags_bytes(self):
self._ensure_real()
return self._real_branch._get_tags_bytes()
@@ -2230,6 +2239,9 @@
def _gen_revision_history(self):
"""See Branch._gen_revision_history()."""
+ if self._is_stacked:
+ self._ensure_real()
+ return self._real_branch._gen_revision_history()
response_tuple, response_handler = self._call_expecting_body(
'Branch.revision_history', self._remote_path())
if response_tuple[0] != 'ok':
=== modified file 'bzrlib/tests/blackbox/test_pull.py'
--- a/bzrlib/tests/blackbox/test_pull.py 2009-05-06 05:36:28 +0000
+++ b/bzrlib/tests/blackbox/test_pull.py 2009-06-11 07:43:56 +0000
@@ -359,3 +359,31 @@
self.assertContainsRe(out, r'\n {4}1 .*\n {6}setup\n')
self.assertNotContainsRe(
out, r'revno: 1\ncommitter: .*\nbranch nick: source')
+
+ def test_pull_smart_stacked_streaming_acceptance(self):
+ """'bzr pull -r 123' works on stacked, smart branches, even when the
+ revision specified by the revno is only present in the fallback
+ repository.
+
+ See <https://launchpad.net/bugs/380314>
+ """
+ self.setup_smart_server_with_call_log()
+ parent = self.make_branch_and_tree('parent', format='1.9')
+ parent.commit(message='first commit')
+ local = parent.bzrdir.sprout('local').open_workingtree()
+ local.commit(message='local commit')
+ local.branch.create_clone_on_transport(
+ self.get_transport('stacked'), stacked_on=self.get_url('parent'))
+ empty = self.make_branch_and_tree('empty', format='1.9')
+ self.reset_smart_call_log()
+ self.run_bzr(['pull', '-r', '1', self.get_url('stacked')],
+ working_dir='empty')
+ # This figure represent the amount of work to perform this use case. It
+ # is entirely ok to reduce this number if a test fails due to rpc_count
+ # being too low. If rpc_count increases, more network roundtrips have
+ # become necessary for this use case. Please do not adjust this number
+ # upwards without agreement from bzr's network support maintainers.
+ self.assertLength(43, self.hpss_calls)
+ remote = Branch.open('stacked')
+ self.assertEndsWith(remote.get_stacked_on_url(), '/parent')
+
=== modified file 'bzrlib/tests/branch_implementations/test_stacking.py'
--- a/bzrlib/tests/branch_implementations/test_stacking.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/branch_implementations/test_stacking.py 2009-06-11 07:43:56 +0000
@@ -421,6 +421,31 @@
# Ensure that opening the branch doesn't raise.
branch.Branch.open(transport.base)
+ def test_revision_history_of_stacked(self):
+ # See <https://launchpad.net/bugs/380314>.
+ stack_on = self.make_branch_and_tree('stack-on')
+ stack_on.commit('first commit', rev_id='rev1')
+ try:
+ stacked_dir = stack_on.bzrdir.sprout(
+ self.get_url('stacked'), stacked=True)
+ except unstackable_format_errors, e:
+ raise TestNotApplicable('Format does not support stacking.')
+ try:
+ stacked = stacked_dir.open_workingtree()
+ except errors.NoWorkingTree:
+ stacked = stacked_dir.open_branch().create_checkout(
+ 'stacked-checkout', lightweight=True)
+ stacked.commit('second commit', rev_id='rev2')
+ # Sanity check: stacked's repo should not contain rev1, otherwise this
+ # test isn't testing what it's supposed to.
+ repo = stacked.branch.repository.bzrdir.open_repository()
+ repo.lock_read()
+ self.addCleanup(repo.unlock)
+ self.assertEqual({}, repo.get_parent_map(['rev1']))
+ # revision_history should work, even though the history is spread over
+ # multiple repositories.
+ self.assertLength(2, stacked.branch.revision_history())
+
class TestStackingConnections(
transport_util.TestCaseWithConnectionHookedTransport):
More information about the bazaar-commits
mailing list