~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Aaron Bentley
  • Date: 2005-10-07 16:07:14 UTC
  • Revision ID: abentley@panoramicfeedback.com-20051007160714-676dd704997013c1
Show branch location when using saved.

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