2
Various useful plugins for working with bzr.
10
from bzrlib.option import Option
11
sys.path.append(os.path.dirname(__file__))
13
Option.OPTIONS['ignored'] = Option('ignored',
14
help='delete all ignored files.')
15
Option.OPTIONS['detrius'] = Option('detrius',
16
help='delete conflict files merge backups, and failed selftest dirs.' +
17
'(*.THIS, *.BASE, *.OTHER, *~, *.tmp')
18
Option.OPTIONS['dry-run'] = Option('dry-run',
19
help='show files to delete instead of deleting them.')
21
class cmd_clean_tree(bzrlib.commands.Command):
22
"""Remove unwanted files from working tree.
23
Normally, ignored files are left alone.
25
takes_options = ['ignored', 'detrius', 'dry-run']
26
def run(self, ignored=False, detrius=False, dry_run=False):
27
from clean_tree import clean_tree
28
clean_tree('.', ignored=ignored, detrius=detrius, dry_run=dry_run)
30
Option.OPTIONS['no-collapse'] = Option('no-collapse')
31
Option.OPTIONS['no-antialias'] = Option('no-antialias')
32
Option.OPTIONS['cluster'] = Option('cluster')
33
Option.OPTIONS['merge-branch'] = Option('merge-branch',type=str)
35
class cmd_graph_ancestry(bzrlib.commands.Command):
36
"""Produce ancestry graphs using dot.
38
Output format is detected according to file extension. Some of the more
39
common output formats are png, gif, svg, ps. An extension of '.dot' will
40
cause a dot graph file to be produced.
42
Branches are labeled r?, where ? is the revno. If they have no revno,
43
with the last 5 characters of their revision identifier are used instead.
45
If --merge-branch is specified, the two branches are compared and a merge
53
blue COMMON non-history ancestor
54
dotted Missing from branch storage
56
Ancestry is usually collapsed by removing revisions with a single parent
57
and descendant. The number of skipped revisions is shown on the arrow.
58
This feature can be disabled with --no-collapse.
60
By default, revisions are ordered by distance from root, but they can be
61
clustered instead using --cluster.
63
If available, rsvg is used to antialias PNG and JPEG output, but this can
64
be disabled with --no-antialias.
66
takes_args = ['branch', 'file']
67
takes_options = ['no-collapse', 'no-antialias', 'merge-branch', 'cluster']
68
def run(self, branch, file, no_collapse=False, no_antialias=False,
69
merge_branch=None, cluster=False):
75
graph.write_ancestry_file(branch, file, not no_collapse,
76
not no_antialias, merge_branch, ranking)
78
class cmd_fetch_ghosts(bzrlib.commands.Command):
79
"""Attempt to retrieve ghosts from another branch.
80
If the other branch is not supplied, the last-pulled branch is used.
82
aliases = ['fetch-missing']
83
takes_args = ['branch?']
84
def run(self, branch=None):
85
from fetch_ghosts import fetch_ghosts
88
strip_help="""Strip the smallest prefix containing num leading slashes from \
89
each file name found in the patch file."""
90
Option.OPTIONS['strip'] = Option('strip', type=int, help=strip_help)
91
class cmd_patch(bzrlib.commands.Command):
92
"""Apply a named patch to the current tree.
94
takes_args = ['filename?']
95
takes_options = ['strip']
96
def run(self, filename=None, strip=0):
97
from patch import patch
98
from bzrlib.branch import Branch
99
b = Branch.open_containing('.')[0]
100
return patch(b, filename, strip)
104
commands = [push.cmd_push, shelf.cmd_shelve,
105
shelf.cmd_unshelve, cmd_clean_tree, cmd_graph_ancestry,
106
cmd_fetch_ghosts, cmd_patch]
108
import bzrlib.builtins
109
if not hasattr(bzrlib.builtins, "cmd_annotate"):
110
commands.append(annotate.cmd_annotate)
112
from errors import NoPyBaz
115
commands.append(baz_import.cmd_baz_import)
118
class cmd_baz_import(bzrlib.commands.Command):
119
"""Disabled. (Requires PyBaz)"""
120
takes_args = ['to_root_dir?', 'from_archive?']
121
takes_options = ['verbose']
122
def run(self, to_root_dir=None, from_archive=None, verbose=False):
123
print "This command is disabled. Please install PyBaz."
124
commands.append(cmd_baz_import)
126
if hasattr(bzrlib.commands, 'register_command'):
127
for command in commands:
128
bzrlib.commands.register_command(command)
131
from doctest import DocTestSuite
132
from unittest import TestSuite
136
result.addTest(DocTestSuite(bzrtools))
137
result.addTest(clean_tree.test_suite())
138
result.addTest(blackbox.test_suite())