~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Aaron Bentley
  • Date: 2005-09-11 03:28:31 UTC
  • Revision ID: aaron.bentley@utoronto.ca-20050911032831-7df69b7bdc4cfefd
Added new bzr patch command

Show diffs side-by-side

added added

removed removed

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