Mercurial > hg
changeset 172:e9b1147db448
hgweb: alternating colors for multifile diffs
author | mpm@selenic.com |
---|---|
date | Thu, 26 May 2005 20:37:05 -0800 |
parents | 75dddd697ed4 |
children | 8da1df932c16 |
files | mercurial/hgweb.py templates/changeset.tmpl templates/filediff.tmpl templates/header.tmpl templates/map |
diffstat | 5 files changed, 19 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hgweb.py Thu May 26 18:20:24 2005 -0800 +++ b/mercurial/hgweb.py Thu May 26 20:37:05 2005 -0800 @@ -142,7 +142,16 @@ 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 @@ 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)
--- a/templates/changeset.tmpl Thu May 26 18:20:24 2005 -0800 +++ b/templates/changeset.tmpl Thu May 26 20:37:05 2005 -0800 @@ -34,7 +34,7 @@ <td>#desc#</td></tr> </table> -<pre class="parity0"> +<pre> #diff# </pre>
--- a/templates/filediff.tmpl Thu May 26 18:20:24 2005 -0800 +++ b/templates/filediff.tmpl Thu May 26 20:37:05 2005 -0800 @@ -23,7 +23,7 @@ <td><a href="?cmd=changeset;node=#p1#">#p1#</a></td></tr> </table> -<pre class="parity0"> +<pre> #diff# </pre>
--- a/templates/header.tmpl Thu May 26 18:20:24 2005 -0800 +++ b/templates/header.tmpl Thu May 26 20:37:05 2005 -0800 @@ -5,9 +5,9 @@ <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; }
--- a/templates/map Thu May 26 18:20:24 2005 -0800 +++ b/templates/map Thu May 26 20:37:05 2005 -0800 @@ -27,3 +27,4 @@ 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>" \ No newline at end of file