~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to command_classes.py

  • Committer: Aaron Bentley
  • Date: 2013-08-20 03:02:43 UTC
  • Revision ID: aaron@aaronbentley.com-20130820030243-r8v1xfbcnd8f10p4
Fix zap command for 2.6/7

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007 Aaron Bentley <aaron@aaronbentley.com>
2
 
# Copyright (C) 2005, 2006 Canonical Limited.
 
1
# Copyright (C) 2005, 2006, 2007, 2011 Aaron Bentley <aaron@aaronbentley.com>
 
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
16
16
#    along with this program; if not, write to the Free Software
17
17
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
18
 
19
 
import errno
20
 
 
21
19
import bzrlib
22
20
 
23
21
from bzrlib.lazy_import import lazy_import
24
22
lazy_import(globals(), """
25
23
from bzrlib import help, urlutils
26
 
import shelf
 
24
from bzrlib.plugins.bzrtools import shelf
27
25
""")
28
26
 
 
27
from bzrlib.plugins import bzrtools
29
28
from command import BzrToolsCommand
30
29
from errors import CommandError
31
30
from patchsource import BzrPatchSource
32
 
import sys
33
 
import os.path
34
31
 
35
 
import bzrlib.builtins
36
32
import bzrlib.commands
37
33
from bzrlib.branch import Branch
38
 
from bzrlib.bzrdir import BzrDir
39
34
from bzrlib.commands import get_cmd_object
40
35
from bzrlib.errors import BzrCommandError
41
 
import bzrlib.ignores
42
 
from bzrlib.trace import note
43
36
from bzrlib.option import Option, RegistryOption
44
 
from bzrlib.workingtree import WorkingTree
45
 
 
46
 
from command import BzrToolsCommand
47
37
 
48
38
 
49
39
class cmd_graph_ancestry(BzrToolsCommand):
379
369
 
380
370
    If --branch is specified, the branch will be deleted too, but only if the
381
371
    the branch has no new commits (relative to its parent).
 
372
 
 
373
    If bzr-pipeline is also installed, the --store option will store changes
 
374
    in the branch before deleting the tree.  To restore the changes, do::
 
375
 
 
376
      bzr checkout --lightweight $BRANCH $CHECKOUT
 
377
      bzr switch-pipe -d $CHECKOUT `bzr nick -d $CHECKOUT`
382
378
    """
383
379
    takes_options = [Option("branch", help="Remove associated branch from"
384
380
                                           " repository."),
385
 
                     Option('force', help='Delete tree even if contents are'
386
 
                     ' modified.')]
 
381
                     RegistryOption('change_policy',
 
382
                                    'How to handle changed files',
 
383
                                    lazy_registry =
 
384
                                    ('bzrlib.plugins.bzrtools.zap',
 
385
                                        'change_policy_registry'),
 
386
                                    value_switches=True,
 
387
                                    enum_switch=False)]
387
388
    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)
 
389
    def run(self, checkout, branch=False, change_policy=None):
 
390
        from zap import (
 
391
            change_policy_registry,
 
392
            StoreChanges,
 
393
            zap,
 
394
        )
 
395
        if change_policy is None:
 
396
            change_policy = change_policy_registry.get()
 
397
        if change_policy is StoreChanges:
 
398
            try:
 
399
                import bzrlib.plugins.pipeline
 
400
            except ImportError:
 
401
                raise BzrCommandError('--store requires bzr-pipeline.')
 
402
        return zap(checkout, remove_branch=branch, policy=change_policy)
391
403
 
392
404
 
393
405
class cmd_cbranch(BzrToolsCommand):
426
438
                       hardlink=hardlink)
427
439
 
428
440
 
429
 
class cmd_branches(BzrToolsCommand):
 
441
class cmd_list_branches(BzrToolsCommand):
430
442
    """Scan a location for branches"""
 
443
    @property
 
444
    def aliases(self):
 
445
        from bzrlib import commands
 
446
        return commands.plugin_cmds.get_info('list-branches').aliases
 
447
 
431
448
    takes_args = ["location?"]
432
449
    def run(self, location=None):
433
450
        from branches import branches