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
class cmd_patch(bzrlib.commands.Command):
89
"""Apply a named patch to the current tree.
91
takes_args = ['filename?']
92
takes_options = ['strip']
93
def run(self, filename=None, strip=0):
94
from patch import patch
95
from bzrlib.branch import Branch
96
b = Branch.open_containing('.')
97
return patch(b, filename, strip)
101
commands = [push.cmd_push, shelf.cmd_shelve,
102
shelf.cmd_unshelve, cmd_clean_tree, cmd_graph_ancestry,
103
cmd_fetch_ghosts, cmd_patch]
105
import bzrlib.builtins
106
if not hasattr(bzrlib.builtins, "cmd_annotate"):
107
commands.append(annotate.cmd_annotate)
109
from errors import NoPyBaz
112
commands.append(baz_import.cmd_baz_import)
115
class cmd_baz_import(bzrlib.commands.Command):
116
"""Disabled. (Requires PyBaz)"""
117
takes_args = ['to_root_dir?', 'from_archive?']
118
takes_options = ['verbose']
119
def run(self, to_root_dir=None, from_archive=None, verbose=False):
120
print "This command is disabled. Please install PyBaz."
121
commands.append(cmd_baz_import)
123
if hasattr(bzrlib.commands, 'register_command'):
124
for command in commands:
125
bzrlib.commands.register_command(command)
128
from doctest import DocTestSuite
129
from unittest import TestSuite
132
result.addTest(DocTestSuite(bzrtools))
133
result.addTest(clean_tree.test_suite())