~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to graph.py

  • Committer: Aaron Bentley
  • Date: 2007-03-16 19:33:45 UTC
  • Revision ID: abentley@panoramicfeedback.com-20070316193345-cvr6cxy6bie0lel6
Update bugs

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
    message = None
78
78
    date = None
79
79
    if rev_id == 'null:':
80
 
        return None, 'Null Revision', None
 
80
        return None, 'Null Revision', None, None
81
81
    try:
82
82
        rev = source.get_revision(rev_id)
83
83
    except NoSuchRevision:
84
84
        try:
85
85
            committer = '-'.join(rev_id.split('-')[:-2]).strip(' ')
86
86
            if committer == '':
87
 
                return None, None, None
 
87
                return None, None, None, None
88
88
        except ValueError:
89
 
            return None, None, None
 
89
            return None, None, None, None
90
90
    else:
91
91
        committer = short_committer(rev.committer)
92
92
        if rev.message is not None:
93
93
            message = rev.message.split('\n')[0]
94
94
        gmtime = time.gmtime(rev.timestamp + (rev.timezone or 0))
95
95
        date = time.strftime('%Y/%m/%d', gmtime)
 
96
        nick = rev.properties.get('branch-nick')
96
97
    if '@' in committer:
97
98
        try:
98
99
            committer = mail_map[committer]
102
103
        committer = committer_alias[committer]
103
104
    except KeyError:
104
105
        pass
105
 
    return committer, message, date
 
106
    return committer, message, nick, date
106
107
 
107
108
class Grapher(object):
108
109
    def __init__(self, branch, other_branch=None):
174
175
            color = "#33ff99"
175
176
 
176
177
        label = [name]
177
 
        committer, message, date = get_rev_info(node, self.branch.repository)
 
178
        committer, message, nick, date = get_rev_info(node, 
 
179
                                                      self.branch.repository)
178
180
        if committer is not None:
179
181
            label.append(committer)
180
182
 
 
183
        if nick is not None:
 
184
            label.append(nick)
 
185
 
181
186
        if date is not None:
182
187
            label.append(date)
183
188
 
196
201
            d_node.node_style.append('dotted')
197
202
 
198
203
        return d_node
199
 
        
200
 
    def get_relations(self, collapse=False):
 
204
       
 
205
    def get_relations(self, collapse=False, max_distance=None):
201
206
        dot_nodes = {}
202
207
        node_relations = []
203
208
        num = 0
206
211
                                                  self.ancestors, (self.base,))
207
212
        else:
208
213
            visible_ancestors = self.ancestors
 
214
        if max_distance is not None:
 
215
            min_distance = max(self.distances.values()) - max_distance
 
216
            visible_ancestors = dict((n, p) for n, p in visible_ancestors.iteritems() if
 
217
                    self.distances[n] >= min_distance)
209
218
        for node, parents in visible_ancestors.iteritems():
210
219
            if node not in dot_nodes:
211
220
                dot_nodes[node] = self.dot_node(node, num)
226
235
 
227
236
 
228
237
def write_ancestry_file(branch, filename, collapse=True, antialias=True,
229
 
                        merge_branch=None, ranking="forced"):
 
238
                        merge_branch=None, ranking="forced", max_distance=None):
230
239
    b = Branch.open_containing(branch)[0]
231
240
    if merge_branch is not None:
232
241
        m = Branch.open_containing(merge_branch)[0]
238
247
            m.lock_read()
239
248
        try:
240
249
            grapher = Grapher(b, m)
241
 
            relations = grapher.get_relations(collapse)
 
250
            relations = grapher.get_relations(collapse, max_distance)
242
251
        finally:
243
252
            if m is not None:
244
253
                m.unlock()