~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Aaron Bentley
  • Date: 2005-09-20 21:10:11 UTC
  • Revision ID: abentley@panoramicfeedback.com-20050920211011-418e92aa03c57fc8
Added skip labels to edges

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""\
 
2
Various useful plugins for working with bzr.
 
3
"""
 
4
import bzrlib.commands
 
5
import push
 
6
import annotate
 
7
import shelf
 
8
import conflicts
 
9
import sys
 
10
import os.path
 
11
sys.path.append(os.path.dirname(__file__))
 
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
 
 
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)
 
32
 
 
33
bzrlib.commands.OPTIONS['no-collapse'] = None
 
34
bzrlib.commands.OPTIONS['no-antialias'] = None
 
35
bzrlib.commands.OPTIONS['merge-branch'] = str
 
36
 
 
37
class cmd_graph_ancestry(bzrlib.commands.Command):
 
38
    """Produce ancestry graphs using dot.
 
39
    
 
40
    Output format is detected according to file extension.  Some of the more
 
41
    common output formats are png, gif, svg, ps.  An extension of '.dot' will
 
42
    cause a dot graph file to be produced.
 
43
 
 
44
    Ancestry is usually collapsed by removing nodes with a single parent
 
45
    and descendant, but this can be disabled with --no-collapse.
 
46
 
 
47
    The current branch's revisions are yellow and labeled R?, where ? is
 
48
    the revno.  Other revisions are labeled with essentially random numbers.
 
49
 
 
50
    Revisions that are not in branch storage have dotted outlines.
 
51
 
 
52
    rsvg is used to antialias PNG and JPEG output, but this can be disabled
 
53
    with --no-antialias.
 
54
    """
 
55
    takes_args = ['branch', 'file']
 
56
    takes_options = ['no-collapse', 'no-antialias', 'merge-branch']
 
57
    def run(self, branch, file, no_collapse=False, no_antialias=False,
 
58
        merge_branch=None):
 
59
        import graph
 
60
        graph.write_ancestry_file(branch, file, not no_collapse, 
 
61
                                  not no_antialias, merge_branch)
 
62
 
 
63
class cmd_fetch_missing(bzrlib.commands.Command):
 
64
    """Attempt to retrieve missing ancestors from another branch.
 
65
    If the other branch is not supplied, the last-pulled branch is used.
 
66
    """
 
67
    takes_args = ['branch?']
 
68
    def run(self, branch=None):
 
69
        from fetch_missing import fetch_missing
 
70
        fetch_missing(branch)
 
71
 
 
72
class cmd_patch(bzrlib.commands.Command):
 
73
    """Apply a named patch to the current tree.
 
74
    """
 
75
    takes_args = ['filename?']
 
76
    takes_options = ['strip']
 
77
    def run(self, filename=None, strip=0):
 
78
        from patch import patch
 
79
        from bzrlib.branch import Branch
 
80
        b = Branch.open_containing('.')
 
81
        return patch(b, filename, strip)
 
82
 
 
83
 
 
84
 
 
85
commands = [push.cmd_push, annotate.cmd_annotate, shelf.cmd_shelve, 
 
86
            shelf.cmd_unshelve, cmd_clean_tree, conflicts.cmd_conflicts,
 
87
            conflicts.cmd_resolve, cmd_graph_ancestry, cmd_fetch_missing,
 
88
            cmd_patch]
 
89
from errors import NoPyBaz
 
90
try:
 
91
    import baz_import
 
92
    commands.append(baz_import.cmd_baz_import)
 
93
 
 
94
except NoPyBaz:
 
95
    class cmd_baz_import(bzrlib.commands.Command):
 
96
        """Disabled. (Requires PyBaz)"""
 
97
    commands.append(cmd_baz_import)
 
98
 
 
99
if hasattr(bzrlib.commands, 'register_command'):
 
100
    for command in commands:
 
101
        bzrlib.commands.register_command(command)
 
102
 
 
103
def test_suite():
 
104
    from doctest import DocTestSuite
 
105
    return DocTestSuite(bzrtools)