~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Aaron Bentley
  • Date: 2007-08-08 06:30:55 UTC
  • mto: (2681.5.3 bzr-mail)
  • mto: This revision was merged to the branch mainline in revision 2690.
  • Revision ID: aaron.bentley@utoronto.ca-20070808063055-bh56b51f3vai83n6
Add support for selecting bundle format

Show diffs side-by-side

added added

removed removed

Lines of Context:
3821
3821
        Option('output', short_name='o', help='Write directive to this file.',
3822
3822
               type=unicode),
3823
3823
        'revision',
 
3824
        RegistryOption.from_kwargs('format', 'Output format',
 
3825
        **{'4': 'Bundle format 4, Merge Directive 2 (default)',
 
3826
           '0.9': 'Bundle format 4, Merge Directive 2 (default)',})
3824
3827
        ]
3825
3828
 
3826
3829
    def run(self, submit_branch=None, public_branch=None, no_bundle=False,
3827
3830
            no_patch=False, revision=None, remember=False, output=None,
3828
 
            **kwargs):
 
3831
            format='4', **kwargs):
3829
3832
        if output is None:
3830
3833
            raise errors.BzrCommandError('File must be specified with'
3831
3834
                                         ' --output')
3832
 
        return self._run(submit_branch, public_branch, no_bundle, no_patch,
3833
 
                         revision, remember, output, **kwargs)
 
3835
        return self._run(submit_branch, revision, public_branch, remember,
 
3836
                         format, no_bundle, no_patch, output,
 
3837
                         kwargs.get('from', '.'))
3834
3838
 
3835
 
    def _run(self, submit_branch=None, public_branch=None, no_bundle=False,
3836
 
            no_patch=False, revision=None, remember=False, output=None,
3837
 
            **kwargs):
 
3839
    def _run(self, submit_branch, revision, public_branch, remember, format,
 
3840
             no_bundle, no_patch, output, from_,):
3838
3841
        from bzrlib.revision import ensure_null, NULL_REVISION
3839
3842
        if output == '-':
3840
3843
            outfile = self.outf
3841
3844
        else:
3842
3845
            outfile = open(output, 'wb')
3843
3846
        try:
3844
 
            from_ = kwargs.get('from', '.')
3845
3847
            branch = Branch.open_containing(from_)[0]
3846
3848
            if remember and submit_branch is None:
3847
3849
                raise errors.BzrCommandError(
3885
3887
            revision_id = ensure_null(revision_id)
3886
3888
            if revision_id == NULL_REVISION:
3887
3889
                raise errors.BzrCommandError('No revisions to submit.')
3888
 
            directive = merge_directive.MergeDirective2.from_objects(
3889
 
                branch.repository, revision_id, time.time(),
3890
 
                osutils.local_time_offset(), submit_branch,
3891
 
                public_branch=public_branch, include_patch=not no_patch,
3892
 
                include_bundle=not no_bundle, message=None,
3893
 
                base_revision_id=base_revision_id)
 
3890
            if format == '4':
 
3891
                directive = merge_directive.MergeDirective2.from_objects(
 
3892
                    branch.repository, revision_id, time.time(),
 
3893
                    osutils.local_time_offset(), submit_branch,
 
3894
                    public_branch=public_branch, include_patch=not no_patch,
 
3895
                    include_bundle=not no_bundle, message=None,
 
3896
                    base_revision_id=base_revision_id)
 
3897
            elif format == '0.9':
 
3898
                if not no_bundle:
 
3899
                    if not no_patch:
 
3900
                        patch_type = 'bundle'
 
3901
                    else:
 
3902
                        raise errors.BzrCommandError('Format 0.9 does not'
 
3903
                            ' permit bundle with no patch')
 
3904
                else:
 
3905
                    if not no_patch:
 
3906
                        patch_type = 'diff'
 
3907
                    else:
 
3908
                        patch_type = None
 
3909
                directive = merge_directive.MergeDirective.from_objects(
 
3910
                    branch.repository, revision_id, time.time(),
 
3911
                    osutils.local_time_offset(), submit_branch,
 
3912
                    public_branch=public_branch, patch_type=patch_type,
 
3913
                    message=None)
 
3914
 
3894
3915
            outfile.writelines(directive.to_lines())
3895
3916
        finally:
3896
3917
            if output != '-':
3933
3954
 
3934
3955
    def run(self, submit_branch=None, public_branch=None, no_bundle=False,
3935
3956
            no_patch=False, revision=None, remember=False, output=None,
3936
 
            **kwargs):
 
3957
            format='4', **kwargs):
3937
3958
        if output is None:
3938
3959
            output = '-'
3939
 
        return self._run(submit_branch, public_branch, no_bundle, no_patch,
3940
 
                         revision, remember, output, **kwargs)
 
3960
        return self._run(submit_branch, revision, public_branch, remember,
 
3961
                         format, no_bundle, no_patch, output,
 
3962
                         kwargs.get('from', '.'))
3941
3963
 
3942
3964
 
3943
3965
class cmd_tag(Command):