~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to graph.py

  • Committer: Aaron Bentley
  • Date: 2005-09-19 06:18:30 UTC
  • Revision ID: aaron.bentley@utoronto.ca-20050919061830-41556571cf5da15d
Added committer names to nodes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from dotgraph import Node, dot_output, invoke_dot, invoke_dot_aa, NoDot, NoRsvg
2
2
from dotgraph import mail_map
3
3
from bzrlib.branch import Branch
4
 
from bzrlib.errors import BzrCommandError, NoCommonRoot
 
4
from bzrlib.errors import BzrCommandError, NoCommonRoot, NoSuchRevision
5
5
from bzrlib.fetch import greedy_fetch
6
6
from bzrlib.graph import node_distances, select_farthest
7
 
from bzrlib.revision import combined_graph
 
7
from bzrlib.revision import combined_graph, MultipleRevisionSources
8
8
import bzrlib.errors
9
9
import re
10
10
import os.path
122
122
            node_relations.append((nodes[key], nodes[value]))
123
123
    return node_relations
124
124
 
 
125
def get_committer(rev_id, source):
 
126
    try:
 
127
        committer = short_committer(source.get_revision(rev_id).committer)
 
128
        if '@' in committer:
 
129
            try:
 
130
                return mail_map[committer]
 
131
            except KeyError:
 
132
                pass
 
133
        return committer
 
134
    except NoSuchRevision:
 
135
        try:
 
136
            first_segment = '-'.join(rev_id.split('-')[:-2])\
 
137
                .strip(' ')
 
138
        except ValueError:
 
139
            first_segment = []
 
140
        if '@' in first_segment:
 
141
            try:
 
142
                return mail_map[first_segment]
 
143
            except KeyError:
 
144
                return first_segment
 
145
 
 
146
 
125
147
def graph_merge_pick(branch, other_branch):
126
148
    greedy_fetch(branch, other_branch)
127
149
    revision_a = branch.last_patch()
128
150
    revision_b = other_branch.last_patch()
 
151
    source = MultipleRevisionSources(branch)
129
152
    try:
130
153
        root, ancestors, descendants, common = \
131
 
            combined_graph(revision_a, revision_b, branch)
 
154
            combined_graph(revision_a, revision_b, source)
132
155
    except bzrlib.errors.NoCommonRoot:
133
156
        raise bzrlib.errors.NoCommonAncestor(revision_a, revision_b)
134
157
    distances = node_distances(descendants, ancestors, root)
176
199
            color = "#33ff99"
177
200
 
178
201
        label = [name]
 
202
        committer = get_committer(node, source)
 
203
        if committer is not None:
 
204
            label.append(committer)
 
205
 
179
206
        if node in distances:
180
207
            label.append('d%d' % distances[node])
181
208
        return Node("n%d" % num, color=color, label="\\n".join(label),