3819
3819
can be used as your actual submit branch, once you have set public_branch
3820
3820
for that mirror.
3822
Mail is sent using your preferred mail program. This should be transparent
3823
on Windows (it uses MAPI). On *nix, it requires the xdg-email utility. If
3824
the preferred client can't be found (or used), your editor will be used.
3826
To use a specific mail program, set the mail_client configuration option.
3827
(For Thunderbird 1.5, this works around some bugs.) Supported values are
3828
"thunderbird", "evolution", "editor", "xdg-email", "mapi", "kmail" and
3831
If mail is being sent, a to address is required. This can be supplied
3832
either on the commandline, or by setting the submit_to configuration
3822
3835
Two formats are currently supported: "4" uses revision bundle format 4 and
3823
3836
merge directive format 2. It is significantly faster and smaller than
3824
3837
older formats. It is compatible with Bazaar 0.19 and later. It is the
3847
3860
Option('output', short_name='o', help='Write directive to this file.',
3862
Option('mail-to', help='Mail the request to this address.',
3850
3866
RegistryOption.from_kwargs('format',
3851
3867
'Use the specified output format.',
3852
3868
**{'4': 'Bundle format 4, Merge Directive 2 (default)',
3856
3872
def run(self, submit_branch=None, public_branch=None, no_bundle=False,
3857
3873
no_patch=False, revision=None, remember=False, output=None,
3858
format='4', **kwargs):
3860
raise errors.BzrCommandError('File must be specified with'
3874
format='4', mail_to=None, message=None, **kwargs):
3862
3875
return self._run(submit_branch, revision, public_branch, remember,
3863
3876
format, no_bundle, no_patch, output,
3864
kwargs.get('from', '.'))
3877
kwargs.get('from', '.'), mail_to, message)
3866
3879
def _run(self, submit_branch, revision, public_branch, remember, format,
3867
no_bundle, no_patch, output, from_,):
3880
no_bundle, no_patch, output, from_, mail_to, message):
3868
3881
from bzrlib.revision import ensure_null, NULL_REVISION
3883
outfile = StringIO()
3870
3885
outfile = self.outf
3872
3887
outfile = open(output, 'wb')
3874
3889
branch = Branch.open_containing(from_)[0]
3891
config = branch.get_config()
3893
mail_to = config.get_user_option('submit_to')
3895
raise errors.BzrCommandError('No mail-to address'
3897
mail_client = config.get_mail_client()
3875
3898
if remember and submit_branch is None:
3876
3899
raise errors.BzrCommandError(
3877
3900
'--remember requires a branch to be specified.')
3919
3942
branch.repository, revision_id, time.time(),
3920
3943
osutils.local_time_offset(), submit_branch,
3921
3944
public_branch=public_branch, include_patch=not no_patch,
3922
include_bundle=not no_bundle, message=None,
3945
include_bundle=not no_bundle, message=message,
3923
3946
base_revision_id=base_revision_id)
3924
3947
elif format == '0.9':
3925
3948
if not no_bundle:
3937
3960
branch.repository, revision_id, time.time(),
3938
3961
osutils.local_time_offset(), submit_branch,
3939
3962
public_branch=public_branch, patch_type=patch_type,
3942
3965
outfile.writelines(directive.to_lines())
3967
subject = '[MERGE] '
3968
if message is not None:
3971
revision = branch.repository.get_revision(revision_id)
3972
subject += revision.get_summary()
3973
mail_client.compose_merge_request(mail_to, subject,
3944
3976
if output != '-':
3945
3977
outfile.close()
3979
4011
format 1. It is compatible with Bazaar 0.12 - 0.18.
4016
help='Do not include a bundle in the merge directive.'),
4017
Option('no-patch', help='Do not include a preview patch in the merge'
4020
help='Remember submit and public branch.'),
4022
help='Branch to generate the submission from, '
4023
'rather than the one containing the working directory.',
4026
Option('output', short_name='o', help='Write directive to this file.',
4029
RegistryOption.from_kwargs('format',
4030
'Use the specified output format.',
4031
**{'4': 'Bundle format 4, Merge Directive 2 (default)',
4032
'0.9': 'Bundle format 0.9, Merge Directive 1',})
3982
4034
aliases = ['bundle']
3984
4036
_see_also = ['send', 'merge']
3993
4045
return self._run(submit_branch, revision, public_branch, remember,
3994
4046
format, no_bundle, no_patch, output,
3995
kwargs.get('from', '.'))
4047
kwargs.get('from', '.'), None, None)
3998
4050
class cmd_tag(Command):