~abentley/bzrtools/bzrtools.dev

124 by Aaron Bentley
Added docstring for bzrtools
1
"""\
2
Various useful plugins for working with bzr.
3
"""
93 by Aaron Bentley
Used the bzr 0.5+ plugin stuff
4
import bzrlib.commands
5
import push
6
import annotate
7
import shelf
119 by aaron.bentley at utoronto
Added conflict-awareness tools
8
import conflicts
132 by Aaron Bentley
brute-forced bzrtools path into sys.path so baz-import works
9
import sys
10
import os.path
11
sys.path.append(os.path.dirname(__file__))
118 by aaron.bentley at utoronto
Added clean-tree command
12
13
bzrlib.commands.OPTIONS['ignored'] = None
14
15
class cmd_clean_tree(bzrlib.commands.Command):
16
    """Remove unwanted files from working tree.
17
    Normally, ignored files are left alone.  The --ignored flag will cause them
18
    to be deleted as well.
19
    """
20
    takes_options = ['ignored']
21
    def run(self, ignored=False):
22
        import clean_tree
23
        clean_tree.clean_tree(ignored=ignored)
24
119 by aaron.bentley at utoronto
Added conflict-awareness tools
25
class cmd_conflicted(bzrlib.commands.Command):
26
    """List files that have conflicts
27
    """
28
    takes_options = ['ignored']
29
    def run(self, ignored=False):
30
        import clean_tree
31
        clean_tree.clean_tree(ignored=ignored)
118 by aaron.bentley at utoronto
Added clean-tree command
32
136 by Aaron Bentley
Allowed disabling ancestry collapsing
33
bzrlib.commands.OPTIONS['no-collapse'] = None
34
128 by Aaron Bentley
Got initial graphing functionality working
35
class cmd_graph_ancestry(bzrlib.commands.Command):
136 by Aaron Bentley
Allowed disabling ancestry collapsing
36
    """Produce ancestry graphs using dot.
37
    
38
    Output format is detected according to file extension.  Some of the more
39
    common outputs are png, gif, svg, ps.  An extension of '.dot' will cause
40
    a dot input file to be produced.
41
42
    Ancestry is usually collapsed by removing nodes with a single parent
43
    and descendant, but this can be disabled with --no-collapse.
44
    """
131 by Aaron Bentley
Added required filename parameter
45
    takes_args = ['branch', 'file']
136 by Aaron Bentley
Allowed disabling ancestry collapsing
46
    takes_options = ['no-collapse']
47
    def run(self, branch, file, no_collapse=False):
128 by Aaron Bentley
Got initial graphing functionality working
48
        import graph
136 by Aaron Bentley
Allowed disabling ancestry collapsing
49
        graph.write_ancestry_file(branch, file, not no_collapse)
128 by Aaron Bentley
Got initial graphing functionality working
50
100 by Aaron Bentley
Fixed up the baz-import plugin
51
commands = [push.cmd_push, annotate.cmd_annotate, shelf.cmd_shelve, 
122 by aaron.bentley at utoronto
Added resolve command
52
            shelf.cmd_unshelve, cmd_clean_tree, conflicts.cmd_conflicts,
128 by Aaron Bentley
Got initial graphing functionality working
53
            conflicts.cmd_resolve, cmd_graph_ancestry]
105 by Aaron Bentley
Fixed NoPyBaz detection
54
from errors import NoPyBaz
100 by Aaron Bentley
Fixed up the baz-import plugin
55
try:
56
    import baz_import
57
    commands.append(baz_import.cmd_baz_import)
105 by Aaron Bentley
Fixed NoPyBaz detection
58
59
except NoPyBaz:
100 by Aaron Bentley
Fixed up the baz-import plugin
60
    class cmd_baz_import(bzrlib.commands.Command):
61
        """Disabled. (Requires PyBaz)"""
62
    commands.append(cmd_baz_import)
63
94 by Aaron Bentley
Adjsted to match plugin api
64
if hasattr(bzrlib.commands, 'register_command'):
93 by Aaron Bentley
Used the bzr 0.5+ plugin stuff
65
    for command in commands:
94 by Aaron Bentley
Adjsted to match plugin api
66
        bzrlib.commands.register_command(command)