Rev 2808: Fix #128076 and #131396 by reusing bound branch transport. in file:///v/home/vila/src/bugs/128076/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Mon Sep 10 13:12:50 BST 2007
At file:///v/home/vila/src/bugs/128076/
------------------------------------------------------------
revno: 2808
revision-id: v.ladeuil+lp at free.fr-20070910121247-sxf4l4pq1e27380p
parent: v.ladeuil+lp at free.fr-20070910091350-mnrhuokhmj2vxim0
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 128076
timestamp: Mon 2007-09-10 14:12:47 +0200
message:
Fix #128076 and #131396 by reusing bound branch transport.
* bzrlib/bzrdir.py:
(BzrDir.open): Add possible_transports as the last parameter.
* bzrlib/builtins.py:
(cmd_update.run): Use possible_transports parameter to obtain the
master branch transport and reuse it.
* bzrlib/branch.py:
(Branch.open, Branch.get_master_branch,
BzrBranch5.get_master_branch, BzrBranch5.update): Add
possible_transports as the last parameter.
* bzrlib/workingtree.py:
(WorkingTree.update): Add possible_transports as the last parameter.
* bzrlib/tests/commands/test_update.py:
(TestUpdate.test_update): Ignore connections from bind.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/branch.py branch.py-20050309040759-e4baf4e0d046576e
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/tests/commands/test_update.py test_update.py-20070910091045-8uyp8v73j926l1g2-1
bzrlib/workingtree.py workingtree.py-20050511021032-29b6ec0a681e02e3
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS 2007-09-10 05:06:24 +0000
+++ b/NEWS 2007-09-10 12:12:47 +0000
@@ -126,6 +126,10 @@
* Prompt for an ftp password if none is provided.
(Vincent Ladeuil, #137044)
+ * Reuse bound branch associated transport to avoid multiple
+ connections.
+ (Vincent Ladeuil, #128076, #131396)
+
IMPROVEMENTS:
* Add the option "--show-diff" to the commit command in order to display
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2007-08-27 08:38:37 +0000
+++ b/bzrlib/branch.py 2007-09-10 12:12:47 +0000
@@ -117,13 +117,14 @@
master.break_lock()
@staticmethod
- def open(base, _unsupported=False):
+ def open(base, _unsupported=False, possible_transports=None):
"""Open the branch rooted at base.
For instance, if the branch is at URL/.bzr/branch,
Branch.open(URL) -> a Branch instance.
"""
- control = bzrdir.BzrDir.open(base, _unsupported)
+ control = bzrdir.BzrDir.open(base, _unsupported,
+ possible_transports=possible_transports)
return control.open_branch(_unsupported)
@staticmethod
@@ -320,7 +321,7 @@
return self.repository.get_commit_builder(self, parents, config,
timestamp, timezone, committer, revprops, revision_id)
- def get_master_branch(self):
+ def get_master_branch(self, possible_transport=None):
"""Return the branch we are bound to.
:return: Either a Branch, or None
@@ -1648,7 +1649,7 @@
class BzrBranch5(BzrBranch):
- """A format 5 branch. This supports new features over plan branches.
+ """A format 5 branch. This supports new features over plain branches.
It has support for a master_branch which is the data for bound branches.
"""
@@ -1697,7 +1698,7 @@
return None
@needs_read_lock
- def get_master_branch(self):
+ def get_master_branch(self, possible_transports=None):
"""Return the branch we are bound to.
:return: Either a Branch, or None
@@ -1711,7 +1712,8 @@
if not bound_loc:
return None
try:
- return Branch.open(bound_loc)
+ return Branch.open(bound_loc,
+ possible_transports=possible_transports)
except (errors.NotBranchError, errors.ConnectionError), e:
raise errors.BoundBranchConnectionFailure(
self, bound_loc, e)
@@ -1779,13 +1781,13 @@
return self.set_bound_location(None)
@needs_write_lock
- def update(self):
+ def update(self, possible_transports=None):
"""Synchronise this branch with the master branch if any.
:return: None or the last_revision that was pivoted out during the
update.
"""
- master = self.get_master_branch()
+ master = self.get_master_branch(possible_transports)
if master is not None:
old_tip = _mod_revision.ensure_null(self.last_revision())
self.pull(master, overwrite=True)
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2007-09-10 02:18:14 +0000
+++ b/bzrlib/builtins.py 2007-09-10 12:12:47 +0000
@@ -1016,7 +1016,9 @@
def run(self, dir='.'):
tree = WorkingTree.open_containing(dir)[0]
- master = tree.branch.get_master_branch()
+ possible_transports = []
+ master = tree.branch.get_master_branch(
+ possible_transports=possible_transports)
if master is not None:
tree.lock_write()
else:
@@ -1032,8 +1034,9 @@
revno = tree.branch.revision_id_to_revno(last_rev)
note("Tree is up to date at revision %d." % (revno,))
return 0
- conflicts = tree.update(delta._ChangeReporter(
- unversioned_filter=tree.is_ignored))
+ conflicts = tree.update(
+ delta._ChangeReporter(unversioned_filter=tree.is_ignored),
+ possible_transports=possible_transports)
revno = tree.branch.revision_id_to_revno(
_mod_revision.ensure_null(tree.last_revision()))
note('Updated to revision %d.' % (revno,))
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py 2007-09-05 03:20:26 +0000
+++ b/bzrlib/bzrdir.py 2007-09-10 12:12:47 +0000
@@ -533,12 +533,12 @@
return BzrDir.open(base, _unsupported=True)
@staticmethod
- def open(base, _unsupported=False):
+ def open(base, _unsupported=False, possible_transports=None):
"""Open an existing bzrdir, rooted at 'base' (url)
_unsupported is a private parameter to the BzrDir class.
"""
- t = get_transport(base)
+ t = get_transport(base, possible_transports=possible_transports)
return BzrDir.open_from_transport(t, _unsupported=_unsupported)
@staticmethod
=== modified file 'bzrlib/tests/commands/test_update.py'
--- a/bzrlib/tests/commands/test_update.py 2007-09-10 09:13:50 +0000
+++ b/bzrlib/tests/commands/test_update.py 2007-09-10 12:12:47 +0000
@@ -29,11 +29,11 @@
wt1.commit('empty commit')
wt2.commit('empty commit too')
- self.install_hooks()
-
bind = builtins.cmd_bind()
bind.run(location=self.get_url('branch1'))
+ self.install_hooks()
+
update = builtins.cmd_update()
update.run()
self.assertEquals(1, len(self.connections))
=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py 2007-09-05 03:20:26 +0000
+++ b/bzrlib/workingtree.py 2007-09-10 12:12:47 +0000
@@ -2022,7 +2022,7 @@
"""
raise NotImplementedError(self.unlock)
- def update(self, change_reporter=None):
+ def update(self, change_reporter=None, possible_transports=None):
"""Update a working tree along its branch.
This will update the branch if its bound too, which means we have
@@ -2047,7 +2047,7 @@
basis.
- Do a 'normal' merge of the old branch basis if it is relevant.
"""
- if self.branch.get_master_branch() is not None:
+ if self.branch.get_master_branch(possible_transports) is not None:
self.lock_write()
update_branch = True
else:
@@ -2055,7 +2055,7 @@
update_branch = False
try:
if update_branch:
- old_tip = self.branch.update()
+ old_tip = self.branch.update(possible_transports)
else:
old_tip = None
return self._update_tree(old_tip, change_reporter)
More information about the bazaar-commits
mailing list