~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to command_classes.py

  • Committer: Aaron Bentley
  • Date: 2011-04-12 04:13:00 UTC
  • mto: This revision was merged to the branch mainline in revision 757.
  • Revision ID: aaron@aaronbentley.com-20110412041300-k13os9o9cq8hlox0
Revamp zap's changed-file handling.

Show diffs side-by-side

added added

removed removed

Lines of Context:
388
388
    """
389
389
    takes_options = [Option("branch", help="Remove associated branch from"
390
390
                                           " repository."),
391
 
                     Option('force', help='Delete tree even if contents are'
392
 
                     ' modified.'),
393
 
                     Option('store', help='Store uncommitted changes in the'
394
 
                                          'branch.  (Requires bzr-pipeline.)')
395
 
                     ]
 
391
                     RegistryOption('change_policy',
 
392
                                    'How to handle changed files',
 
393
                                    lazy_registry =
 
394
                                    ('bzrlib.plugins.bzrtools.zap',
 
395
                                        'change_policy_registry'),
 
396
                                    value_switches=True,
 
397
                                    enum_switch=False)]
396
398
    takes_args = ["checkout"]
397
 
    def run(self, checkout, branch=False, force=False, store=False):
 
399
    def run(self, checkout, branch=False, change_policy=None):
398
400
        from zap import (
399
 
            AllowChanged,
400
401
            HaltOnChange,
401
402
            StoreChanges,
402
 
            zap
 
403
            zap,
403
404
        )
404
 
        if store:
 
405
        if change_policy is None:
 
406
            change_policy = HaltOnChange
 
407
        if change_policy is StoreChanges:
405
408
            try:
406
409
                import bzrlib.plugins.pipeline
407
410
            except ImportError:
408
411
                raise BzrCommandError('--store requires bzr-pipeline.')
409
 
            force = False
410
412
            if branch:
411
413
                raise BzrCommandError('Cannot store changes in branch, then'
412
414
                                      ' delete branch.')
413
 
        if store:
414
 
            policy = StoreChanges
415
 
        elif not force:
416
 
            policy = HaltOnChange
417
 
        else:
418
 
            policy = AllowChanged
419
 
 
420
 
        return zap(checkout, remove_branch=branch, policy=policy)
 
415
        return zap(checkout, remove_branch=branch, policy=change_policy)
421
416
 
422
417
 
423
418
class cmd_cbranch(BzrToolsCommand):