~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-08-09 15:19:06 UTC
  • mfrom: (2681.1.7 send-bundle)
  • Revision ID: pqm@pqm.ubuntu.com-20070809151906-hdn9oyslf2qib2op
Allow omitting -o for bundle, add --format

Show diffs side-by-side

added added

removed removed

Lines of Context:
1085
1085
    takes_options = ['verbose',
1086
1086
        Option('new', help='Remove newly-added files.'),
1087
1087
        RegistryOption.from_kwargs('file-deletion-strategy',
1088
 
            'The file deletion mode to be used',
 
1088
            'The file deletion mode to be used.',
1089
1089
            title='Deletion Strategy', value_switches=True, enum_switch=False,
1090
1090
            safe='Only delete files if they can be'
1091
1091
                 ' safely recovered (default).',
3697
3697
 
3698
3698
    hidden = True
3699
3699
 
3700
 
    _see_also = ['submit']
 
3700
    _see_also = ['send']
3701
3701
 
3702
3702
    takes_options = [
3703
3703
        RegistryOption.from_kwargs('patch-type',
3704
 
            'The type of patch to include in the directive',
 
3704
            'The type of patch to include in the directive.',
3705
3705
            title='Patch type',
3706
3706
            value_switches=True,
3707
3707
            enum_switch=False,
3801
3801
    branch is used in the merge instructions.  This means that a local mirror
3802
3802
    can be used as your actual submit branch, once you have set public_branch
3803
3803
    for that mirror.
 
3804
 
 
3805
    Two formats are currently supported: "4" uses revision bundle format 4 and
 
3806
    merge directive format 2.  It is significantly faster and smaller than
 
3807
    older formats.  It is compatible with Bazaar 0.19 and later.  It is the
 
3808
    default.  "0.9" uses revision bundle format 0.9 and merge directive
 
3809
    format 1.  It is compatible with Bazaar 0.12 - 0.18.
3804
3810
    """
3805
3811
 
3806
3812
    encoding_type = 'exact'
3807
3813
 
3808
 
    aliases = ['bundle', 'bundle-revisions']
3809
 
 
3810
3814
    _see_also = ['merge']
3811
3815
 
3812
3816
    takes_args = ['submit_branch?', 'public_branch?']
3826
3830
        Option('output', short_name='o', help='Write directive to this file.',
3827
3831
               type=unicode),
3828
3832
        'revision',
 
3833
        RegistryOption.from_kwargs('format',
 
3834
        'Use the specified output format.',
 
3835
        **{'4': 'Bundle format 4, Merge Directive 2 (default)',
 
3836
           '0.9': 'Bundle format 0.9, Merge Directive 1',})
3829
3837
        ]
3830
3838
 
3831
3839
    def run(self, submit_branch=None, public_branch=None, no_bundle=False,
3832
3840
            no_patch=False, revision=None, remember=False, output=None,
3833
 
            **kwargs):
3834
 
        from bzrlib.revision import ensure_null, NULL_REVISION
 
3841
            format='4', **kwargs):
3835
3842
        if output is None:
3836
3843
            raise errors.BzrCommandError('File must be specified with'
3837
3844
                                         ' --output')
3838
 
        elif output == '-':
 
3845
        return self._run(submit_branch, revision, public_branch, remember,
 
3846
                         format, no_bundle, no_patch, output,
 
3847
                         kwargs.get('from', '.'))
 
3848
 
 
3849
    def _run(self, submit_branch, revision, public_branch, remember, format,
 
3850
             no_bundle, no_patch, output, from_,):
 
3851
        from bzrlib.revision import ensure_null, NULL_REVISION
 
3852
        if output == '-':
3839
3853
            outfile = self.outf
3840
3854
        else:
3841
3855
            outfile = open(output, 'wb')
3842
3856
        try:
3843
 
            from_ = kwargs.get('from', '.')
3844
3857
            branch = Branch.open_containing(from_)[0]
3845
3858
            if remember and submit_branch is None:
3846
3859
                raise errors.BzrCommandError(
3884
3897
            revision_id = ensure_null(revision_id)
3885
3898
            if revision_id == NULL_REVISION:
3886
3899
                raise errors.BzrCommandError('No revisions to submit.')
3887
 
            directive = merge_directive.MergeDirective2.from_objects(
3888
 
                branch.repository, revision_id, time.time(),
3889
 
                osutils.local_time_offset(), submit_branch,
3890
 
                public_branch=public_branch, include_patch=not no_patch,
3891
 
                include_bundle=not no_bundle, message=None,
3892
 
                base_revision_id=base_revision_id)
 
3900
            if format == '4':
 
3901
                directive = merge_directive.MergeDirective2.from_objects(
 
3902
                    branch.repository, revision_id, time.time(),
 
3903
                    osutils.local_time_offset(), submit_branch,
 
3904
                    public_branch=public_branch, include_patch=not no_patch,
 
3905
                    include_bundle=not no_bundle, message=None,
 
3906
                    base_revision_id=base_revision_id)
 
3907
            elif format == '0.9':
 
3908
                if not no_bundle:
 
3909
                    if not no_patch:
 
3910
                        patch_type = 'bundle'
 
3911
                    else:
 
3912
                        raise errors.BzrCommandError('Format 0.9 does not'
 
3913
                            ' permit bundle with no patch')
 
3914
                else:
 
3915
                    if not no_patch:
 
3916
                        patch_type = 'diff'
 
3917
                    else:
 
3918
                        patch_type = None
 
3919
                directive = merge_directive.MergeDirective.from_objects(
 
3920
                    branch.repository, revision_id, time.time(),
 
3921
                    osutils.local_time_offset(), submit_branch,
 
3922
                    public_branch=public_branch, patch_type=patch_type,
 
3923
                    message=None)
 
3924
 
3893
3925
            outfile.writelines(directive.to_lines())
3894
3926
        finally:
3895
3927
            if output != '-':
3896
3928
                outfile.close()
3897
3929
 
3898
3930
 
 
3931
class cmd_bundle_revisions(cmd_send):
 
3932
 
 
3933
    """Create a merge-directive for submiting changes.
 
3934
 
 
3935
    A merge directive provides many things needed for requesting merges:
 
3936
 
 
3937
    * A machine-readable description of the merge to perform
 
3938
 
 
3939
    * An optional patch that is a preview of the changes requested
 
3940
 
 
3941
    * An optional bundle of revision data, so that the changes can be applied
 
3942
      directly from the merge directive, without retrieving data from a
 
3943
      branch.
 
3944
 
 
3945
    If --no-bundle is specified, then public_branch is needed (and must be
 
3946
    up-to-date), so that the receiver can perform the merge using the
 
3947
    public_branch.  The public_branch is always included if known, so that
 
3948
    people can check it later.
 
3949
 
 
3950
    The submit branch defaults to the parent, but can be overridden.  Both
 
3951
    submit branch and public branch will be remembered if supplied.
 
3952
 
 
3953
    If a public_branch is known for the submit_branch, that public submit
 
3954
    branch is used in the merge instructions.  This means that a local mirror
 
3955
    can be used as your actual submit branch, once you have set public_branch
 
3956
    for that mirror.
 
3957
 
 
3958
    Two formats are currently supported: "4" uses revision bundle format 4 and
 
3959
    merge directive format 2.  It is significantly faster and smaller than
 
3960
    older formats.  It is compatible with Bazaar 0.19 and later.  It is the
 
3961
    default.  "0.9" uses revision bundle format 0.9 and merge directive
 
3962
    format 1.  It is compatible with Bazaar 0.12 - 0.18.
 
3963
    """
 
3964
 
 
3965
    aliases = ['bundle']
 
3966
 
 
3967
    _see_also = ['send', 'merge']
 
3968
 
 
3969
    hidden = True
 
3970
 
 
3971
    def run(self, submit_branch=None, public_branch=None, no_bundle=False,
 
3972
            no_patch=False, revision=None, remember=False, output=None,
 
3973
            format='4', **kwargs):
 
3974
        if output is None:
 
3975
            output = '-'
 
3976
        return self._run(submit_branch, revision, public_branch, remember,
 
3977
                         format, no_bundle, no_patch, output,
 
3978
                         kwargs.get('from', '.'))
 
3979
 
 
3980
 
3899
3981
class cmd_tag(Command):
3900
3982
    """Create, remove or modify a tag naming a revision.
3901
3983