Download:
child 45:978c387b91e3
parent 43:d9569e15bcc3
44:51371d1b3578
Anton Shestakov <av6@dwimlabs.net>, Mon, 28 Sep 2015 01:40:25 +0800
viewer: map all background colors into css classes, let's see how it works out

2 файлов изменено, 13 вставок(+), 6 удалений(-) [+]
templates/results.html file | annotate | diff | comparison | revisions
viewer.py file | annotate | diff | comparison | revisions
--- a/templates/results.html Mon Sep 28 00:03:36 2015 +0800
+++ b/templates/results.html Mon Sep 28 01:40:25 2015 +0800
@@ -28,6 +28,9 @@
left: 5px;
right: 5px;
}
+ {% for rgb, cc in colormap.items() %}{#
+ #}.{{ cc }} { background: rgb({{ '{},{},{}'.format(*rgb) }}); }
+ {% end %}
</style>
</head>
<body>
@@ -90,8 +93,8 @@
{% set result = results.get(cset['node'], {}) %}
{% set v1, c1, v2, c2 = result.get(mark, (None, None, None, None)) %}
<td>
- <span{% if c1 is not None %} style="background-color: rgb{{ str(c1) }};"{% end %}>&nbsp;</span>{#
- #}<span{% if c2 is not None %} style="background-color: rgb{{ str(c2) }};"{% end %}>&nbsp;</span>
+ <span{% if c1 is not None %} class="{{ colormap[c1] }}"{% end %}>&nbsp;</span>{#
+ #}<span{% if c2 is not None %} class="{{ colormap[c2] }}"{% end %}>&nbsp;</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
@@ -89,8 +89,9 @@
for mark in marks
}
- def getresults(self, changesets, marks, local=False):
+ def getresults(self, changesets, marks, local=False, colors=True):
results = {}
+ colormap = {}
limits = self.getlimits(marks, changesets if local else None)
resultsq = self.conn.execute(
@@ -107,13 +108,15 @@
else:
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
+ return results, colormap
def results_tsv(self):
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('rev\tnode')
for mark in MARKS:
self.write('\t{0} (without cache)\t{0} (with cache)'.format(mark))
@@ -217,13 +220,14 @@
marks = MARKS
moremarks = {}
local = self.get_argument('local', False)
- results = self.getresults(changesets, marks=marks, local=local)
+ results, colormap = self.getresults(changesets, marks=marks, local=local)
context = {
'changesets': changesets,
'marks': marks,
'moremarks': moremarks,
'results': results,
'local': local,
+ 'colormap': colormap,
'setlocal': self.setlocal,
'setrev': self.setrev,
'setmarks': self.setmarks(marks),