Rev 2690: Allow omitting -o for bundle, add --format in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Aug 9 16:19:11 BST 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 2690
revision-id: pqm at pqm.ubuntu.com-20070809151906-hdn9oyslf2qib2op
parent: pqm at pqm.ubuntu.com-20070809063601-esywbsbqp7zcs4x9
parent: abentley at panoramicfeedback.com-20070809143455-3tkkwfjba2de78cu
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2007-08-09 16:19:06 +0100
message:
Allow omitting -o for bundle, add --format
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/option.py option.py-20051014052914-661fb36e76e7362f
bzrlib/tests/blackbox/test_send.py test_bundle.py-20060616222707-c21c8b7ea5ef57b1
bzrlib/tests/test_options.py testoptions.py-20051014093702-96457cfc86319a8f
------------------------------------------------------------
revno: 2681.1.7
merged: abentley at panoramicfeedback.com-20070809143455-3tkkwfjba2de78cu
parent: aaron.bentley at utoronto.ca-20070809052924-ajaufw1758hs8n0n
committer: Aaron Bentley <abentley at panoramicfeedback.com>
branch nick: send-bundle
timestamp: Thu 2007-08-09 10:34:55 -0400
message:
Fix option grammar
------------------------------------------------------------
revno: 2681.1.6
merged: aaron.bentley at utoronto.ca-20070809052924-ajaufw1758hs8n0n
parent: aaron.bentley at utoronto.ca-20070809051653-cal7k9ih3e37f7ip
committer: Aaron Bentley <aaron.bentley at utoronto.ca>
branch nick: send-bundle
timestamp: Thu 2007-08-09 01:29:24 -0400
message:
Update help to describe available formats
------------------------------------------------------------
revno: 2681.1.5
merged: aaron.bentley at utoronto.ca-20070809051653-cal7k9ih3e37f7ip
parent: aaron.bentley at utoronto.ca-20070809050103-flwt9g996msssq9u
committer: Aaron Bentley <aaron.bentley at utoronto.ca>
branch nick: send-bundle
timestamp: Thu 2007-08-09 01:16:53 -0400
message:
Display correct help message in from_kwargs
------------------------------------------------------------
revno: 2681.1.4
merged: aaron.bentley at utoronto.ca-20070809050103-flwt9g996msssq9u
parent: aaron.bentley at utoronto.ca-20070809045442-8himzbkqth0y5924
committer: Aaron Bentley <aaron.bentley at utoronto.ca>
branch nick: send-bundle
timestamp: Thu 2007-08-09 01:01:03 -0400
message:
Fix reference to told submit command
------------------------------------------------------------
revno: 2681.1.3
merged: aaron.bentley at utoronto.ca-20070809045442-8himzbkqth0y5924
parent: aaron.bentley at utoronto.ca-20070808063055-bh56b51f3vai83n6
committer: Aaron Bentley <aaron.bentley at utoronto.ca>
branch nick: send-bundle
timestamp: Thu 2007-08-09 00:54:42 -0400
message:
Ensure that a format 0.9 bundle is generated
------------------------------------------------------------
revno: 2681.1.2
merged: aaron.bentley at utoronto.ca-20070808063055-bh56b51f3vai83n6
parent: aaron.bentley at utoronto.ca-20070808044010-7swp1274oszh7pbe
committer: Aaron Bentley <aaron.bentley at utoronto.ca>
branch nick: send-bundle
timestamp: Wed 2007-08-08 02:30:55 -0400
message:
Add support for selecting bundle format
------------------------------------------------------------
revno: 2681.1.1
merged: aaron.bentley at utoronto.ca-20070808044010-7swp1274oszh7pbe
parent: pqm at pqm.ubuntu.com-20070807225230-7gb6fot3mnsxp7zs
committer: Aaron Bentley <aaron.bentley at utoronto.ca>
branch nick: send-bundle
timestamp: Wed 2007-08-08 00:40:10 -0400
message:
Split 'send' into 'send' and 'bundle'.
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2007-08-09 05:56:20 +0000
+++ b/bzrlib/builtins.py 2007-08-09 15:19:06 +0000
@@ -1085,7 +1085,7 @@
takes_options = ['verbose',
Option('new', help='Remove newly-added files.'),
RegistryOption.from_kwargs('file-deletion-strategy',
- 'The file deletion mode to be used',
+ 'The file deletion mode to be used.',
title='Deletion Strategy', value_switches=True, enum_switch=False,
safe='Only delete files if they can be'
' safely recovered (default).',
@@ -3697,11 +3697,11 @@
hidden = True
- _see_also = ['submit']
+ _see_also = ['send']
takes_options = [
RegistryOption.from_kwargs('patch-type',
- 'The type of patch to include in the directive',
+ 'The type of patch to include in the directive.',
title='Patch type',
value_switches=True,
enum_switch=False,
@@ -3801,12 +3801,16 @@
branch is used in the merge instructions. This means that a local mirror
can be used as your actual submit branch, once you have set public_branch
for that mirror.
+
+ Two formats are currently supported: "4" uses revision bundle format 4 and
+ merge directive format 2. It is significantly faster and smaller than
+ older formats. It is compatible with Bazaar 0.19 and later. It is the
+ default. "0.9" uses revision bundle format 0.9 and merge directive
+ format 1. It is compatible with Bazaar 0.12 - 0.18.
"""
encoding_type = 'exact'
- aliases = ['bundle', 'bundle-revisions']
-
_see_also = ['merge']
takes_args = ['submit_branch?', 'public_branch?']
@@ -3826,21 +3830,30 @@
Option('output', short_name='o', help='Write directive to this file.',
type=unicode),
'revision',
+ RegistryOption.from_kwargs('format',
+ 'Use the specified output format.',
+ **{'4': 'Bundle format 4, Merge Directive 2 (default)',
+ '0.9': 'Bundle format 0.9, Merge Directive 1',})
]
def run(self, submit_branch=None, public_branch=None, no_bundle=False,
no_patch=False, revision=None, remember=False, output=None,
- **kwargs):
- from bzrlib.revision import ensure_null, NULL_REVISION
+ format='4', **kwargs):
if output is None:
raise errors.BzrCommandError('File must be specified with'
' --output')
- elif output == '-':
+ return self._run(submit_branch, revision, public_branch, remember,
+ format, no_bundle, no_patch, output,
+ kwargs.get('from', '.'))
+
+ def _run(self, submit_branch, revision, public_branch, remember, format,
+ no_bundle, no_patch, output, from_,):
+ from bzrlib.revision import ensure_null, NULL_REVISION
+ if output == '-':
outfile = self.outf
else:
outfile = open(output, 'wb')
try:
- from_ = kwargs.get('from', '.')
branch = Branch.open_containing(from_)[0]
if remember and submit_branch is None:
raise errors.BzrCommandError(
@@ -3884,18 +3897,87 @@
revision_id = ensure_null(revision_id)
if revision_id == NULL_REVISION:
raise errors.BzrCommandError('No revisions to submit.')
- directive = 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,
- include_bundle=not no_bundle, message=None,
- base_revision_id=base_revision_id)
+ if format == '4':
+ directive = 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,
+ include_bundle=not no_bundle, message=None,
+ base_revision_id=base_revision_id)
+ elif format == '0.9':
+ if not no_bundle:
+ if not no_patch:
+ patch_type = 'bundle'
+ else:
+ raise errors.BzrCommandError('Format 0.9 does not'
+ ' permit bundle with no patch')
+ else:
+ if not no_patch:
+ patch_type = 'diff'
+ else:
+ patch_type = None
+ directive = merge_directive.MergeDirective.from_objects(
+ branch.repository, revision_id, time.time(),
+ osutils.local_time_offset(), submit_branch,
+ public_branch=public_branch, patch_type=patch_type,
+ message=None)
+
outfile.writelines(directive.to_lines())
finally:
if output != '-':
outfile.close()
+class cmd_bundle_revisions(cmd_send):
+
+ """Create a merge-directive for submiting changes.
+
+ A merge directive provides many things needed for requesting merges:
+
+ * A machine-readable description of the merge to perform
+
+ * An optional patch that is a preview of the changes requested
+
+ * An optional bundle of revision data, so that the changes can be applied
+ directly from the merge directive, without retrieving data from a
+ branch.
+
+ If --no-bundle is specified, then public_branch is needed (and must be
+ up-to-date), so that the receiver can perform the merge using the
+ public_branch. The public_branch is always included if known, so that
+ people can check it later.
+
+ The submit branch defaults to the parent, but can be overridden. Both
+ submit branch and public branch will be remembered if supplied.
+
+ If a public_branch is known for the submit_branch, that public submit
+ branch is used in the merge instructions. This means that a local mirror
+ can be used as your actual submit branch, once you have set public_branch
+ for that mirror.
+
+ Two formats are currently supported: "4" uses revision bundle format 4 and
+ merge directive format 2. It is significantly faster and smaller than
+ older formats. It is compatible with Bazaar 0.19 and later. It is the
+ default. "0.9" uses revision bundle format 0.9 and merge directive
+ format 1. It is compatible with Bazaar 0.12 - 0.18.
+ """
+
+ aliases = ['bundle']
+
+ _see_also = ['send', 'merge']
+
+ hidden = True
+
+ def run(self, submit_branch=None, public_branch=None, no_bundle=False,
+ no_patch=False, revision=None, remember=False, output=None,
+ format='4', **kwargs):
+ if output is None:
+ output = '-'
+ return self._run(submit_branch, revision, public_branch, remember,
+ format, no_bundle, no_patch, output,
+ kwargs.get('from', '.'))
+
+
class cmd_tag(Command):
"""Create, remove or modify a tag naming a revision.
=== modified file 'bzrlib/option.py'
--- a/bzrlib/option.py 2007-07-13 04:41:55 +0000
+++ b/bzrlib/option.py 2007-08-09 05:16:53 +0000
@@ -285,9 +285,9 @@
as values for the option, and they value is treated as the help.
"""
reg = registry.Registry()
- for name, help in kwargs.iteritems():
+ for name, switch_help in kwargs.iteritems():
name = name.replace('_', '-')
- reg.register(name, name, help=help)
+ reg.register(name, name, help=switch_help)
return RegistryOption(name_, help, reg, title=title,
value_switches=value_switches, enum_switch=enum_switch)
=== modified file 'bzrlib/tests/blackbox/test_send.py'
--- a/bzrlib/tests/blackbox/test_send.py 2007-07-31 02:58:48 +0000
+++ b/bzrlib/tests/blackbox/test_send.py 2007-08-09 04:54:42 +0000
@@ -34,11 +34,14 @@
def make_trees(self):
grandparent_tree = BzrDir.create_standalone_workingtree('grandparent')
+ self.build_tree_contents([('grandparent/file1', 'grandparent')])
+ grandparent_tree.add('file1')
grandparent_tree.commit('initial commit', rev_id='revision1')
parent_bzrdir = grandparent_tree.bzrdir.sprout('parent')
parent_tree = parent_bzrdir.open_workingtree()
parent_tree.commit('next commit', rev_id='revision2')
branch_tree = parent_tree.bzrdir.sprout('branch').open_workingtree()
+ self.build_tree_contents([('branch/file1', 'branch')])
branch_tree.commit('last commit', rev_id='revision3')
def test_uses_parent(self):
@@ -53,6 +56,18 @@
br = read_bundle(StringIO(stdout))
self.assertRevisions(br, ['revision3'])
+ def test_bundle(self):
+ """Bundle works like send, except -o is not required"""
+ self.make_trees()
+ os.chdir('grandparent')
+ errmsg = self.run_bzr('bundle', retcode=3)[1]
+ self.assertContainsRe(errmsg, 'No submit branch known or specified')
+ os.chdir('../branch')
+ stdout, stderr = self.run_bzr('bundle')
+ self.assertEqual(stderr.count('Using saved location'), 1)
+ br = read_bundle(StringIO(stdout))
+ self.assertRevisions(br, ['revision3'])
+
def assertRevisions(self, bi, expected):
self.assertEqual(set(r.revision_id for r in bi.revisions),
set(expected))
@@ -124,16 +139,35 @@
md = self.send_directive([])
self.assertIsNot(None, md.bundle)
self.assertIsNot(None, md.patch)
+
+ md = self.send_directive(['--format=0.9'])
+ self.assertIsNot(None, md.bundle)
+ self.assertIsNot(None, md.patch)
+
md = self.send_directive(['--no-patch'])
self.assertIsNot(None, md.bundle)
self.assertIs(None, md.patch)
+ self.run_bzr_error(['Format 0.9 does not permit bundle with no patch'],
+ 'send --no-patch --format=0.9 -o-')
+
md = self.send_directive(['--no-bundle', '.', '.'])
self.assertIs(None, md.bundle)
self.assertIsNot(None, md.patch)
+
+ md = self.send_directive(['--no-bundle', '--format=0.9', '../parent',
+ '.'])
+ self.assertIs(None, md.bundle)
+ self.assertIsNot(None, md.patch)
+
md = self.send_directive(['--no-bundle', '--no-patch', '.', '.'])
self.assertIs(None, md.bundle)
self.assertIs(None, md.patch)
+ md = self.send_directive(['--no-bundle', '--no-patch', '--format=0.9',
+ '../parent', '.'])
+ self.assertIs(None, md.bundle)
+ self.assertIs(None, md.patch)
+
def test_from_option(self):
self.make_trees()
self.run_bzr('send', retcode=3)
@@ -156,3 +190,20 @@
self.make_trees()
self.run_bzr_error(('File must be specified with --output',),
'send -f branch')
+
+ def test_format(self):
+ self.make_trees()
+ s = StringIO(self.run_bzr('send -f branch -o- --format=4')[0])
+ md = merge_directive.MergeDirective.from_lines(s.readlines())
+ self.assertIs(merge_directive.MergeDirective2, md.__class__)
+ s = StringIO(self.run_bzr('send -f branch -o- --format=0.9')[0])
+ md = merge_directive.MergeDirective.from_lines(s.readlines())
+ self.assertContainsRe(md.get_raw_bundle().splitlines()[0],
+ '# Bazaar revision bundle v0.9')
+ s = StringIO(self.run_bzr('bundle -f branch -o- --format=0.9')[0])
+ md = merge_directive.MergeDirective.from_lines(s.readlines())
+ self.assertContainsRe(md.get_raw_bundle().splitlines()[0],
+ '# Bazaar revision bundle v0.9')
+ self.assertIs(merge_directive.MergeDirective, md.__class__)
+ self.run_bzr_error(['Bad value .* for option .format.'],
+ 'send -f branch -o- --format=0.999')[0]
=== modified file 'bzrlib/tests/test_options.py'
--- a/bzrlib/tests/test_options.py 2007-07-13 04:41:55 +0000
+++ b/bzrlib/tests/test_options.py 2007-08-09 05:16:53 +0000
@@ -151,6 +151,7 @@
be_long='go long', value_switches=True)
self.assertEqual(['my-option', 'be-long', 'short'],
[x[0] for x in my_option.iter_switches()])
+ self.assertEqual('test option', my_option.help)
def test_help(self):
registry = bzrdir.BzrDirFormatRegistry()
More information about the bazaar-commits
mailing list