Rev 6368: (jelmer) Only make a single connection to the submit branch in 'bzr send'. in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Dec 14 18:42:02 UTC 2011
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6368 [merge]
revision-id: pqm at pqm.ubuntu.com-20111214184202-r0x5y7oe5h6rz72w
parent: pqm at pqm.ubuntu.com-20111214173258-gt3ywqak3no5ybo0
parent: jelmer at samba.org-20111214181419-sup6int3bfb3eup8
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2011-12-14 18:42:02 +0000
message:
(jelmer) Only make a single connection to the submit branch in 'bzr send'.
(Jelmer Vernooij)
modified:
bzrlib/merge_directive.py merge_directive.py-20070228184838-ja62280spt1g7f4x-1
bzrlib/send.py send.py-20090521192735-j7cdb33ykmtmzx4w-1
bzrlib/tests/blackbox/test_send.py test_bundle.py-20060616222707-c21c8b7ea5ef57b1
doc/en/release-notes/bzr-2.5.txt bzr2.5.txt-20110708125756-587p0hpw7oke4h05-1
=== modified file 'bzrlib/merge_directive.py'
--- a/bzrlib/merge_directive.py 2011-04-07 10:36:24 +0000
+++ b/bzrlib/merge_directive.py 2011-12-14 18:03:06 +0000
@@ -82,8 +82,8 @@
multiple_output_files = False
def __init__(self, revision_id, testament_sha1, time, timezone,
- target_branch, patch=None, source_branch=None, message=None,
- bundle=None):
+ target_branch, patch=None, source_branch=None,
+ message=None, bundle=None):
"""Constructor.
:param revision_id: The revision to merge
@@ -91,7 +91,7 @@
merge.
:param time: The current POSIX timestamp time
:param timezone: The timezone offset
- :param target_branch: The branch to apply the merge to
+ :param target_branch: Location of branch to apply the merge to
:param patch: The text of a diff or bundle
:param source_branch: A public location to merge the revision from
:param message: The message to use when committing this merge
@@ -165,9 +165,9 @@
:param target_branch: The url of the branch to merge into
:param patch_type: 'bundle', 'diff' or None, depending on the type of
patch desired.
- :param local_target_branch: a local copy of the target branch
- :param public_branch: location of a public branch containing the target
- revision.
+ :param local_target_branch: the submit branch, either itself or a local copy
+ :param public_branch: location of a public branch containing
+ the target revision.
:param message: Message to use when committing the merge
:return: The merge directive
@@ -181,7 +181,10 @@
if revision_id == _mod_revision.NULL_REVISION:
t_revision_id = None
t = testament.StrictTestament3.from_revision(repository, t_revision_id)
- submit_branch = _mod_branch.Branch.open(target_branch)
+ if local_target_branch is None:
+ submit_branch = _mod_branch.Branch.open(target_branch)
+ else:
+ submit_branch = local_target_branch
if submit_branch.get_public_branch() is not None:
target_branch = submit_branch.get_public_branch()
if patch_type is None:
@@ -373,7 +376,7 @@
merge.
:param time: The current POSIX timestamp time
:param timezone: The timezone offset
- :param target_branch: The branch to apply the merge to
+ :param target_branch: Location of the branch to apply the merge to
:param patch: The text of a diff or bundle
:param patch_type: None, "diff" or "bundle", depending on the contents
of patch
@@ -567,9 +570,9 @@
:param target_branch: The url of the branch to merge into
:param include_patch: If true, include a preview patch
:param include_bundle: If true, include a bundle
- :param local_target_branch: a local copy of the target branch
- :param public_branch: location of a public branch containing the target
- revision.
+ :param local_target_branch: the target branch, either itself or a local copy
+ :param public_branch: location of a public branch containing
+ the target revision.
:param message: Message to use when committing the merge
:return: The merge directive
@@ -588,7 +591,10 @@
t_revision_id = None
t = testament.StrictTestament3.from_revision(repository,
t_revision_id)
- submit_branch = _mod_branch.Branch.open(target_branch)
+ if local_target_branch is None:
+ submit_branch = _mod_branch.Branch.open(target_branch)
+ else:
+ submit_branch = local_target_branch
submit_branch.lock_read()
locked.append(submit_branch)
if submit_branch.get_public_branch() is not None:
=== modified file 'bzrlib/send.py'
--- a/bzrlib/send.py 2011-10-11 12:01:51 +0000
+++ b/bzrlib/send.py 2011-12-14 16:10:52 +0000
@@ -37,11 +37,12 @@
format_registry = registry.Registry()
-def send(submit_branch, revision, public_branch, remember, format,
- no_bundle, no_patch, output, from_, mail_to, message, body,
+def send(target_branch, revision, public_branch, remember,
+ format, no_bundle, no_patch, output, from_, mail_to, message, body,
to_file, strict=None):
tree, branch = controldir.ControlDir.open_containing_tree_or_branch(
from_)[:2]
+ possible_transports = [tree.bzrdir.transport, branch.bzrdir.transport]
# we may need to write data into branch's repository to calculate
# the data to send.
branch.lock_write()
@@ -56,39 +57,40 @@
raise errors.BzrCommandError(gettext(
'Mail client "%s" does not support specifying body') %
mail_client.__class__.__name__)
- if remember and submit_branch is None:
+ if remember and target_branch is None:
raise errors.BzrCommandError(gettext(
'--remember requires a branch to be specified.'))
- stored_submit_branch = branch.get_submit_branch()
- remembered_submit_branch = None
- if submit_branch is None:
- submit_branch = stored_submit_branch
- remembered_submit_branch = "submit"
+ stored_target_branch = branch.get_submit_branch()
+ remembered_target_branch = None
+ if target_branch is None:
+ target_branch = stored_target_branch
+ remembered_target_branch = "submit"
else:
# Remembers if asked explicitly or no previous location is set
- if remember or (remember is None and stored_submit_branch is None):
- branch.set_submit_branch(submit_branch)
- if submit_branch is None:
- submit_branch = branch.get_parent()
- remembered_submit_branch = "parent"
- if submit_branch is None:
+ if remember or (
+ remember is None and stored_target_branch is None):
+ branch.set_submit_branch(target_branch)
+ if target_branch is None:
+ target_branch = branch.get_parent()
+ remembered_target_branch = "parent"
+ if target_branch is None:
raise errors.BzrCommandError(gettext('No submit branch known or'
' specified'))
- if remembered_submit_branch is not None:
+ if remembered_target_branch is not None:
trace.note(gettext('Using saved {0} location "{1}" to determine '
'what changes to submit.').format(
- remembered_submit_branch, submit_branch))
+ remembered_target_branch,
+ target_branch))
+ submit_branch = Branch.open(target_branch,
+ possible_transports=possible_transports)
+ possible_transports.append(submit_branch.bzrdir.root_transport)
if mail_to is None or format is None:
- # TODO: jam 20090716 we open the submit_branch here, but we *don't*
- # pass it down into the format creation, so it will have to
- # open it again
- submit_br = Branch.open(submit_branch)
- submit_config = submit_br.get_config()
+ submit_config = submit_branch.get_config()
if mail_to is None:
mail_to = submit_config.get_user_option("child_submit_to")
if format is None:
- formatname = submit_br.get_child_submit_format()
+ formatname = submit_branch.get_child_submit_format()
try:
format = format_registry.get(formatname)
except KeyError:
@@ -125,8 +127,9 @@
raise errors.BzrCommandError(gettext('No revisions to submit.'))
if format is None:
format = format_registry.get()
- directive = format(branch, revision_id, submit_branch,
- public_branch, no_patch, no_bundle, message, base_revision_id)
+ directive = format(branch, revision_id, target_branch,
+ public_branch, no_patch, no_bundle, message, base_revision_id,
+ submit_branch)
if output is None:
directive.compose_merge_request(mail_client, mail_to, body,
branch, tree)
@@ -158,19 +161,23 @@
branch.unlock()
-def _send_4(branch, revision_id, submit_branch, public_branch,
- no_patch, no_bundle, message, base_revision_id):
+def _send_4(branch, revision_id, target_branch, public_branch,
+ no_patch, no_bundle, message,
+ base_revision_id, local_target_branch=None):
from bzrlib import merge_directive
return merge_directive.MergeDirective2.from_objects(
branch.repository, revision_id, time.time(),
- osutils.local_time_offset(), submit_branch,
- public_branch=public_branch, include_patch=not no_patch,
+ osutils.local_time_offset(), target_branch,
+ public_branch=public_branch,
+ include_patch=not no_patch,
include_bundle=not no_bundle, message=message,
- base_revision_id=base_revision_id)
+ base_revision_id=base_revision_id,
+ local_target_branch=local_target_branch)
def _send_0_9(branch, revision_id, submit_branch, public_branch,
- no_patch, no_bundle, message, base_revision_id):
+ no_patch, no_bundle, message,
+ base_revision_id, local_target_branch=None):
if not no_bundle:
if not no_patch:
patch_type = 'bundle'
@@ -187,10 +194,10 @@
branch.repository, revision_id, time.time(),
osutils.local_time_offset(), submit_branch,
public_branch=public_branch, patch_type=patch_type,
- message=message)
-
-
-format_registry.register('4',
+ message=message, local_target_branch=local_target_branch)
+
+
+format_registry.register('4',
_send_4, 'Bundle format 4, Merge Directive 2 (default)')
format_registry.register('0.9',
_send_0_9, 'Bundle format 0.9, Merge Directive 1')
=== modified file 'bzrlib/tests/blackbox/test_send.py'
--- a/bzrlib/tests/blackbox/test_send.py 2011-09-22 12:13:12 +0000
+++ b/bzrlib/tests/blackbox/test_send.py 2011-12-14 15:47:45 +0000
@@ -16,7 +16,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-import sys
from cStringIO import StringIO
from bzrlib import (
@@ -29,8 +28,8 @@
from bzrlib.transport import memory
from bzrlib.tests import (
scenarios,
- script,
)
+from bzrlib.tests.matchers import ContainsNoVfsCalls
load_tests = scenarios.load_tests_apply_scenarios
@@ -439,3 +438,26 @@
class TestBundleStrictWithoutChanges(TestSendStrictWithoutChanges):
_default_command = ['bundle-revisions', '../parent']
+
+
+class TestSmartServerSend(tests.TestCaseWithTransport):
+
+ def test_send(self):
+ self.setup_smart_server_with_call_log()
+ t = self.make_branch_and_tree('branch')
+ self.build_tree_contents([('branch/foo', 'thecontents')])
+ t.add("foo")
+ t.commit("message")
+ local = t.bzrdir.sprout('local-branch').open_workingtree()
+ self.build_tree_contents([('branch/foo', 'thenewcontents')])
+ local.commit("anothermessage")
+ self.reset_smart_call_log()
+ out, err = self.run_bzr(
+ ['send', '-o', 'x.diff', self.get_url('branch')], working_dir='local-branch')
+ # 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(9, self.hpss_calls)
+ self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt 2011-12-14 17:32:58 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt 2011-12-14 18:14:19 +0000
@@ -41,6 +41,9 @@
will mean bzr works with non-ascii files when no locale or an incorrect
locale is set. (Martin Packman, #794353)
+* ``bzr send`` now only opens a single connection, rather than two,
+ to the target branch. (Jelmer Vernooij)
+
Bug Fixes
*********
@@ -67,6 +70,10 @@
.. Changes that may require updates in plugins or other code that uses
bzrlib.
+* Send formats now accept a new optional argument ``submit_branch``,
+ which can be None or a Branch object for the submit branch location.
+ (Jelmer Vernooij)
+
Internals
*********
More information about the bazaar-commits
mailing list