/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

Update to bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
3794
3794
 
3795
3795
 
3796
3796
class cmd_send(Command):
3797
 
    """Create a merge-directive for submiting changes.
 
3797
    """Mail or create a merge-directive for submiting changes.
3798
3798
 
3799
3799
    A merge directive provides many things needed for requesting merges:
3800
3800
 
3819
3819
    can be used as your actual submit branch, once you have set public_branch
3820
3820
    for that mirror.
3821
3821
 
 
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.
 
3825
    
 
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
 
3829
    "default".
 
3830
 
 
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
 
3833
    option.
 
3834
 
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
3828
3841
 
3829
3842
    encoding_type = 'exact'
3830
3843
 
3831
 
    _see_also = ['merge']
 
3844
    _see_also = ['merge', 'doc/configuration.txt']
3832
3845
 
3833
3846
    takes_args = ['submit_branch?', 'public_branch?']
3834
3847
 
3846
3859
               type=unicode),
3847
3860
        Option('output', short_name='o', help='Write directive to this file.',
3848
3861
               type=unicode),
 
3862
        Option('mail-to', help='Mail the request to this address.',
 
3863
               type=unicode),
3849
3864
        'revision',
 
3865
        'message',
3850
3866
        RegistryOption.from_kwargs('format',
3851
3867
        'Use the specified output format.',
3852
3868
        **{'4': 'Bundle format 4, Merge Directive 2 (default)',
3855
3871
 
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):
3859
 
        if output is None:
3860
 
            raise errors.BzrCommandError('File must be specified with'
3861
 
                                         ' --output')
 
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)
3865
3878
 
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
3869
 
        if output == '-':
 
3882
        if output is None:
 
3883
            outfile = StringIO()
 
3884
        elif output == '-':
3870
3885
            outfile = self.outf
3871
3886
        else:
3872
3887
            outfile = open(output, 'wb')
3873
3888
        try:
3874
3889
            branch = Branch.open_containing(from_)[0]
 
3890
            if output is None:
 
3891
                config = branch.get_config()
 
3892
                if mail_to is None:
 
3893
                    mail_to = config.get_user_option('submit_to')
 
3894
                if mail_to is None:
 
3895
                    raise errors.BzrCommandError('No mail-to address'
 
3896
                                                 ' specified')
 
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,
3940
 
                    message=None)
 
3963
                    message=message)
3941
3964
 
3942
3965
            outfile.writelines(directive.to_lines())
 
3966
            if output is None:
 
3967
                subject = '[MERGE] '
 
3968
                if message is not None:
 
3969
                    subject += message
 
3970
                else:
 
3971
                    revision = branch.repository.get_revision(revision_id)
 
3972
                    subject += revision.get_summary()
 
3973
                mail_client.compose_merge_request(mail_to, subject,
 
3974
                                                  outfile.getvalue())
3943
3975
        finally:
3944
3976
            if output != '-':
3945
3977
                outfile.close()
3979
4011
    format 1.  It is compatible with Bazaar 0.12 - 0.18.
3980
4012
    """
3981
4013
 
 
4014
    takes_options = [
 
4015
        Option('no-bundle',
 
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'
 
4018
               ' directive.'),
 
4019
        Option('remember',
 
4020
               help='Remember submit and public branch.'),
 
4021
        Option('from',
 
4022
               help='Branch to generate the submission from, '
 
4023
               'rather than the one containing the working directory.',
 
4024
               short_name='f',
 
4025
               type=unicode),
 
4026
        Option('output', short_name='o', help='Write directive to this file.',
 
4027
               type=unicode),
 
4028
        'revision',
 
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',})
 
4033
        ]
3982
4034
    aliases = ['bundle']
3983
4035
 
3984
4036
    _see_also = ['send', 'merge']
3992
4044
            output = '-'
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)
3996
4048
 
3997
4049
 
3998
4050
class cmd_tag(Command):