100
99
authors = ", ".join([
101
100
parse_username(author)[0]
102
101
for author in revision.get_apparent_authors()])
105
(revid, node, lines, last_lines, revno, summary, message,
103
revid, node, lines, last_lines, revno, summary, message,
106
104
committer, timestamp, revision, parents, children, tags,
110
class TreeModel(Gtk.TreeStore):
112
def __init__(self, branch, line_graph_data):
113
Gtk.TreeStore.__init__(self)
116
self.repository = branch.repository
117
self.line_graph_data = line_graph_data
119
if self.branch.supports_tags():
120
self.tags = self.branch.tags.get_reverse_tag_dict()
124
def add_tag(self, tag, revid):
125
self.branch.tags.set_tag(tag, revid)
127
self.tags[revid].append(tag)
129
self.tags[revid] = [tag]
131
def on_get_flags(self):
132
return Gtk.TREE_MODEL_LIST_ONLY
134
def on_get_n_columns(self):
137
def on_get_column_type(self, index):
138
if index == REVID: return GObject.TYPE_STRING
139
if index == NODE: return GObject.TYPE_PYOBJECT
140
if index == LINES: return GObject.TYPE_PYOBJECT
141
if index == LAST_LINES: return GObject.TYPE_PYOBJECT
142
if index == REVNO: return GObject.TYPE_STRING
143
if index == SUMMARY: return GObject.TYPE_STRING
144
if index == MESSAGE: return GObject.TYPE_STRING
145
if index == COMMITTER: return GObject.TYPE_STRING
146
if index == TIMESTAMP: return GObject.TYPE_STRING
147
if index == REVISION: return GObject.TYPE_PYOBJECT
148
if index == PARENTS: return GObject.TYPE_PYOBJECT
149
if index == CHILDREN: return GObject.TYPE_PYOBJECT
150
if index == TAGS: return GObject.TYPE_PYOBJECT
151
if index == AUTHORS: return GObject.TYPE_STRING
153
def on_get_iter(self, path):
154
# XXX sinzui 2011-08-12: maybe path.get_indices()[0]?
157
def on_get_path(self, rowref):
160
def on_get_value(self, rowref, column):
161
if len(self.line_graph_data) > 0:
162
(revid, node, lines, parents,
163
children, revno_sequence) = self.line_graph_data[rowref]
165
(revid, node, lines, parents,
166
children, revno_sequence) = (None, (0, 0), (), (),
168
if column == REVID: return revid
169
if column == NODE: return node
170
if column == LINES: return lines
171
if column == PARENTS: return parents
172
if column == CHILDREN: return children
173
if column == LAST_LINES:
175
return self.line_graph_data[rowref-1][2]
177
if column == REVNO: return ".".join(["%d" % (revno)
178
for revno in revno_sequence])
180
if column == TAGS: return self.tags.get(revid, [])
182
if not revid or revid == NULL_REVISION:
184
if revid not in self.revisions:
185
revision = self.repository.get_revisions([revid])[0]
186
self.revisions[revid] = revision
188
revision = self.revisions[revid]
190
if column == REVISION: return revision
191
if column == SUMMARY: return escape(revision.get_summary())
192
if column == MESSAGE: return escape(revision.message)
193
if column == COMMITTER: return parse_username(revision.committer)[0]
194
if column == TIMESTAMP:
195
return strftime("%Y-%m-%d %H:%M", localtime(revision.timestamp))
196
if column == AUTHORS:
198
parse_username(author)[0] for author in revision.get_apparent_authors()])
200
def on_iter_next(self, rowref):
201
if rowref < len(self.line_graph_data) - 1:
205
def on_iter_children(self, parent):
206
if parent is None: return 0
209
def on_iter_has_child(self, rowref):
212
def on_iter_n_children(self, rowref):
213
if rowref is None: return len(self.line_graph_data)
216
def on_iter_nth_child(self, parent, n):
217
if parent is None: return n
220
def on_iter_parent(self, child):