hgweb: alternating colors for multifile diffs

This commit is contained in:
mpm@selenic.com 2005-05-26 20:37:05 -08:00
parent 3d6a44cc6c
commit 1dd7e5c920
5 changed files with 19 additions and 9 deletions

View File

@ -142,7 +142,16 @@ class hgweb:
l += [ x for x in list if x.startswith(f) ]
return l
def prettyprint(diff):
parity = [0]
def diffblock(diff, f, fn):
yield self.t("diffblock",
lines = prettyprintlines(diff),
parity = parity[0],
file = f,
filenode = hex(fn))
parity[0] = 1 - parity[0]
def prettyprintlines(diff):
for l in diff.splitlines(1):
line = cgi.escape(l)
if line.startswith('+'):
@ -170,15 +179,15 @@ class hgweb:
for f in c:
to = r.file(f).read(mmap1[f])
tn = r.file(f).read(mmap2[f])
yield prettyprint(mdiff.unidiff(to, date1, tn, date2, f))
yield diffblock(mdiff.unidiff(to, date1, tn, date2, f), f, tn)
for f in a:
to = ""
tn = r.file(f).read(mmap2[f])
yield prettyprint(mdiff.unidiff(to, date1, tn, date2, f))
yield diffblock(mdiff.unidiff(to, date1, tn, date2, f), f, tn)
for f in d:
to = r.file(f).read(mmap1[f])
tn = ""
yield prettyprint(mdiff.unidiff(to, date1, tn, date2, f))
yield diffblock(mdiff.unidiff(to, date1, tn, date2, f), f, tn)
def header(self):
yield self.t("header", repo = self.reponame)

View File

@ -34,7 +34,7 @@
<td>#desc#</td></tr>
</table>
<pre class="parity0">
<pre>
#diff#
</pre>

View File

@ -23,7 +23,7 @@
<td><a href="?cmd=changeset;node=#p1#">#p1#</a></td></tr>
</table>
<pre class="parity0">
<pre>
#diff#
</pre>

View File

@ -5,9 +5,9 @@ Content-type: text/html
<head>
<style type="text/css">
a { text-decoration:none; }
.parity0 { background-color: #eeeeee; }
.parity1 { background-color: #f8f8f8; }
.lineno { width: 60px; color: #cccccc; font-size: smaller; }
.parity0 { background-color: #dddddd; }
.parity1 { background-color: #eeeeee; }
.lineno { width: 60px; color: #aaaaaa; font-size: smaller; }
.plusline { color: green; }
.minusline { color: red; }
.atline { color: purple; }

View File

@ -27,3 +27,4 @@ filerevparent = "<tr><td class="metatag">parent:</td><td><a href="?cmd=file;file
fileannotateparent = "<tr><td class="metatag">parent:</td><td><a href="?cmd=annotate;file=#file#;filenode=#node#">#node#</a></td></tr>"
tags = tags.tmpl
tagentry = "<div class="parity#parity#"><tt>#node#</tt> <a href="?cmd=changeset;node=#node#">#tag#</a><br /></div>"
diffblock = "<div class="parity#parity#">#lines#</div>"