~bzr/ubuntu/jaunty/bzrtools/beta-ppa

« back to all changes in this revision

Viewing changes to command_classes.py

  • Committer: Max Bowsher
  • Date: 2011-05-15 07:35:58 UTC
  • mfrom: (18.2.19 karmic)
  • Revision ID: maxb@f2s.com-20110515073558-zc3x4w7hwy47j8k2
Tags: 2.4.0~bzr767-2~bazaar1~jaunty1
MergeĀ 2.4.0~bzr767-2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2005, 2006, 2007 Aaron Bentley <aaron@aaronbentley.com>
2
 
# Copyright (C) 2005, 2006 Canonical Limited.
 
2
# Copyright (C) 2005, 2006, 2011 Canonical Limited.
3
3
# Copyright (C) 2006 Michael Ellerman.
4
4
#
5
5
#    This program is free software; you can redistribute it and/or modify
379
379
 
380
380
    If --branch is specified, the branch will be deleted too, but only if the
381
381
    the branch has no new commits (relative to its parent).
 
382
 
 
383
    If bzr-pipeline is also installed, the --store option will store changes
 
384
    in the branch before deleting the tree.  To restore the changes, do::
 
385
 
 
386
      bzr checkout --lightweight $BRANCH $CHECKOUT
 
387
      bzr switch-pipe -d $CHECKOUT `bzr nick -d $CHECKOUT`
382
388
    """
383
389
    takes_options = [Option("branch", help="Remove associated branch from"
384
390
                                           " repository."),
385
 
                     Option('force', help='Delete tree even if contents are'
386
 
                     ' modified.')]
 
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)]
387
398
    takes_args = ["checkout"]
388
 
    def run(self, checkout, branch=False, force=False):
389
 
        from zap import zap
390
 
        return zap(checkout, remove_branch=branch, allow_modified=force)
 
399
    def run(self, checkout, branch=False, change_policy=None):
 
400
        from zap import (
 
401
            change_policy_registry,
 
402
            StoreChanges,
 
403
            zap,
 
404
        )
 
405
        if change_policy is None:
 
406
            change_policy = change_policy_registry.get()
 
407
        if change_policy is StoreChanges:
 
408
            try:
 
409
                import bzrlib.plugins.pipeline
 
410
            except ImportError:
 
411
                raise BzrCommandError('--store requires bzr-pipeline.')
 
412
        return zap(checkout, remove_branch=branch, policy=change_policy)
391
413
 
392
414
 
393
415
class cmd_cbranch(BzrToolsCommand):