~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Aaron Bentley
  • Date: 2012-01-20 01:43:54 UTC
  • Revision ID: aaron@aaronbentley.com-20120120014354-z8ezzp1zccf62lt5
Fix shelf compatibility

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