38
38
from bzrlib.errors import BzrCommandError
39
39
import bzrlib.ignores
40
40
from bzrlib.trace import note
41
from bzrlib.option import Option
41
from bzrlib.option import Option, RegistryOption
43
43
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
46
class cmd_graph_ancestry(BzrToolsCommand):
81
47
"""Produce ancestry graphs using dot.
199
165
don't depend on each other.
201
167
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.
168
the 'shelf1' command. Run 'bzr shelf1 -h' for more info.
206
171
takes_args = ['file*']
207
172
takes_options = [Option('message',
208
173
help='A message to associate with the shelved changes.',
534
498
"""A color version of bzr's diff"""
535
499
takes_args = property(lambda x: get_cmd_object('diff').takes_args)
536
500
takes_options = list(get_cmd_object('diff').takes_options) + [
501
RegistryOption.from_kwargs('color',
502
'Color mode to use.',
503
title='Color Mode', value_switches=False, enum_switch=True,
504
never='Never colorize output.',
505
auto='Only colorize output if terminal supports it and STDOUT is a'
507
always='Always colorize output (default).'),
537
508
Option('check-style',
538
509
help='Warn if trailing whitespace or spurious changes have been'
541
def run(self, check_style=False, *args, **kwargs):
512
def run(self, color='always', check_style=False, *args, **kwargs):
542
513
from colordiff import colordiff
543
colordiff(check_style, *args, **kwargs)
514
colordiff(color, check_style, *args, **kwargs)
517
class cmd_conflict_diff(BzrToolsCommand):
519
"""Compare a conflicted file against BASE."""
521
encoding_type = 'exact'
522
takes_args = ['file']
524
RegistryOption.from_kwargs('new', 'blah', value_switches=True,
526
other='Compare OTHER against common base.',
527
this='Compare THIS against common base.')]
529
def run(self, file, new='other'):
530
from bzrlib.diff import internal_diff
531
from bzrlib.plugins.bzrtools.colordiff import DiffWriter
532
dw = DiffWriter(self.outf, check_style=False, color='auto')
533
old_path = file + '.BASE'
535
new_path = file + '.OTHER'
537
new_path = file + '.THIS'
538
oldlines = open(old_path).readlines()
539
newlines = open(new_path).readlines()
540
internal_diff(old_path, oldlines, new_path, newlines, dw)
546
543
class cmd_rspush(BzrToolsCommand):