~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to command_classes.py

  • Committer: Aaron Bentley
  • Date: 2011-04-11 23:04:01 UTC
  • mto: This revision was merged to the branch mainline in revision 757.
  • Revision ID: aaron@aaronbentley.com-20110411230401-jyb0j7s1r6hzw21h
Add --store option for zap.

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
 
    takes_options = [Option("branch", help="Remove associated branch from"
384
 
                                           " repository."),
385
 
                     Option('force', help='Delete tree even if contents are'
 
389
    @property
 
390
    def takes_options(self):
 
391
        options = [Option("branch", help="Remove associated branch from"
 
392
                                          " repository."),
 
393
                   Option('force', help='Delete tree even if contents are'
386
394
                     ' modified.')]
 
395
        try:
 
396
            import bzrlib.plugins.pipeline
 
397
        except:
 
398
            pass
 
399
        else:
 
400
            options.append(Option('store', help='Store uncommitted changes in'
 
401
                                                ' the branch.'))
 
402
        return options
387
403
    takes_args = ["checkout"]
388
 
    def run(self, checkout, branch=False, force=False):
 
404
    def run(self, checkout, branch=False, force=False, store=False):
389
405
        from zap import zap
390
 
        return zap(checkout, remove_branch=branch, allow_modified=force)
 
406
        if store:
 
407
            force = False
 
408
            if branch:
 
409
                raise BzrCommandError('Cannot store changes in branch, then'
 
410
                                      ' delete branch.')
 
411
        return zap(checkout, remove_branch=branch, allow_modified=force,
 
412
                   store_changes=store)
391
413
 
392
414
 
393
415
class cmd_cbranch(BzrToolsCommand):