~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: John Arbash Meinel
  • Date: 2005-09-22 23:08:00 UTC
  • mto: This revision was merged to the branch mainline in revision 193.
  • Revision ID: john@arbash-meinel.com-20050922230800-49074635850e0552
Fix datestamp, reuse pre-layed out dot file.

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['cluster'] = None
 
36
bzrlib.commands.OPTIONS['merge-branch'] = str
 
37
 
 
38
class cmd_graph_ancestry(bzrlib.commands.Command):
 
39
    """Produce ancestry graphs using dot.
 
40
    
 
41
    Output format is detected according to file extension.  Some of the more
 
42
    common output formats are png, gif, svg, ps.  An extension of '.dot' will
 
43
    cause a dot graph file to be produced.
 
44
 
 
45
    Branches are labeled r?, where ? is the revno.  If they have no revno,
 
46
    with the last 5 characters of their revision identifier are used instead.
 
47
    
 
48
    If --merge-branch is specified, the two branches are compared and a merge
 
49
    base is selected.
 
50
    
 
51
    Legend:
 
52
    yellow   THIS  history
 
53
    red      OTHER history
 
54
    orange   COMMON history
 
55
    blue     COMMON non-history ancestors
 
56
    dotted   Missing from branch storage
 
57
 
 
58
    Ancestry is usually collapsed by removing revisions with a single parent
 
59
    and descendant.  The number of skipped revisions is shown on the arrow.
 
60
    This feature can be disabled with --no-collapse.
 
61
 
 
62
    By default, revisions are ordered by distance from root, but they can be
 
63
    clustered instead using --cluster.
 
64
 
 
65
    rsvg is used to antialias PNG and JPEG output, but this can be disabled
 
66
    with --no-antialias.
 
67
    """
 
68
    takes_args = ['branch', 'file']
 
69
    takes_options = ['no-collapse', 'no-antialias', 'merge-branch', 'cluster']
 
70
    def run(self, branch, file, no_collapse=False, no_antialias=False,
 
71
        merge_branch=None, cluster=False):
 
72
        import graph
 
73
        if cluster:
 
74
            ranking = "cluster"
 
75
        else:
 
76
            ranking = "forced"
 
77
        graph.write_ancestry_file(branch, file, not no_collapse, 
 
78
                                  not no_antialias, merge_branch, ranking)
 
79
 
 
80
class cmd_fetch_missing(bzrlib.commands.Command):
 
81
    """Attempt to retrieve missing ancestors from another branch.
 
82
    If the other branch is not supplied, the last-pulled branch is used.
 
83
    """
 
84
    takes_args = ['branch?']
 
85
    def run(self, branch=None):
 
86
        from fetch_missing import fetch_missing
 
87
        fetch_missing(branch)
 
88
 
 
89
class cmd_patch(bzrlib.commands.Command):
 
90
    """Apply a named patch to the current tree.
 
91
    """
 
92
    takes_args = ['filename?']
 
93
    takes_options = ['strip']
 
94
    def run(self, filename=None, strip=0):
 
95
        from patch import patch
 
96
        from bzrlib.branch import Branch
 
97
        b = Branch.open_containing('.')
 
98
        return patch(b, filename, strip)
 
99
 
 
100
 
 
101
 
 
102
commands = [push.cmd_push, annotate.cmd_annotate, shelf.cmd_shelve, 
 
103
            shelf.cmd_unshelve, cmd_clean_tree, conflicts.cmd_conflicts,
 
104
            conflicts.cmd_resolve, cmd_graph_ancestry, cmd_fetch_missing,
 
105
            cmd_patch]
 
106
from errors import NoPyBaz
 
107
try:
 
108
    import baz_import
 
109
    commands.append(baz_import.cmd_baz_import)
 
110
 
 
111
except NoPyBaz:
 
112
    class cmd_baz_import(bzrlib.commands.Command):
 
113
        """Disabled. (Requires PyBaz)"""
 
114
    commands.append(cmd_baz_import)
 
115
 
 
116
if hasattr(bzrlib.commands, 'register_command'):
 
117
    for command in commands:
 
118
        bzrlib.commands.register_command(command)
 
119
 
 
120
def test_suite():
 
121
    from doctest import DocTestSuite
 
122
    return DocTestSuite(bzrtools)