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.
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
23
21
from bzrlib.lazy_import import lazy_import
24
22
lazy_import(globals(), """
25
23
from bzrlib import help, urlutils
24
from bzrlib.plugins.bzrtools import shelf
27
from bzrlib.plugins import bzrtools
29
28
from command import BzrToolsCommand
30
29
from errors import CommandError
31
30
from patchsource import BzrPatchSource
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
42
from bzrlib.trace import note
43
36
from bzrlib.option import Option, RegistryOption
44
from bzrlib.workingtree import WorkingTree
46
from command import BzrToolsCommand
49
39
class cmd_graph_ancestry(BzrToolsCommand):
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).
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::
376
bzr checkout --lightweight $BRANCH $CHECKOUT
377
bzr switch-pipe -d $CHECKOUT `bzr nick -d $CHECKOUT`
383
379
takes_options = [Option("branch", help="Remove associated branch from"
385
Option('force', help='Delete tree even if contents are'
381
RegistryOption('change_policy',
382
'How to handle changed files',
384
('bzrlib.plugins.bzrtools.zap',
385
'change_policy_registry'),
387
388
takes_args = ["checkout"]
388
def run(self, checkout, branch=False, force=False):
390
return zap(checkout, remove_branch=branch, allow_modified=force)
389
def run(self, checkout, branch=False, change_policy=None):
391
change_policy_registry,
395
if change_policy is None:
396
change_policy = change_policy_registry.get()
397
if change_policy is StoreChanges:
399
import bzrlib.plugins.pipeline
401
raise BzrCommandError('--store requires bzr-pipeline.')
402
return zap(checkout, remove_branch=branch, policy=change_policy)
393
405
class cmd_cbranch(BzrToolsCommand):
426
438
hardlink=hardlink)
429
class cmd_branches(BzrToolsCommand):
441
class cmd_list_branches(BzrToolsCommand):
430
442
"""Scan a location for branches"""
445
from bzrlib import commands
446
return commands.plugin_cmds.get_info('list-branches').aliases
431
448
takes_args = ["location?"]
432
449
def run(self, location=None):
433
450
from branches import branches