Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/hgweb/hgweb_mod.py @ 3208:e7b7906cc47e
hgweb: teach siblings and callers to use contexts
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Fri, 29 Sep 2006 16:26:09 -0700 |
parents | 79fd7a92f3e2 |
children | 325278542ea8 |
comparison
equal
deleted
inserted
replaced
3207:0790dce2f3a8 | 3208:e7b7906cc47e |
---|---|
68 for f in files[:self.maxfiles]: | 68 for f in files[:self.maxfiles]: |
69 yield self.t("filedifflink", node=hex(changeset), file=f) | 69 yield self.t("filedifflink", node=hex(changeset), file=f) |
70 if len(files) > self.maxfiles: | 70 if len(files) > self.maxfiles: |
71 yield self.t("fileellipses") | 71 yield self.t("fileellipses") |
72 | 72 |
73 def siblings(self, siblings=[], rev=None, hiderev=None, **args): | 73 def siblings(self, siblings=[], hiderev=None, **args): |
74 if not rev: | 74 siblings = [s for s in siblings if s.node() != nullid] |
75 rev = lambda x: "" | 75 if len(siblings) == 1 and siblings[0].rev() == hiderev: |
76 siblings = [s for s in siblings if s != nullid] | |
77 if len(siblings) == 1 and rev(siblings[0]) == hiderev: | |
78 return | 76 return |
79 for s in siblings: | 77 for s in siblings: |
80 yield dict(node=hex(s), rev=rev(s), **args) | 78 yield dict(node=hex(s.node()), rev=s.rev(), **args) |
81 | 79 |
82 def renamelink(self, fl, node): | 80 def renamelink(self, fl, node): |
83 r = fl.renamed(node) | 81 r = fl.renamed(node) |
84 if r: | 82 if r: |
85 return [dict(file=r[0], node=hex(r[1]))] | 83 return [dict(file=r[0], node=hex(r[1]))] |
189 def changelist(**map): | 187 def changelist(**map): |
190 parity = (start - end) & 1 | 188 parity = (start - end) & 1 |
191 cl = self.repo.changelog | 189 cl = self.repo.changelog |
192 l = [] # build a list in forward order for efficiency | 190 l = [] # build a list in forward order for efficiency |
193 for i in range(start, end): | 191 for i in range(start, end): |
194 n = cl.node(i) | 192 ctx = self.repo.changectx(i) |
195 changes = cl.read(n) | 193 n = ctx.node() |
196 hn = hex(n) | |
197 | 194 |
198 l.insert(0, {"parity": parity, | 195 l.insert(0, {"parity": parity, |
199 "author": changes[1], | 196 "author": ctx.user(), |
200 "parent": self.siblings(cl.parents(n), cl.rev, | 197 "parent": self.siblings(ctx.parents(), i - 1), |
201 cl.rev(n) - 1), | 198 "child": self.siblings(ctx.children(), i + 1), |
202 "child": self.siblings(cl.children(n), cl.rev, | |
203 cl.rev(n) + 1), | |
204 "changelogtag": self.showtag("changelogtag",n), | 199 "changelogtag": self.showtag("changelogtag",n), |
205 "desc": changes[4], | 200 "desc": ctx.description(), |
206 "date": changes[2], | 201 "date": ctx.date(), |
207 "files": self.listfilediffs(changes[3], n), | 202 "files": self.listfilediffs(ctx.files(), n), |
208 "rev": i, | 203 "rev": i, |
209 "node": hn}) | 204 "node": hex(n)}) |
210 parity = 1 - parity | 205 parity = 1 - parity |
211 | 206 |
212 for e in l: | 207 for e in l: |
213 yield e | 208 yield e |
214 | 209 |
235 | 230 |
236 def revgen(): | 231 def revgen(): |
237 for i in range(cl.count() - 1, 0, -100): | 232 for i in range(cl.count() - 1, 0, -100): |
238 l = [] | 233 l = [] |
239 for j in range(max(0, i - 100), i): | 234 for j in range(max(0, i - 100), i): |
240 n = cl.node(j) | 235 ctx = self.repo.changectx(j) |
241 changes = cl.read(n) | 236 l.append(ctx) |
242 l.append((n, j, changes)) | |
243 l.reverse() | 237 l.reverse() |
244 for e in l: | 238 for e in l: |
245 yield e | 239 yield e |
246 | 240 |
247 for n, i, changes in revgen(): | 241 for ctx in revgen(): |
248 miss = 0 | 242 miss = 0 |
249 for q in qw: | 243 for q in qw: |
250 if not (q in changes[1].lower() or | 244 if not (q in ctx.user().lower() or |
251 q in changes[4].lower() or | 245 q in ctx.description().lower() or |
252 q in " ".join(changes[3][:20]).lower()): | 246 q in " ".join(ctx.files()[:20]).lower()): |
253 miss = 1 | 247 miss = 1 |
254 break | 248 break |
255 if miss: | 249 if miss: |
256 continue | 250 continue |
257 | 251 |
258 count += 1 | 252 count += 1 |
259 hn = hex(n) | 253 n = ctx.node() |
260 | 254 |
261 yield self.t('searchentry', | 255 yield self.t('searchentry', |
262 parity=self.stripes(count), | 256 parity=self.stripes(count), |
263 author=changes[1], | 257 author=ctx.user(), |
264 parent=self.siblings(cl.parents(n), cl.rev), | 258 parent=self.siblings(ctx.parents()), |
265 child=self.siblings(cl.children(n), cl.rev), | 259 child=self.siblings(ctx.children()), |
266 changelogtag=self.showtag("changelogtag",n), | 260 changelogtag=self.showtag("changelogtag",n), |
267 desc=changes[4], | 261 desc=ctx.description(), |
268 date=changes[2], | 262 date=ctx.date(), |
269 files=self.listfilediffs(changes[3], n), | 263 files=self.listfilediffs(ctx.files(), n), |
270 rev=i, | 264 rev=ctx.rev(), |
271 node=hn) | 265 node=hex(n)) |
272 | 266 |
273 if count >= self.maxchanges: | 267 if count >= self.maxchanges: |
274 break | 268 break |
275 | 269 |
276 cl = self.repo.changelog | 270 cl = self.repo.changelog |
277 mf = cl.read(cl.tip())[0] | |
278 | 271 |
279 yield self.t('search', | 272 yield self.t('search', |
280 query=query, | 273 query=query, |
281 node=hex(cl.tip()), | 274 node=hex(cl.tip()), |
282 entries=changelist) | 275 entries=changelist) |
283 | 276 |
284 def changeset(self, nodeid): | 277 def changeset(self, nodeid): |
285 cl = self.repo.changelog | 278 ctx = self.repo.changectx(nodeid) |
286 n = self.repo.lookup(nodeid) | 279 n = ctx.node() |
287 nodeid = hex(n) | 280 parents = ctx.parents() |
288 changes = cl.read(n) | 281 p1 = parents[0].node() |
289 p1 = cl.parents(n)[0] | |
290 | 282 |
291 files = [] | 283 files = [] |
292 mf = self.repo.manifest.read(changes[0]) | |
293 parity = 0 | 284 parity = 0 |
294 for f in changes[3]: | 285 for f in ctx.files(): |
295 files.append(self.t("filenodelink", | 286 files.append(self.t("filenodelink", |
296 node=hex(n), file=f, | 287 node=hex(n), file=f, |
297 parity=parity)) | 288 parity=parity)) |
298 parity = 1 - parity | 289 parity = 1 - parity |
299 | 290 |
300 def diff(**map): | 291 def diff(**map): |
301 yield self.diff(p1, n, None) | 292 yield self.diff(p1, n, None) |
302 | 293 |
303 yield self.t('changeset', | 294 yield self.t('changeset', |
304 diff=diff, | 295 diff=diff, |
305 rev=cl.rev(n), | 296 rev=ctx.rev(), |
306 node=nodeid, | 297 node=hex(n), |
307 parent=self.siblings(cl.parents(n), cl.rev), | 298 parent=self.siblings(parents), |
308 child=self.siblings(cl.children(n), cl.rev), | 299 child=self.siblings(ctx.children()), |
309 changesettag=self.showtag("changesettag",n), | 300 changesettag=self.showtag("changesettag",n), |
310 author=changes[1], | 301 author=ctx.user(), |
311 desc=changes[4], | 302 desc=ctx.description(), |
312 date=changes[2], | 303 date=ctx.date(), |
313 files=files, | 304 files=files, |
314 archives=self.archivelist(nodeid)) | 305 archives=self.archivelist(nodeid)) |
315 | 306 |
316 def filelog(self, fctx): | 307 def filelog(self, fctx): |
317 f = fctx.path() | 308 f = fctx.path() |
322 def entries(**map): | 313 def entries(**map): |
323 l = [] | 314 l = [] |
324 parity = (count - 1) & 1 | 315 parity = (count - 1) & 1 |
325 | 316 |
326 for i in range(count): | 317 for i in range(count): |
318 ctx = fctx.filectx(i) | |
327 n = fl.node(i) | 319 n = fl.node(i) |
328 lr = fl.linkrev(n) | |
329 ctx = self.repo.changectx(lr) | |
330 | 320 |
331 l.insert(0, {"parity": parity, | 321 l.insert(0, {"parity": parity, |
332 "filerev": i, | 322 "filerev": i, |
333 "file": f, | 323 "file": f, |
334 "node": hex(ctx.node()), | 324 "node": hex(ctx.node()), |
335 "author": ctx.user(), | 325 "author": ctx.user(), |
336 "date": ctx.date(), | 326 "date": ctx.date(), |
337 "rename": self.renamelink(fl, n), | 327 "rename": self.renamelink(fl, n), |
338 "parent": self.siblings(fl.parents(n), | 328 "parent": self.siblings(fctx.parents(), file=f), |
339 fl.rev, file=f), | 329 "child": self.siblings(fctx.children(), file=f), |
340 "child": self.siblings(fl.children(n), | |
341 fl.rev, file=f), | |
342 "desc": ctx.description()}) | 330 "desc": ctx.description()}) |
343 parity = 1 - parity | 331 parity = 1 - parity |
344 | 332 |
345 for e in l: | 333 for e in l: |
346 yield e | 334 yield e |
374 mimetype=mt, | 362 mimetype=mt, |
375 rev=fctx.rev(), | 363 rev=fctx.rev(), |
376 node=hex(fctx.node()), | 364 node=hex(fctx.node()), |
377 author=fctx.user(), | 365 author=fctx.user(), |
378 date=fctx.date(), | 366 date=fctx.date(), |
379 parent=self.siblings(fl.parents(n), fl.rev, file=f), | 367 parent=self.siblings(fctx.parents(), file=f), |
380 child=self.siblings(fl.children(n), fl.rev, file=f), | 368 child=self.siblings(fctx.children(), file=f), |
381 rename=self.renamelink(fl, n), | 369 rename=self.renamelink(fl, n), |
382 permissions=fctx.manifest().execf(f)) | 370 permissions=fctx.manifest().execf(f)) |
383 | 371 |
384 def fileannotate(self, fctx): | 372 def fileannotate(self, fctx): |
385 f = fctx.path() | 373 f = fctx.path() |
411 rev=fctx.rev(), | 399 rev=fctx.rev(), |
412 node=hex(fctx.node()), | 400 node=hex(fctx.node()), |
413 author=fctx.user(), | 401 author=fctx.user(), |
414 date=fctx.date(), | 402 date=fctx.date(), |
415 rename=self.renamelink(fl, n), | 403 rename=self.renamelink(fl, n), |
416 parent=self.siblings(fl.parents(n), fl.rev, file=f), | 404 parent=self.siblings(fctx.parents(), file=f), |
417 child=self.siblings(fl.children(n), fl.rev, file=f), | 405 child=self.siblings(fctx.children(), file=f), |
418 permissions=fctx.manifest().execf(f)) | 406 permissions=fctx.manifest().execf(f)) |
419 | 407 |
420 def manifest(self, ctx, path): | 408 def manifest(self, ctx, path): |
421 mf = ctx.manifest() | 409 mf = ctx.manifest() |
422 node = ctx.node() | 410 node = ctx.node() |
563 shortlog = changelist, | 551 shortlog = changelist, |
564 node = hex(self.repo.changelog.tip()), | 552 node = hex(self.repo.changelog.tip()), |
565 archives=self.archivelist("tip")) | 553 archives=self.archivelist("tip")) |
566 | 554 |
567 def filediff(self, file, changeset): | 555 def filediff(self, file, changeset): |
568 cl = self.repo.changelog | 556 ctx = self.repo.changectx(changeset) |
569 n = self.repo.lookup(changeset) | 557 n = ctx.node() |
570 changeset = hex(n) | 558 parents = ctx.parents() |
571 p1 = cl.parents(n)[0] | 559 p1 = parents[0].node() |
572 cs = cl.read(n) | |
573 mf = self.repo.manifest.read(cs[0]) | |
574 | 560 |
575 def diff(**map): | 561 def diff(**map): |
576 yield self.diff(p1, n, [file]) | 562 yield self.diff(p1, n, [file]) |
577 | 563 |
578 yield self.t("filediff", | 564 yield self.t("filediff", |
579 file=file, | 565 file=file, |
580 filenode=hex(mf.get(file, nullid)), | 566 node=hex(n), |
581 node=changeset, | 567 rev=ctx.rev(), |
582 rev=self.repo.changelog.rev(n), | 568 parent=self.siblings(parents), |
583 parent=self.siblings(cl.parents(n), cl.rev), | 569 child=self.siblings(ctx.children()), |
584 child=self.siblings(cl.children(n), cl.rev), | |
585 diff=diff) | 570 diff=diff) |
586 | 571 |
587 archive_specs = { | 572 archive_specs = { |
588 'bz2': ('application/x-tar', 'tbz2', '.tar.bz2', None), | 573 'bz2': ('application/x-tar', 'tbz2', '.tar.bz2', None), |
589 'gz': ('application/x-tar', 'tgz', '.tar.gz', None), | 574 'gz': ('application/x-tar', 'tgz', '.tar.gz', None), |