Rev 3213: Merge RemoteBzrDir._get_tree_branch. in http://people.ubuntu.com/~robertc/baz2.0/search-results
Robert Collins
robertc at robertcollins.net
Mon Feb 4 03:58:26 GMT 2008
At http://people.ubuntu.com/~robertc/baz2.0/search-results
------------------------------------------------------------
revno: 3213
revision-id:robertc at robertcollins.net-20080204035820-reho5s4y0hzcpcl9
parent: robertc at robertcollins.net-20080203225508-0rogbg0ggonuqfhp
parent: robertc at robertcollins.net-20080204035039-gdwcyz8gopti4r0l
committer: Robert Collins <robertc at robertcollins.net>
branch nick: RemoteBzrDir._get_tree_branch
timestamp: Mon 2008-02-04 14:58:20 +1100
message:
Merge RemoteBzrDir._get_tree_branch.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
------------------------------------------------------------
revno: 3211.1.1
revision-id:robertc at robertcollins.net-20080204035039-gdwcyz8gopti4r0l
parent: pqm at pqm.ubuntu.com-20080201053934-q32y2nk5vvo13c6v
committer: Robert Collins <robertc at robertcollins.net>
branch nick: RemoteBzrDir._get_tree_branch
timestamp: Mon 2008-02-04 14:50:39 +1100
message:
* ``RemoteBzrDir._get_tree_branch`` no longer triggers ``_ensure_real``,
removing one round trip on many network operations. (Robert Collins)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
=== modified file 'NEWS'
--- a/NEWS 2008-02-03 22:55:08 +0000
+++ b/NEWS 2008-02-04 03:58:20 +0000
@@ -142,6 +142,9 @@
``Repository.get_data_stream_for_search`` which allows less network
traffic when requesting data streams over a smart server. (Robert Collins)
+ * ``RemoteBzrDir._get_tree_branch`` no longer triggers ``_ensure_real``,
+ removing one round trip on many network operations. (Robert Collins)
+
* Repository has a new method ``has_revisions`` which signals the presence
of many revisions by returning a set of the revisions listed which are
present. This can be done by index queries without reading data for parent
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py 2008-01-17 13:45:16 +0000
+++ b/bzrlib/bzrdir.py 2008-02-04 03:50:39 +0000
@@ -748,7 +748,7 @@
def _get_tree_branch(self):
"""Return the branch and tree, if any, for this bzrdir.
- Return None for tree if not present.
+ Return None for tree if not present or inaccessible.
Raise NotBranchError if no branch is present.
:return: (tree, branch)
"""
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2008-02-03 22:55:08 +0000
+++ b/bzrlib/remote.py 2008-02-04 03:58:20 +0000
@@ -131,6 +131,10 @@
else:
raise errors.UnexpectedSmartServerResponse(response)
+ def _get_tree_branch(self):
+ """See BzrDir._get_tree_branch()."""
+ return None, self.open_branch()
+
def open_branch(self, _unsupported=False):
assert _unsupported == False, 'unsupported flag support not implemented yet.'
reference_url = self.get_branch_reference()
=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py 2008-02-03 22:55:08 +0000
+++ b/bzrlib/tests/test_remote.py 2008-02-04 03:58:20 +0000
@@ -207,6 +207,23 @@
[('call', 'BzrDir.open_branch', ('quack/',))],
client._calls)
+ def test__get_tree_branch(self):
+ # _get_tree_branch is a form of open_branch, but it should only ask for
+ # branch opening, not any other network requests.
+ calls = []
+ def open_branch():
+ calls.append("Called")
+ return "a-branch"
+ transport = MemoryTransport()
+ # no requests on the network - catches other api calls being made.
+ client = FakeClient([], transport.base)
+ bzrdir = RemoteBzrDir(transport, _client=client)
+ # patch the open_branch call to record that it was called.
+ bzrdir.open_branch = open_branch
+ self.assertEqual((None, "a-branch"), bzrdir._get_tree_branch())
+ self.assertEqual(["Called"], calls)
+ self.assertEqual([], client._calls)
+
def test_url_quoting_of_path(self):
# Relpaths on the wire should not be URL-escaped. So "~" should be
# transmitted as "~", not "%7E".
More information about the bazaar-commits
mailing list