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
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
38
class cmd_graph_ancestry(BzrToolsCommand):
81
39
"""Produce ancestry graphs using dot.
83
41
Output format is detected according to file extension. Some of the more
84
42
common output formats are html, png, gif, svg, ps. An extension of '.dot'
85
43
will cause a dot graph file to be produced. HTML output has mouseovers
151
109
takes_options = [Option('no-fix', help="Skip additional synchonization.")]
152
110
def run(self, branch=None, no_fix=False):
153
111
from fetch_ghosts import fetch_ghosts
154
fetch_ghosts(branch, no_fix)
112
fetch_ghosts(branch, do_reconcile=not no_fix)
156
114
strip_help="""Strip the smallest prefix containing num leading slashes from \
157
115
each file name found in the patch file."""
161
119
"""Apply a named patch to the current tree.
163
121
takes_args = ['filename?']
164
takes_options = [Option('strip', type=int, help=strip_help),
122
takes_options = [Option('strip', type=int, short_name='p',
165
124
Option('silent', help='Suppress chatter.')]
166
125
def run(self, filename=None, strip=None, silent=False):
167
126
from patch import patch
199
158
don't depend on each other.
201
160
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.
161
the 'shelf1' command. Run 'bzr shelf1 -h' for more info.
206
164
takes_args = ['file*']
207
165
takes_options = [Option('message',
208
166
help='A message to associate with the shelved changes.',
374
331
--all --help --revision --show-ids
375
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):
379
return shell.run_shell()
344
return shell.run_shell(directory)
382
347
class cmd_branch_history(BzrToolsCommand):
404
369
If --branch is specified, the branch will be deleted too, but only if the
405
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`
407
378
takes_options = [Option("branch", help="Remove associated branch from"
409
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'),
411
387
takes_args = ["checkout"]
412
def run(self, checkout, branch=False, force=False):
414
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)
417
404
class cmd_cbranch(BzrToolsCommand):
540
527
never='Never colorize output.',
541
528
auto='Only colorize output if terminal supports it and STDOUT is a'
543
always='Always colorize ouput (default).'),
530
always='Always colorize output (default).'),
544
531
Option('check-style',
545
532
help='Warn if trailing whitespace or spurious changes have been'
550
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)
553
559
class cmd_rspush(BzrToolsCommand):
554
560
"""Upload this branch to another location using rsync.
593
599
source_tree.unlock()
595
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, [])