Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

repomodel: Log now displays tags (very hacky!)

Can't resist hacking together (very quickly) an example using
the previous two patches to get tags in Log column.

Changeset 454503f93571

Parent fec1b1a1bc98

by George Marrows

Changes to 2 files · Browse files at 454503f93571 Showing diff from parent fec1b1a1bc98 Diff from another changeset...

 
20
21
22
 
 
23
24
25
 
57
58
59
60
 
61
62
63
 
65
66
67
68
 
69
70
71
72
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
75
76
77
78
79
80
 
 
81
82
83
 
 
84
85
86
 
 
87
88
89
 
374
375
376
377
 
378
379
380
 
20
21
22
23
24
25
26
27
 
59
60
61
 
62
63
64
65
 
67
68
69
 
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
 
 
105
106
107
 
 
108
109
110
 
 
111
112
113
114
115
 
400
401
402
 
403
404
405
406
@@ -20,6 +20,8 @@
 from tortoisehg.hgqt.graph import Graph  from tortoisehg.hgqt.graph import revision_grapher  from tortoisehg.hgqt.qtlib import geticon +from tortoisehg.hgqt import qtlib +    from tortoisehg.hgqt.i18n import _   @@ -57,7 +59,7 @@
  date, tzdelay = date   return QDateTime.fromTime_t(int(date)).toString(Qt.LocaleDate)   -def gettags(ctx, gnode): +def gettags(ctx, gnode, repo):   if ctx.rev() is None:   return ""   mqtags = ['qbase', 'qtip', 'qparent'] @@ -65,25 +67,49 @@
  tags = [t for t in tags if t not in mqtags]   return tounicode(",".join(tags))   -def getlog(ctx, gnode): +def getlog(ctx, gnode, repo):   # TODO: add branch name / tag markups   if ctx.rev() is not None:   msg = tounicode(ctx.description())   if msg:   msg = msg.splitlines()[0] + + node = ctx.node() + tags = repo.nodetags(node) + tstr = '' + for tag in tags: + # FIXME if tag not in self.hidetags: + bg = "yellow" + #if tag == self.curbookmark: + # bg = "orange" + #elif tag in self.mqpatches: + # bg = "blue" + style = {'fg': "black", 'bg': bg} + tstr += qtlib.markup(' %s ' % tag, **style) + ' ' + + branch = ctx.branch() + bstr = '' + #if self.branchtags.get(branch) == node: + # bstr += gtklib.markup(' %s ' % branch, color=gtklib.BLACK, + # background=gtklib.PGREEN) + ' ' + #if revid in self.wcparents: + # sumstr = bstr + tstr + '<b><u>' + summary + '</u></b>' + #else: + msg = bstr + tstr + msg +   else:   msg = '** ' + _('Working copy changes') + ' **'   return msg    # XXX maybe it's time to make these methods of the model... -_columnmap = {'ID': lambda ctx, gnode: ctx.rev() is not None and str(ctx.rev()) or "", - 'Graph': lambda ctx, gnode: "", +_columnmap = {'ID': lambda ctx, gnode, repo: ctx.rev() is not None and str(ctx.rev()) or "", + 'Graph': lambda ctx, gnode, repo: "",   'Log': getlog, - 'Author': lambda ctx, gnode: templatefilters.person(ctx.user()), - 'Date': lambda ctx, gnode: cvrt_date(ctx.date()), + 'Author': lambda ctx, gnode, repo: templatefilters.person(ctx.user()), + 'Date': lambda ctx, gnode, repo: cvrt_date(ctx.date()),   'Tags': gettags, - 'Branch': lambda ctx, gnode: ctx.branch(), - 'Filename': lambda ctx, gnode: gnode.extra[0], + 'Branch': lambda ctx, gnode, repo: ctx.branch(), + 'Filename': lambda ctx, gnode, repo: gnode.extra[0],   }    # in following lambdas, r is a hg repo @@ -374,7 +400,7 @@
  gnode = self.graph[row]   ctx = self.repo.changectx(gnode.rev)   if role == Qt.DisplayRole: - text = _columnmap[column](ctx, gnode) + text = _columnmap[column](ctx, gnode, self.repo)   if not isinstance(text, (QString, unicode)):   text = tounicode(text)   return QVariant(text)
 
88
89
90
91
92
 
 
93
94
95
 
88
89
90
 
 
91
92
93
94
95
@@ -88,8 +88,8 @@
  model = index.model()   record = model.data(index, Qt.DisplayRole)   doc = QTextDocument(self) - opts = dict(fg='black', bg='#ffffaa') # FIXME expect this from the model - doc.setHtml(qtlib.markup(str(record.toString()), **opts)) + #opts = dict(fg='black', bg='#ffffaa') # FIXME expect this from the model + doc.setHtml(str(record.toString()))   doc.setTextWidth(option.rect.width())   painter.save()   painter.translate(option.rect.topLeft());