95
95
column = gtk.TreeViewColumn("Message")
96
96
column.set_resizable(True)
97
97
column.pack_start(cell, expand=True)
98
column.add_attribute(cell, "text", 4)
98
column.add_attribute(cell, "text", 6)
99
99
self.treeview.append_column(column)
101
101
cell = gtk.CellRendererText()
104
104
column = gtk.TreeViewColumn("Committer")
105
105
column.set_resizable(True)
106
106
column.pack_start(cell, expand=True)
107
column.add_attribute(cell, "text", 5)
107
column.add_attribute(cell, "text", 7)
108
108
self.treeview.append_column(column)
110
110
cell = gtk.CellRendererText()
159
159
def set_branch(self, branch, start, maxnum):
160
160
"""Set the branch and start position for this window.
162
162
Creates a new TreeModel and populates it with information about
163
163
the new branch before updating the window title and model of the
166
166
self.branch = branch
168
168
# [ revision, node, last_lines, lines, message, committer, timestamp ]
169
169
self.model = gtk.ListStore(gobject.TYPE_PYOBJECT,
170
170
gobject.TYPE_PYOBJECT,
171
171
gobject.TYPE_PYOBJECT,
172
172
gobject.TYPE_PYOBJECT,
173
gobject.TYPE_PYOBJECT,
174
gobject.TYPE_PYOBJECT,
177
revids = [revision for revision in \
179
branch.repository.get_ancestry(branch.last_revision()) \
181
if revision is not None]
182
self.revisions = branch.repository.get_revisions(revids)
183
revisionparents = branch.repository.get_graph().get_parents(revids)
178
(self.revisions, colours, self.children, self.parent_ids,
179
merge_sorted) = distances(branch.repository, start)
180
for (index, (revision, node, lines)) in enumerate(graph(
181
self.revisions, colours, merge_sorted)):
188
for (index,(revision, node, lines, parents, children)) in \
189
enumerate(linegraph(self.revisions, revisionparents, maxnum)):
182
190
# FIXME: at this point we should be able to show the graph order
183
191
# and lines with no message or commit data - and then incrementally
184
192
# fill the timestamp, committer etc data as desired.
185
194
message = revision.message.split("\n")[0]
186
196
if revision.committer is not None:
187
197
timestamp = format_date(revision.timestamp, revision.timezone)
190
200
self.model.append([revision, node, last_lines, lines,
191
202
message, revision.committer, timestamp])
192
self.index[revision] = index
203
self.index[revision.revision_id] = index
193
204
last_lines = lines
194
if maxnum is not None and index > maxnum:
197
206
self.set_title(branch.nick + " - bzrk")
198
207
self.treeview.set_model(self.model)
200
208
def _treeview_cursor_cb(self, *args):
201
209
"""Callback for when the treeview cursor changes."""
202
210
(path, col) = self.treeview.get_cursor()
203
211
revision = self.model[path][0]
212
parents = self.model[path][4]
213
children = self.model[path][5]
205
self.back_button.set_sensitive(len(self.parent_ids[revision]) > 0)
206
self.fwd_button.set_sensitive(len(self.children[revision]) > 0)
215
self.back_button.set_sensitive(len(parents) > 0)
216
self.fwd_button.set_sensitive(len(children) > 0)
208
218
if self.branch.supports_tags():
209
219
tagdict = self.branch.tags.get_reverse_tag_dict()
215
225
"""Callback for when the back button is clicked."""
216
226
(path, col) = self.treeview.get_cursor()
217
227
revision = self.model[path][0]
218
if not len(self.parent_ids[revision]):
228
parents = self.model[path][4]
221
for parent_id in self.parent_ids[revision]:
222
parent = self.revisions[parent_id]
232
for parent_id in parents:
233
parent = self.revisions[self.index[parent_id]]
223
234
if same_branch(revision, parent):
224
self.treeview.set_cursor(self.index[parent])
235
self.treeview.set_cursor(self.index[parent_id])
227
next = self.revisions[self.parent_ids[revision][0]]
228
self.treeview.set_cursor(self.index[next])
238
self.treeview.set_cursor(self.index[parents[0]])
229
239
self.treeview.grab_focus()
231
241
def _fwd_clicked_cb(self, *args):
232
242
"""Callback for when the forward button is clicked."""
233
243
(path, col) = self.treeview.get_cursor()
234
244
revision = self.model[path][0]
235
if not len(self.children[revision]):
245
children = self.model[path][5]
246
if not len(children):
238
for child in self.children[revision]:
249
for child_id in children:
250
child = self.revisions[self.index[child_id]]
239
251
if same_branch(child, revision):
240
self.treeview.set_cursor(self.index[child])
252
self.treeview.set_cursor(self.index[child_id])
243
prev = list(self.children[revision])[0]
244
self.treeview.set_cursor(self.index[prev])
255
self.treeview.set_cursor(self.index[children[0]])
245
256
self.treeview.grab_focus()
247
258
def _go_clicked_cb(self, revid):
248
259
"""Callback for when the go button for a parent is clicked."""
249
self.treeview.set_cursor(self.index[self.revisions[revid]])
260
self.treeview.set_cursor(self.index[revid])
250
261
self.treeview.grab_focus()
252
263
def show_diff(self, branch, revid, parentid):