--- a/templates/results.html Mon Sep 28 00:03:36 2015 +0800
+++ b/templates/results.html Mon Sep 28 01:40:25 2015 +0800
+ {% for rgb, cc in colormap.items() %}{#
+ #}.{{ cc }} { background: rgb({{ '{},{},{}'.format(*rgb) }}); }
{% set result = results.get(cset['node'], {}) %}
{% set v1, c1, v2, c2 = result.get(mark, (None, None, None, None)) %}
- <span{% if c1 is not None %} style="background-color: rgb{{ str(c1) }};"{% end %}> </span>{#
- #}<span{% if c2 is not None %} style="background-color: rgb{{ str(c2) }};"{% end %}> </span>
+ <span{% if c1 is not None %} class="{{ colormap[c1] }}"{% end %}> </span>{#
+ #}<span{% if c2 is not None %} class="{{ colormap[c2] }}"{% end %}> </span>
<span title="{{ v1 }} without .hg/cache">{{ '{:.2f}s'.format(v1) if v1 is not None else '-' }}</span>{#
#}<span title="{{ v2 }} with .hg/cache">{{ '{:.2f}s'.format(v2) if v2 is not None else '-' }}</span>
--- a/viewer.py Mon Sep 28 00:03:36 2015 +0800
+++ b/viewer.py Mon Sep 28 01:40:25 2015 +0800
- def getresults(self, changesets, marks, local=False):
+ def getresults(self, changesets, marks, local=False, colors=True):
limits = self.getlimits(marks, changesets if local else None)
resultsq = self.conn.execute(
color = green_to_red(limits[mark][2:4], time) if time is not None else None
results[node][mark][2:4] = [time, color]
+ if colors and color not in colormap:
+ colormap[color] = 'c{}'.format(len(colormap))
+ return results, colormap
self.set_header('Content-Type', 'text/plain; charset=UTF-8')
changesets = self.getchangesets()
- results = self.getresults(changesets, MARKS)
+ results, _ = self.getresults(changesets, MARKS, colors=False)
self.write('\t{0} (without cache)\t{0} (with cache)'.format(mark))
local = self.get_argument('local', False)
- results = self.getresults(changesets, marks=marks, local=local)
+ results, colormap = self.getresults(changesets, marks=marks, local=local)
'changesets': changesets,
'setlocal': self.setlocal,
'setmarks': self.setmarks(marks),