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.
5
5
# This program is free software; you can redistribute it and/or modify
27
27
from command import BzrToolsCommand
28
28
from errors import CommandError
29
29
from patchsource import BzrPatchSource
33
import bzrlib.builtins
34
31
import bzrlib.commands
35
32
from bzrlib.branch import Branch
36
from bzrlib.bzrdir import BzrDir
37
33
from bzrlib.commands import get_cmd_object
38
34
from bzrlib.errors import BzrCommandError
40
from bzrlib.trace import note
41
35
from bzrlib.option import Option, RegistryOption
43
from command import BzrToolsCommand
46
38
class cmd_graph_ancestry(BzrToolsCommand):
47
39
"""Produce ancestry graphs using dot.
49
41
Output format is detected according to file extension. Some of the more
50
42
common output formats are html, png, gif, svg, ps. An extension of '.dot'
51
43
will cause a dot graph file to be produced. HTML output has mouseovers
117
109
takes_options = [Option('no-fix', help="Skip additional synchonization.")]
118
110
def run(self, branch=None, no_fix=False):
119
111
from fetch_ghosts import fetch_ghosts
120
fetch_ghosts(branch, no_fix)
112
fetch_ghosts(branch, do_reconcile=not no_fix)
122
114
strip_help="""Strip the smallest prefix containing num leading slashes from \
123
115
each file name found in the patch file."""
127
119
"""Apply a named patch to the current tree.
129
121
takes_args = ['filename?']
130
takes_options = [Option('strip', type=int, help=strip_help),
122
takes_options = [Option('strip', type=int, short_name='p',
131
124
Option('silent', help='Suppress chatter.')]
132
125
def run(self, filename=None, strip=None, silent=False):
133
126
from patch import patch
338
331
--all --help --revision --show-ids
339
332
bzr bzrtools:287/> status --
336
help='Branch in which to start the shell, '
337
'rather than the one containing the working directory.',
342
def run(self, directory=None):
343
return shell.run_shell()
344
return shell.run_shell(directory)
346
347
class cmd_branch_history(BzrToolsCommand):
368
369
If --branch is specified, the branch will be deleted too, but only if the
369
370
the branch has no new commits (relative to its parent).
372
If bzr-pipeline is also installed, the --store option will store changes
373
in the branch before deleting the tree. To restore the changes, do::
375
bzr checkout --lightweight $BRANCH $CHECKOUT
376
bzr switch-pipe -d $CHECKOUT `bzr nick -d $CHECKOUT`
371
378
takes_options = [Option("branch", help="Remove associated branch from"
373
Option('force', help='Delete tree even if contents are'
380
RegistryOption('change_policy',
381
'How to handle changed files',
383
('bzrlib.plugins.bzrtools.zap',
384
'change_policy_registry'),
375
387
takes_args = ["checkout"]
376
def run(self, checkout, branch=False, force=False):
378
return zap(checkout, remove_branch=branch, allow_modified=force)
388
def run(self, checkout, branch=False, change_policy=None):
390
change_policy_registry,
394
if change_policy is None:
395
change_policy = change_policy_registry.get()
396
if change_policy is StoreChanges:
398
import bzrlib.plugins.pipeline
400
raise BzrCommandError('--store requires bzr-pipeline.')
401
return zap(checkout, remove_branch=branch, policy=change_policy)
381
404
class cmd_cbranch(BzrToolsCommand):
514
537
colordiff(color, check_style, *args, **kwargs)
540
class cmd_conflict_diff(BzrToolsCommand):
542
"""Compare a conflicted file against BASE."""
544
encoding_type = 'exact'
545
takes_args = ['file*']
547
RegistryOption.from_kwargs('direction', 'Direction of comparison.',
548
value_switches=True, enum_switch=False,
549
other='Compare OTHER against common base.',
550
this='Compare THIS against common base.')]
552
def run(self, file_list, direction='other'):
553
from bzrlib.plugins.bzrtools.colordiff import DiffWriter
554
from conflict_diff import ConflictDiffer
555
dw = DiffWriter(self.outf, check_style=False, color='auto')
556
ConflictDiffer().run(dw, file_list, direction)
517
559
class cmd_rspush(BzrToolsCommand):
518
560
"""Upload this branch to another location using rsync.
557
599
source_tree.unlock()
559
601
target_tree.unlock()
604
class cmd_create_mirror(BzrToolsCommand):
605
"""Create a mirror of another branch.
607
This is similar to `bzr branch`, but copies more settings, including the
608
submit branch and nickname.
610
It sets the public branch and parent of the target to the source location.
613
takes_args = ['source', 'target']
615
def run(self, source, target):
616
source_branch = Branch.open(source)
617
from bzrlib.plugins.bzrtools.mirror import create_mirror
618
create_mirror(source_branch, target, [])