~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Aaron Bentley
  • Date: 2007-08-09 20:30:00 UTC
  • mto: (2681.5.3 bzr-mail)
  • mto: This revision was merged to the branch mainline in revision 2736.
  • Revision ID: abentley@panoramicfeedback.com-20070809203000-939mwp9uv19snzme
Add support for mail-from-editor

Show diffs side-by-side

added added

removed removed

Lines of Context:
3826
3826
               type=unicode),
3827
3827
        Option('output', short_name='o', help='Write directive to this file.',
3828
3828
               type=unicode),
 
3829
        Option('mail-to', help='Mail the request to this address',
 
3830
               type=unicode),
3829
3831
        'revision',
 
3832
        'message',
3830
3833
        RegistryOption.from_kwargs('format',
3831
3834
        'Use the specified output format.',
3832
3835
        **{'4': 'Bundle format 4, Merge Directive 2 (default)',
3835
3838
 
3836
3839
    def run(self, submit_branch=None, public_branch=None, no_bundle=False,
3837
3840
            no_patch=False, revision=None, remember=False, output=None,
3838
 
            format='4', **kwargs):
 
3841
            format='4', mail_to=None, message=None, **kwargs):
3839
3842
        return self._run(submit_branch, revision, public_branch, remember,
3840
3843
                         format, no_bundle, no_patch, output,
3841
 
                         kwargs.get('from', '.'))
 
3844
                         kwargs.get('from', '.'), mail_to, message)
3842
3845
 
3843
3846
    def _run(self, submit_branch, revision, public_branch, remember, format,
3844
 
             no_bundle, no_patch, output, from_,):
 
3847
             no_bundle, no_patch, output, from_, mail_to, message):
3845
3848
        from bzrlib.revision import ensure_null, NULL_REVISION
3846
3849
        if output is None:
 
3850
            if mail_to is None:
 
3851
                raise errors.BzrCommandError('No mail-to address specified')
3847
3852
            outfile = StringIO()
3848
3853
        elif output == '-':
3849
3854
            outfile = self.outf
3898
3903
                    branch.repository, revision_id, time.time(),
3899
3904
                    osutils.local_time_offset(), submit_branch,
3900
3905
                    public_branch=public_branch, include_patch=not no_patch,
3901
 
                    include_bundle=not no_bundle, message=None,
 
3906
                    include_bundle=not no_bundle, message=message,
3902
3907
                    base_revision_id=base_revision_id)
3903
3908
            elif format == '0.9':
3904
3909
                if not no_bundle:
3916
3921
                    branch.repository, revision_id, time.time(),
3917
3922
                    osutils.local_time_offset(), submit_branch,
3918
3923
                    public_branch=public_branch, patch_type=patch_type,
3919
 
                    message=None)
 
3924
                    message=message)
3920
3925
 
3921
3926
            outfile.writelines(directive.to_lines())
3922
3927
            if output is None:
3923
 
                branch.get_config().get_mail_client().compose(None, None,
 
3928
                subject = '[MERGE] '
 
3929
                if message is not None:
 
3930
                    subject += message
 
3931
                else:
 
3932
                    revision = branch.repository.get_revision(revision_id)
 
3933
                    subject += revision.message
 
3934
                branch.get_config().get_mail_client().compose(mail_to, subject,
3924
3935
                    outfile.getvalue())
3925
3936
        finally:
3926
3937
            if output != '-':
3961
3972
    format 1.  It is compatible with Bazaar 0.12 - 0.18.
3962
3973
    """
3963
3974
 
 
3975
    takes_options = [
 
3976
        Option('no-bundle',
 
3977
               help='Do not include a bundle in the merge directive.'),
 
3978
        Option('no-patch', help='Do not include a preview patch in the merge'
 
3979
               ' directive.'),
 
3980
        Option('remember',
 
3981
               help='Remember submit and public branch.'),
 
3982
        Option('from',
 
3983
               help='Branch to generate the submission from, '
 
3984
               'rather than the one containing the working directory.',
 
3985
               short_name='f',
 
3986
               type=unicode),
 
3987
        Option('output', short_name='o', help='Write directive to this file.',
 
3988
               type=unicode),
 
3989
        'revision',
 
3990
        RegistryOption.from_kwargs('format',
 
3991
        'Use the specified output format.',
 
3992
        **{'4': 'Bundle format 4, Merge Directive 2 (default)',
 
3993
           '0.9': 'Bundle format 0.9, Merge Directive 1',})
 
3994
        ]
3964
3995
    aliases = ['bundle']
3965
3996
 
3966
3997
    _see_also = ['send', 'merge']