~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Aaron Bentley
  • Date: 2007-03-02 02:46:26 UTC
  • mto: (2323.6.9 0.15-integration)
  • mto: This revision was merged to the branch mainline in revision 2330.
  • Revision ID: aaron.bentley@utoronto.ca-20070302024626-nxb07lxv8k162wwd
Get merge-directive command basically working

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
    merge as _mod_merge,
40
40
    merge_directive,
41
41
    osutils,
 
42
    registry,
42
43
    repository,
43
44
    symbol_versioning,
44
45
    transport,
3166
3167
        server.serve()
3167
3168
 
3168
3169
 
 
3170
_directive_patch_type = registry.Registry()
 
3171
_directive_patch_type.register('bundle', 'bundle', 'Bazaar revision bundle')
 
3172
_directive_patch_type.register('diff', 'diff', 'Normal unified diff')
 
3173
_directive_patch_type.register('plain', None, 'No patch, just directive')
 
3174
 
 
3175
 
3169
3176
class cmd_merge_directive(Command):
3170
3177
    """Generate a merge directive auto-merge tools."""
3171
3178
 
3172
 
    def run(self):
 
3179
    takes_args = ['submit_branch?', 'public_branch?']
 
3180
 
 
3181
    takes_options = [RegistryOption('patch-type',
 
3182
        'The type of patch to include in the directive',
 
3183
        _directive_patch_type, value_switches=True)]
 
3184
 
 
3185
    def run(self, submit_branch=None, public_branch=None, patch_type='bundle'):
3173
3186
        branch = Branch.open('.')
3174
 
        submit_branch = branch.get_submit_branch()
3175
 
        public_branch = branch.get_config().get_user_option('public_branch')
 
3187
        config_submit_branch = branch.get_submit_branch()
 
3188
        if submit_branch is None:
 
3189
            submit_branch = config_submit_branch
 
3190
        else:
 
3191
            if config_submit_branch is None:
 
3192
                branch.set_submit_branch(submit_branch)
 
3193
        if submit_branch is None:
 
3194
            submit_branch = branch.get_parent()
 
3195
        if submit_branch is None:
 
3196
            raise errors.BzrCommandError('No submit branch specified or known')
 
3197
        config_public_branch = branch.get_config().get_user_option(
 
3198
                'public_branch')
 
3199
        if public_branch is None:
 
3200
            public_branch = config_public_branch
 
3201
        elif config_public_branch is None:
 
3202
            branch.get_config().set_user_option('public_branch', public_branch)
3176
3203
        if public_branch is not None:
3177
3204
            public_branch = Branch.open(public_branch)
3178
 
        if submit_branch is None:
3179
 
            submit_branch = branch.get_parent()
 
3205
        if patch_type != "bundle" and public_branch is None:
 
3206
            raise errors.BzrCommandError('No public branch specified or known')
3180
3207
        directive = merge_directive.MergeDirective.from_objects(
3181
3208
            branch.repository, branch.last_revision(), time.time(),
3182
3209
            osutils.local_time_offset(), submit_branch,
3183
 
            public_branch=public_branch)
 
3210
            public_branch=public_branch, patch_type=patch_type)
3184
3211
        self.outf.writelines(directive.to_lines())
3185
3212
 
 
3213
 
3186
3214
# command-line interpretation helper for merge-related commands
3187
3215
def _merge_helper(other_revision, base_revision,
3188
3216
                  check_clean=True, ignore_zero=False,