comparison mercurial/hgweb.py @ 172:e9b1147db448

hgweb: alternating colors for multifile diffs
author mpm@selenic.com
date Thu, 26 May 2005 20:37:05 -0800
parents 65cf1b0cfe86
children 8da1df932c16
comparison
equal deleted inserted replaced
171:75dddd697ed4 172:e9b1147db448
140 for f in files: 140 for f in files:
141 if f[-1] != os.sep: f += os.sep 141 if f[-1] != os.sep: f += os.sep
142 l += [ x for x in list if x.startswith(f) ] 142 l += [ x for x in list if x.startswith(f) ]
143 return l 143 return l
144 144
145 def prettyprint(diff): 145 parity = [0]
146 def diffblock(diff, f, fn):
147 yield self.t("diffblock",
148 lines = prettyprintlines(diff),
149 parity = parity[0],
150 file = f,
151 filenode = hex(fn))
152 parity[0] = 1 - parity[0]
153
154 def prettyprintlines(diff):
146 for l in diff.splitlines(1): 155 for l in diff.splitlines(1):
147 line = cgi.escape(l) 156 line = cgi.escape(l)
148 if line.startswith('+'): 157 if line.startswith('+'):
149 yield self.t("difflineplus", line = line) 158 yield self.t("difflineplus", line = line)
150 elif line.startswith('-'): 159 elif line.startswith('-'):
168 c, a, d = map(lambda x: filterfiles(x, files), (c, a, d)) 177 c, a, d = map(lambda x: filterfiles(x, files), (c, a, d))
169 178
170 for f in c: 179 for f in c:
171 to = r.file(f).read(mmap1[f]) 180 to = r.file(f).read(mmap1[f])
172 tn = r.file(f).read(mmap2[f]) 181 tn = r.file(f).read(mmap2[f])
173 yield prettyprint(mdiff.unidiff(to, date1, tn, date2, f)) 182 yield diffblock(mdiff.unidiff(to, date1, tn, date2, f), f, tn)
174 for f in a: 183 for f in a:
175 to = "" 184 to = ""
176 tn = r.file(f).read(mmap2[f]) 185 tn = r.file(f).read(mmap2[f])
177 yield prettyprint(mdiff.unidiff(to, date1, tn, date2, f)) 186 yield diffblock(mdiff.unidiff(to, date1, tn, date2, f), f, tn)
178 for f in d: 187 for f in d:
179 to = r.file(f).read(mmap1[f]) 188 to = r.file(f).read(mmap1[f])
180 tn = "" 189 tn = ""
181 yield prettyprint(mdiff.unidiff(to, date1, tn, date2, f)) 190 yield diffblock(mdiff.unidiff(to, date1, tn, date2, f), f, tn)
182 191
183 def header(self): 192 def header(self):
184 yield self.t("header", repo = self.reponame) 193 yield self.t("header", repo = self.reponame)
185 194
186 def footer(self): 195 def footer(self):