23
23
from bzrlib import lazy_regex
24
24
from bzrlib.revision import NULL_REVISION, CURRENT_REVISION
26
from bzrlib.plugins.qbzr.lib.bugs import get_bug_id
25
27
from bzrlib.plugins.qbzr.lib.loggraphprovider import LogGraphProvider
26
28
from bzrlib.plugins.qbzr.lib.lazycachedrevloader import cached_revisions
27
29
from bzrlib.plugins.qbzr.lib.revtreeview import RevIdRole as im_RevIdRole
52
_bug_id_re = lazy_regex.lazy_compile(r'(?:'
53
r'bugs/' # Launchpad bugs URL
54
r'|ticket/' # Trac bugs URL
55
r'|show_bug\.cgi\?id=' # Bugzilla bugs URL
56
r'|issues/show/' # Redmine bugs URL
57
r'|DispForm.aspx\?ID=' # Microsoft SharePoint URL
58
r'|default.asp\?' # Fogbugz URL
59
r'|issue' # Roundup issue tracker URL
60
r'|view.php\?id=' # Mantis bug tracker URL
64
def get_bug_id(bug_url):
65
match = _bug_id_re.search(bug_url)
71
56
QVariant_fromList = QtCore.QVariant.fromList
136
121
self.graph_provider.compute_graph_lines()
137
122
self.emit(QtCore.SIGNAL("dataChanged(QModelIndex, QModelIndex)"),
138
123
self.createIndex (0, COL_MESSAGE, QtCore.QModelIndex()),
139
self.createIndex (len(self.graph_provider.merge_sorted_revisions),
124
self.createIndex (len(self.graph_provider.revisions),
140
125
COL_MESSAGE, QtCore.QModelIndex()))
126
self.emit(QtCore.SIGNAL("linesUpdated()"))
142
128
def colapse_expand_rev(self, revid, visible):
143
self.clicked_row = self.graph_provider.revid_msri[revid]
129
self.clicked_row = self.graph_provider.revid_rev[revid].index
144
130
clicked_row_index = self.createIndex (self.clicked_row,
146
132
QtCore.QModelIndex())
178
164
def rowCount(self, parent):
179
165
if parent.isValid():
181
return len(self.graph_provider.merge_sorted_revisions)
167
return len(self.graph_provider.revisions)
183
169
def data(self, index, role):
184
170
if not index.isValid():
185
171
return QtCore.QVariant()
187
if index.row() in self.graph_provider.msri_index \
188
and len(self.graph_provider.graph_line_data)> \
189
self.graph_provider.msri_index[index.row()]:
194
twisty_branch_ids) = self.graph_provider.graph_line_data\
195
[self.graph_provider.msri_index[index.row()]]
201
twisty_branch_ids) = (index.row(), None, [], None, [])
174
gp = self.graph_provider
175
if self.last_rev_is_placeholder and \
176
index.row() == len(gp.revisions) - 1:
177
if role == GraphNodeRole:
178
return QVariant_fromList([QtCore.QVariant(-1),
180
return QtCore.QVariant()
182
rev_info = gp.revisions[index.row()]
203
184
if role == GraphLinesRole:
205
for start, end, color, direct in lines:
186
for start, end, color, direct in rev_info.lines:
206
187
qlines.append(QVariant_fromList(
207
188
[QtCore.QVariant(start),
208
189
QtCore.QVariant(end),
211
192
return QVariant_fromList(qlines)
213
194
if self.last_rev_is_placeholder and \
214
msri == len(self.graph_provider.merge_sorted_revisions) - 1:
195
rev_info.index == len(self.graph_provider.revisions) - 1:
215
196
if role == GraphNodeRole:
216
197
return QVariant_fromList([QtCore.QVariant(-1), QtCore.QVariant(0)])
217
198
if role == QtCore.Qt.DisplayRole:
219
200
return QtCore.QVariant()
221
202
if role == GraphNodeRole:
203
if rev_info.col_index is None:
223
204
return QtCore.QVariant()
224
return QVariant_fromList([QtCore.QVariant(nodei) for nodei in node])
205
return QVariant_fromList([QtCore.QVariant(rev_info.col_index),
206
QtCore.QVariant(rev_info.color)])
226
208
if role == GraphTwistyStateRole:
227
if twisty_state is None:
209
if rev_info.twisty_state is None:
228
210
return QtCore.QVariant()
229
211
if index.row() == self.clicked_row:
230
212
return QtCore.QVariant(-1)
231
return QtCore.QVariant(twisty_state)
233
(sequence_number, revid, merge_depth, revno_sequence, end_of_merge) = \
234
self.graph_provider.merge_sorted_revisions[index.row()]
213
return QtCore.QVariant(rev_info.twisty_state)
236
215
if (role == QtCore.Qt.DisplayRole and index.column() == COL_REV) :
237
revnos = ".".join(["%d" % (revno)
238
for revno in revno_sequence])
239
if revid == CURRENT_REVISION:
241
return QtCore.QVariant(revnos)
216
return QtCore.QVariant(rev_info.revno_str)
243
218
if (role == QtCore.Qt.DisplayRole and index.column() == COL_MERGE_DEPTH) :
244
return QtCore.QVariant("%d" % merge_depth)
219
return QtCore.QVariant("%d" % rev_info.merge_depth)
246
221
if role == TagsRole:
248
if revid in self.graph_provider.tags:
249
tags = list(self.graph_provider.tags[revid])
223
if rev_info.revid in gp.tags:
224
tags = list(gp.tags[rev_info.revid])
250
225
return QtCore.QVariant(QtCore.QStringList(tags))
252
227
if role == BranchTagsRole:
254
if revid in self.graph_provider.branch_tags:
229
if rev_info.revid in gp.branch_tags:
255
230
tags = [tag for tag \
256
in self.graph_provider.branch_tags[revid] if tag]
231
in gp.branch_tags[rev_info.revid] if tag]
257
232
return QtCore.QVariant(QtCore.QStringList(tags))
259
234
if role == RevIdRole:
260
return QtCore.QVariant(revid)
235
return QtCore.QVariant(rev_info.revid)
262
237
#Everything from here foward will need to have the revision loaded.
263
if not revid or revid not in cached_revisions:
238
if rev_info.revid not in cached_revisions:
264
239
if role == QtCore.Qt.DisplayRole:
265
240
return QtCore.QVariant("")
266
241
return QtCore.QVariant()
268
revision = cached_revisions[revid]
243
revision = cached_revisions[rev_info.revid]
270
245
if role == QtCore.Qt.DisplayRole and index.column() == COL_DATE:
271
246
return QtCore.QVariant(strftime("%Y-%m-%d %H:%M",
304
279
def indexFromRevId(self, revid, columns=None):
305
msri = self.graph_provider.revid_msri[revid]
280
rev = self.graph_provider.revid_rev[revid]
307
return [self.index (msri, column, QtCore.QModelIndex())\
282
return [self.index (rev.index, column, QtCore.QModelIndex())\
308
283
for column in columns]
309
return self.index (msri, 0, QtCore.QModelIndex())
284
return self.index (rev.index, 0, QtCore.QModelIndex())
311
286
def on_revisions_loaded(self, revisions, last_call):
312
287
for revid in revisions.iterkeys():