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
21
23
from bzrlib.lazy_import import lazy_import
38
40
from bzrlib.errors import BzrCommandError
39
41
import bzrlib.ignores
40
42
from bzrlib.trace import note
41
from bzrlib.option import Option
43
from bzrlib.option import Option, RegistryOption
44
from bzrlib.workingtree import WorkingTree
43
46
from command import BzrToolsCommand
46
class cmd_clean_tree(BzrToolsCommand):
47
"""Remove unwanted files from working tree.
49
By default, only unknown files, not ignored files, are deleted. Versioned
50
files are never deleted.
52
Another class is 'detritus', which includes files emitted by bzr during
53
normal operations and selftests. (The value of these files decreases with
56
If no options are specified, unknown files are deleted. Otherwise, option
57
flags are respected, and may be combined.
59
To check what clean-tree will do, use --dry-run.
61
takes_options = [Option('ignored', help='Delete all ignored files.'),
62
Option('detritus', help='Delete conflict files, merge'
63
' backups, and failed selftest dirs.'),
65
help='Delete files unknown to bzr (default).'),
66
Option('dry-run', help='Show files to delete instead of'
68
Option('force', help='Do not prompt before deleting.')]
69
def run(self, unknown=False, ignored=False, detritus=False, dry_run=False,
71
from clean_tree import clean_tree
72
if not (unknown or ignored or detritus):
76
clean_tree('.', unknown=unknown, ignored=ignored, detritus=detritus,
77
dry_run=dry_run, no_prompt=force)
80
49
class cmd_graph_ancestry(BzrToolsCommand):
81
50
"""Produce ancestry graphs using dot.
151
120
takes_options = [Option('no-fix', help="Skip additional synchonization.")]
152
121
def run(self, branch=None, no_fix=False):
153
122
from fetch_ghosts import fetch_ghosts
154
fetch_ghosts(branch, no_fix)
123
fetch_ghosts(branch, do_reconcile=not no_fix)
156
125
strip_help="""Strip the smallest prefix containing num leading slashes from \
157
126
each file name found in the patch file."""
161
130
"""Apply a named patch to the current tree.
163
132
takes_args = ['filename?']
164
takes_options = [Option('strip', type=int, help=strip_help),
133
takes_options = [Option('strip', type=int, short_name='p',
165
135
Option('silent', help='Suppress chatter.')]
166
136
def run(self, filename=None, strip=None, silent=False):
167
137
from patch import patch
199
169
don't depend on each other.
201
171
While you have patches on the shelf you can view and manipulate them with
202
the 'shelf' command. Run 'bzr shelf -h' for more info.
172
the 'shelf1' command. Run 'bzr shelf1 -h' for more info.
206
175
takes_args = ['file*']
207
176
takes_options = [Option('message',
208
177
help='A message to associate with the shelved changes.',
229
# The following classes are only used as subcommands for 'shelf', they're
198
# The following classes are only used as subcommands for 'shelf1', they're
230
199
# not to be registered directly with bzr.
232
201
class cmd_shelf_list(bzrlib.commands.Command):
343
312
See 'shelve1' for more information.
345
aliases = ['unshelve']
346
314
takes_options = [
347
315
Option('all', help='Unshelve all changes without prompting.'),
348
316
Option('force', help='Force unshelving even if errors occur.'),
534
502
"""A color version of bzr's diff"""
535
503
takes_args = property(lambda x: get_cmd_object('diff').takes_args)
536
504
takes_options = list(get_cmd_object('diff').takes_options) + [
505
RegistryOption.from_kwargs('color',
506
'Color mode to use.',
507
title='Color Mode', value_switches=False, enum_switch=True,
508
never='Never colorize output.',
509
auto='Only colorize output if terminal supports it and STDOUT is a'
511
always='Always colorize output (default).'),
537
512
Option('check-style',
538
513
help='Warn if trailing whitespace or spurious changes have been'
541
def run(self, check_style=False, *args, **kwargs):
516
def run(self, color='always', check_style=False, *args, **kwargs):
542
517
from colordiff import colordiff
543
colordiff(check_style, *args, **kwargs)
518
colordiff(color, check_style, *args, **kwargs)
521
class cmd_conflict_diff(BzrToolsCommand):
523
"""Compare a conflicted file against BASE."""
525
encoding_type = 'exact'
526
takes_args = ['file']
528
RegistryOption.from_kwargs('direction', 'Direction of comparison.',
529
value_switches=True, enum_switch=False,
530
other='Compare OTHER against common base.',
531
this='Compare THIS against common base.')]
533
def run(self, file, direction='other'):
534
from bzrlib.plugins.bzrtools.colordiff import DiffWriter
535
from conflict_diff import conflict_diff
536
dw = DiffWriter(self.outf, check_style=False, color='auto')
537
conflict_diff(dw, file, direction)
546
540
class cmd_rspush(BzrToolsCommand):
586
580
source_tree.unlock()
588
582
target_tree.unlock()
585
class cmd_create_mirror(BzrToolsCommand):
586
"""Create a mirror of another branch.
588
This is similar to `bzr branch`, but copies more settings, including the
589
submit branch and nickname.
591
It sets the public branch and parent of the target to the source location.
594
takes_args = ['source', 'target']
596
def run(self, source, target):
597
source_branch = Branch.open(source)
598
from bzrlib.plugins.bzrtools.mirror import create_mirror
599
create_mirror(source_branch, target, [])