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