Show More
@@ -198,32 +198,31 b' class hgweb(object):' | |||||
198 |
|
198 | |||
199 | # actually process the request |
|
199 | # actually process the request | |
200 |
|
200 | |||
201 | self.templater(req) |
|
|||
202 | try: |
|
201 | try: | |
203 | if not req.form.has_key('cmd'): |
|
|||
204 | req.form['cmd'] = [self.t.cache['default']] |
|
|||
205 |
|
202 | |||
206 |
cmd = req.form |
|
203 | cmd = req.form.get('cmd', [''])[0] | |
207 |
|
204 | if hasattr(protocol, cmd): | ||
208 | try: |
|
205 | method = getattr(protocol, cmd) | |
209 | if hasattr(protocol, cmd): |
|
|||
210 | method = getattr(protocol, cmd) |
|
|||
211 | else: |
|
|||
212 | method = getattr(webcommands, cmd) |
|
|||
213 | method(self, req) |
|
206 | method(self, req) | |
214 | except revlog.LookupError, err: |
|
207 | else: | |
215 |
|
|
208 | tmpl = self.templater(req) | |
216 | 'error', error='revision not found: %s' % err.name)) |
|
209 | if cmd == '': | |
217 | except (hg.RepoError, revlog.RevlogError), inst: |
|
210 | req.form['cmd'] = [tmpl.cache['default']] | |
218 | req.respond('500 Internal Server Error', |
|
211 | cmd = req.form['cmd'][0] | |
219 | self.t('error', error=str(inst))) |
|
212 | method = getattr(webcommands, cmd) | |
220 | except ErrorResponse, inst: |
|
213 | method(self, req, tmpl) | |
221 | req.respond(inst.code, self.t('error', error=inst.message)) |
|
214 | del tmpl | |
222 | except AttributeError: |
|
215 | ||
223 | req.respond(400, |
|
216 | except revlog.LookupError, err: | |
224 | self.t('error', error='No such method: ' + cmd)) |
|
217 | req.respond(404, tmpl( | |
225 | finally: |
|
218 | 'error', error='revision not found: %s' % err.name)) | |
226 | self.t = None |
|
219 | except (hg.RepoError, revlog.RevlogError), inst: | |
|
220 | req.respond('500 Internal Server Error', | |||
|
221 | tmpl('error', error=str(inst))) | |||
|
222 | except ErrorResponse, inst: | |||
|
223 | req.respond(inst.code, tmpl('error', error=inst.message)) | |||
|
224 | except AttributeError: | |||
|
225 | req.respond(400, tmpl('error', error='No such method: ' + cmd)) | |||
227 |
|
226 | |||
228 | def templater(self, req): |
|
227 | def templater(self, req): | |
229 |
|
228 | |||
@@ -249,7 +248,7 b' class hgweb(object):' | |||||
249 |
|
248 | |||
250 | def header(**map): |
|
249 | def header(**map): | |
251 | header_file = cStringIO.StringIO( |
|
250 | header_file = cStringIO.StringIO( | |
252 |
''.join( |
|
251 | ''.join(tmpl("header", encoding=self.encoding, **map))) | |
253 | msg = mimetools.Message(header_file, 0) |
|
252 | msg = mimetools.Message(header_file, 0) | |
254 | req.header(msg.items()) |
|
253 | req.header(msg.items()) | |
255 | yield header_file.read() |
|
254 | yield header_file.read() | |
@@ -261,7 +260,7 b' class hgweb(object):' | |||||
261 | yield '' |
|
260 | yield '' | |
262 |
|
261 | |||
263 | def footer(**map): |
|
262 | def footer(**map): | |
264 |
yield |
|
263 | yield tmpl("footer", **map) | |
265 |
|
264 | |||
266 | def motd(**map): |
|
265 | def motd(**map): | |
267 | yield self.config("web", "motd", "") |
|
266 | yield self.config("web", "motd", "") | |
@@ -292,17 +291,18 b' class hgweb(object):' | |||||
292 |
|
291 | |||
293 | # create the templater |
|
292 | # create the templater | |
294 |
|
293 | |||
295 |
|
|
294 | tmpl = templater.templater(mapfile, templater.common_filters, | |
296 |
|
|
295 | defaults={"url": req.url, | |
297 |
|
|
296 | "staticurl": staticurl, | |
298 |
|
|
297 | "urlbase": urlbase, | |
299 |
|
|
298 | "repo": self.reponame, | |
300 |
|
|
299 | "header": header, | |
301 |
|
|
300 | "footer": footer, | |
302 |
|
|
301 | "motd": motd, | |
303 |
|
|
302 | "rawfileheader": rawfileheader, | |
304 |
|
|
303 | "sessionvars": sessionvars | |
305 |
|
|
304 | }) | |
|
305 | return tmpl | |||
306 |
|
306 | |||
307 | def archivelist(self, nodeid): |
|
307 | def archivelist(self, nodeid): | |
308 | allowed = self.configlist("web", "allow_archive") |
|
308 | allowed = self.configlist("web", "allow_archive") | |
@@ -310,11 +310,11 b' class hgweb(object):' | |||||
310 | if i in allowed or self.configbool("web", "allow" + i): |
|
310 | if i in allowed or self.configbool("web", "allow" + i): | |
311 | yield {"type" : i, "extension" : spec[2], "node" : nodeid} |
|
311 | yield {"type" : i, "extension" : spec[2], "node" : nodeid} | |
312 |
|
312 | |||
313 | def listfilediffs(self, files, changeset): |
|
313 | def listfilediffs(self, tmpl, files, changeset): | |
314 | for f in files[:self.maxfiles]: |
|
314 | for f in files[:self.maxfiles]: | |
315 |
yield |
|
315 | yield tmpl("filedifflink", node=hex(changeset), file=f) | |
316 | if len(files) > self.maxfiles: |
|
316 | if len(files) > self.maxfiles: | |
317 |
yield |
|
317 | yield tmpl("fileellipses") | |
318 |
|
318 | |||
319 | def siblings(self, siblings=[], hiderev=None, **args): |
|
319 | def siblings(self, siblings=[], hiderev=None, **args): | |
320 | siblings = [s for s in siblings if s.node() != nullid] |
|
320 | siblings = [s for s in siblings if s.node() != nullid] | |
@@ -346,11 +346,11 b' class hgweb(object):' | |||||
346 | branches.append({"name": branch}) |
|
346 | branches.append({"name": branch}) | |
347 | return branches |
|
347 | return branches | |
348 |
|
348 | |||
349 | def showtag(self, t1, node=nullid, **args): |
|
349 | def showtag(self, tmpl, t1, node=nullid, **args): | |
350 | for t in self.repo.nodetags(node): |
|
350 | for t in self.repo.nodetags(node): | |
351 |
yield |
|
351 | yield tmpl(t1, tag=t, **args) | |
352 |
|
352 | |||
353 | def diff(self, node1, node2, files): |
|
353 | def diff(self, tmpl, node1, node2, files): | |
354 | def filterfiles(filters, files): |
|
354 | def filterfiles(filters, files): | |
355 | l = [x for x in files if x in filters] |
|
355 | l = [x for x in files if x in filters] | |
356 |
|
356 | |||
@@ -362,22 +362,22 b' class hgweb(object):' | |||||
362 |
|
362 | |||
363 | parity = paritygen(self.stripecount) |
|
363 | parity = paritygen(self.stripecount) | |
364 | def diffblock(diff, f, fn): |
|
364 | def diffblock(diff, f, fn): | |
365 |
yield |
|
365 | yield tmpl("diffblock", | |
366 |
|
|
366 | lines=prettyprintlines(diff), | |
367 |
|
|
367 | parity=parity.next(), | |
368 |
|
|
368 | file=f, | |
369 |
|
|
369 | filenode=hex(fn or nullid)) | |
370 |
|
370 | |||
371 | def prettyprintlines(diff): |
|
371 | def prettyprintlines(diff): | |
372 | for l in diff.splitlines(1): |
|
372 | for l in diff.splitlines(1): | |
373 | if l.startswith('+'): |
|
373 | if l.startswith('+'): | |
374 |
yield |
|
374 | yield tmpl("difflineplus", line=l) | |
375 | elif l.startswith('-'): |
|
375 | elif l.startswith('-'): | |
376 |
yield |
|
376 | yield tmpl("difflineminus", line=l) | |
377 | elif l.startswith('@'): |
|
377 | elif l.startswith('@'): | |
378 |
yield |
|
378 | yield tmpl("difflineat", line=l) | |
379 | else: |
|
379 | else: | |
380 |
yield |
|
380 | yield tmpl("diffline", line=l) | |
381 |
|
381 | |||
382 | r = self.repo |
|
382 | r = self.repo | |
383 | c1 = r.changectx(node1) |
|
383 | c1 = r.changectx(node1) | |
@@ -407,7 +407,7 b' class hgweb(object):' | |||||
407 | yield diffblock(mdiff.unidiff(to, date1, tn, date2, f, f, |
|
407 | yield diffblock(mdiff.unidiff(to, date1, tn, date2, f, f, | |
408 | opts=diffopts), f, tn) |
|
408 | opts=diffopts), f, tn) | |
409 |
|
409 | |||
410 | def changelog(self, ctx, shortlog=False): |
|
410 | def changelog(self, tmpl, ctx, shortlog=False): | |
411 | def changelist(limit=0,**map): |
|
411 | def changelist(limit=0,**map): | |
412 | cl = self.repo.changelog |
|
412 | cl = self.repo.changelog | |
413 | l = [] # build a list in forward order for efficiency |
|
413 | l = [] # build a list in forward order for efficiency | |
@@ -422,7 +422,7 b' class hgweb(object):' | |||||
422 | "changelogtag": self.showtag("changelogtag",n), |
|
422 | "changelogtag": self.showtag("changelogtag",n), | |
423 | "desc": ctx.description(), |
|
423 | "desc": ctx.description(), | |
424 | "date": ctx.date(), |
|
424 | "date": ctx.date(), | |
425 | "files": self.listfilediffs(ctx.files(), n), |
|
425 | "files": self.listfilediffs(tmpl, ctx.files(), n), | |
426 | "rev": i, |
|
426 | "rev": i, | |
427 | "node": hex(n), |
|
427 | "node": hex(n), | |
428 | "tags": self.nodetagsdict(n), |
|
428 | "tags": self.nodetagsdict(n), | |
@@ -445,15 +445,15 b' class hgweb(object):' | |||||
445 |
|
445 | |||
446 | changenav = revnavgen(pos, maxchanges, count, self.repo.changectx) |
|
446 | changenav = revnavgen(pos, maxchanges, count, self.repo.changectx) | |
447 |
|
447 | |||
448 |
yield |
|
448 | yield tmpl(shortlog and 'shortlog' or 'changelog', | |
449 |
|
|
449 | changenav=changenav, | |
450 |
|
|
450 | node=hex(cl.tip()), | |
451 |
|
|
451 | rev=pos, changesets=count, | |
452 |
|
|
452 | entries=lambda **x: changelist(limit=0,**x), | |
453 |
|
|
453 | latestentry=lambda **x: changelist(limit=1,**x), | |
454 |
|
|
454 | archives=self.archivelist("tip")) | |
455 |
|
455 | |||
456 | def search(self, query): |
|
456 | def search(self, tmpl, query): | |
457 |
|
457 | |||
458 | def changelist(**map): |
|
458 | def changelist(**map): | |
459 | cl = self.repo.changelog |
|
459 | cl = self.repo.changelog | |
@@ -484,19 +484,19 b' class hgweb(object):' | |||||
484 | count += 1 |
|
484 | count += 1 | |
485 | n = ctx.node() |
|
485 | n = ctx.node() | |
486 |
|
486 | |||
487 |
yield |
|
487 | yield tmpl('searchentry', | |
488 |
|
|
488 | parity=parity.next(), | |
489 |
|
|
489 | author=ctx.user(), | |
490 |
|
|
490 | parent=self.siblings(ctx.parents()), | |
491 |
|
|
491 | child=self.siblings(ctx.children()), | |
492 |
|
|
492 | changelogtag=self.showtag("changelogtag",n), | |
493 |
|
|
493 | desc=ctx.description(), | |
494 |
|
|
494 | date=ctx.date(), | |
495 |
|
|
495 | files=self.listfilediffs(tmpl, ctx.files(), n), | |
496 |
|
|
496 | rev=ctx.rev(), | |
497 |
|
|
497 | node=hex(n), | |
498 |
|
|
498 | tags=self.nodetagsdict(n), | |
499 |
|
|
499 | branches=self.nodebranchdict(ctx)) | |
500 |
|
500 | |||
501 | if count >= self.maxchanges: |
|
501 | if count >= self.maxchanges: | |
502 | break |
|
502 | break | |
@@ -504,13 +504,13 b' class hgweb(object):' | |||||
504 | cl = self.repo.changelog |
|
504 | cl = self.repo.changelog | |
505 | parity = paritygen(self.stripecount) |
|
505 | parity = paritygen(self.stripecount) | |
506 |
|
506 | |||
507 |
yield |
|
507 | yield tmpl('search', | |
508 |
|
|
508 | query=query, | |
509 |
|
|
509 | node=hex(cl.tip()), | |
510 |
|
|
510 | entries=changelist, | |
511 |
|
|
511 | archives=self.archivelist("tip")) | |
512 |
|
512 | |||
513 | def changeset(self, ctx): |
|
513 | def changeset(self, tmpl, ctx): | |
514 | n = ctx.node() |
|
514 | n = ctx.node() | |
515 | parents = ctx.parents() |
|
515 | parents = ctx.parents() | |
516 | p1 = parents[0].node() |
|
516 | p1 = parents[0].node() | |
@@ -518,29 +518,29 b' class hgweb(object):' | |||||
518 | files = [] |
|
518 | files = [] | |
519 | parity = paritygen(self.stripecount) |
|
519 | parity = paritygen(self.stripecount) | |
520 | for f in ctx.files(): |
|
520 | for f in ctx.files(): | |
521 |
files.append( |
|
521 | files.append(tmpl("filenodelink", | |
522 |
|
|
522 | node=hex(n), file=f, | |
523 |
|
|
523 | parity=parity.next())) | |
524 |
|
524 | |||
525 | def diff(**map): |
|
525 | def diff(**map): | |
526 | yield self.diff(p1, n, None) |
|
526 | yield self.diff(tmpl, p1, n, None) | |
527 |
|
527 | |||
528 |
yield |
|
528 | yield tmpl('changeset', | |
529 |
|
|
529 | diff=diff, | |
530 |
|
|
530 | rev=ctx.rev(), | |
531 |
|
|
531 | node=hex(n), | |
532 |
|
|
532 | parent=self.siblings(parents), | |
533 |
|
|
533 | child=self.siblings(ctx.children()), | |
534 |
|
|
534 | changesettag=self.showtag("changesettag",n), | |
535 |
|
|
535 | author=ctx.user(), | |
536 |
|
|
536 | desc=ctx.description(), | |
537 |
|
|
537 | date=ctx.date(), | |
538 |
|
|
538 | files=files, | |
539 |
|
|
539 | archives=self.archivelist(hex(n)), | |
540 |
|
|
540 | tags=self.nodetagsdict(n), | |
541 |
|
|
541 | branches=self.nodebranchdict(ctx)) | |
542 |
|
542 | |||
543 | def filelog(self, fctx): |
|
543 | def filelog(self, tmpl, fctx): | |
544 | f = fctx.path() |
|
544 | f = fctx.path() | |
545 | fl = fctx.filelog() |
|
545 | fl = fctx.filelog() | |
546 | count = fl.count() |
|
546 | count = fl.count() | |
@@ -577,11 +577,11 b' class hgweb(object):' | |||||
577 |
|
577 | |||
578 | nodefunc = lambda x: fctx.filectx(fileid=x) |
|
578 | nodefunc = lambda x: fctx.filectx(fileid=x) | |
579 | nav = revnavgen(pos, pagelen, count, nodefunc) |
|
579 | nav = revnavgen(pos, pagelen, count, nodefunc) | |
580 |
yield |
|
580 | yield tmpl("filelog", file=f, node=hex(fctx.node()), nav=nav, | |
581 |
|
|
581 | entries=lambda **x: entries(limit=0, **x), | |
582 |
|
|
582 | latestentry=lambda **x: entries(limit=1, **x)) | |
583 |
|
583 | |||
584 | def filerevision(self, fctx): |
|
584 | def filerevision(self, tmpl, fctx): | |
585 | f = fctx.path() |
|
585 | f = fctx.path() | |
586 | text = fctx.data() |
|
586 | text = fctx.data() | |
587 | fl = fctx.filelog() |
|
587 | fl = fctx.filelog() | |
@@ -601,23 +601,23 b' class hgweb(object):' | |||||
601 | "linenumber": "% 6d" % (l + 1), |
|
601 | "linenumber": "% 6d" % (l + 1), | |
602 | "parity": parity.next()} |
|
602 | "parity": parity.next()} | |
603 |
|
603 | |||
604 |
yield |
|
604 | yield tmpl("filerevision", | |
605 |
|
|
605 | file=f, | |
606 |
|
|
606 | path=_up(f), | |
607 |
|
|
607 | text=lines(), | |
608 |
|
|
608 | raw=rawtext, | |
609 |
|
|
609 | mimetype=mt, | |
610 |
|
|
610 | rev=fctx.rev(), | |
611 |
|
|
611 | node=hex(fctx.node()), | |
612 |
|
|
612 | author=fctx.user(), | |
613 |
|
|
613 | date=fctx.date(), | |
614 |
|
|
614 | desc=fctx.description(), | |
615 |
|
|
615 | parent=self.siblings(fctx.parents()), | |
616 |
|
|
616 | child=self.siblings(fctx.children()), | |
617 |
|
|
617 | rename=self.renamelink(fl, n), | |
618 |
|
|
618 | permissions=fctx.manifest().flags(f)) | |
619 |
|
619 | |||
620 | def fileannotate(self, fctx): |
|
620 | def fileannotate(self, tmpl, fctx): | |
621 | f = fctx.path() |
|
621 | f = fctx.path() | |
622 | n = fctx.filenode() |
|
622 | n = fctx.filenode() | |
623 | fl = fctx.filelog() |
|
623 | fl = fctx.filelog() | |
@@ -639,21 +639,21 b' class hgweb(object):' | |||||
639 | "file": f.path(), |
|
639 | "file": f.path(), | |
640 | "line": l} |
|
640 | "line": l} | |
641 |
|
641 | |||
642 |
yield |
|
642 | yield tmpl("fileannotate", | |
643 |
|
|
643 | file=f, | |
644 |
|
|
644 | annotate=annotate, | |
645 |
|
|
645 | path=_up(f), | |
646 |
|
|
646 | rev=fctx.rev(), | |
647 |
|
|
647 | node=hex(fctx.node()), | |
648 |
|
|
648 | author=fctx.user(), | |
649 |
|
|
649 | date=fctx.date(), | |
650 |
|
|
650 | desc=fctx.description(), | |
651 |
|
|
651 | rename=self.renamelink(fl, n), | |
652 |
|
|
652 | parent=self.siblings(fctx.parents()), | |
653 |
|
|
653 | child=self.siblings(fctx.children()), | |
654 |
|
|
654 | permissions=fctx.manifest().flags(f)) | |
655 |
|
655 | |||
656 | def manifest(self, ctx, path): |
|
656 | def manifest(self, tmpl, ctx, path): | |
657 | mf = ctx.manifest() |
|
657 | mf = ctx.manifest() | |
658 | node = ctx.node() |
|
658 | node = ctx.node() | |
659 |
|
659 | |||
@@ -707,19 +707,19 b' class hgweb(object):' | |||||
707 | "path": "%s%s" % (abspath, f), |
|
707 | "path": "%s%s" % (abspath, f), | |
708 | "basename": f[:-1]} |
|
708 | "basename": f[:-1]} | |
709 |
|
709 | |||
710 |
yield |
|
710 | yield tmpl("manifest", | |
711 |
|
|
711 | rev=ctx.rev(), | |
712 |
|
|
712 | node=hex(node), | |
713 |
|
|
713 | path=abspath, | |
714 |
|
|
714 | up=_up(abspath), | |
715 |
|
|
715 | upparity=parity.next(), | |
716 |
|
|
716 | fentries=filelist, | |
717 |
|
|
717 | dentries=dirlist, | |
718 |
|
|
718 | archives=self.archivelist(hex(node)), | |
719 |
|
|
719 | tags=self.nodetagsdict(node), | |
720 |
|
|
720 | branches=self.nodebranchdict(ctx)) | |
721 |
|
721 | |||
722 | def tags(self): |
|
722 | def tags(self, tmpl): | |
723 | i = self.repo.tagslist() |
|
723 | i = self.repo.tagslist() | |
724 | i.reverse() |
|
724 | i.reverse() | |
725 | parity = paritygen(self.stripecount) |
|
725 | parity = paritygen(self.stripecount) | |
@@ -737,13 +737,13 b' class hgweb(object):' | |||||
737 | "date": self.repo.changectx(n).date(), |
|
737 | "date": self.repo.changectx(n).date(), | |
738 | "node": hex(n)} |
|
738 | "node": hex(n)} | |
739 |
|
739 | |||
740 |
yield |
|
740 | yield tmpl("tags", | |
741 |
|
|
741 | node=hex(self.repo.changelog.tip()), | |
742 |
|
|
742 | entries=lambda **x: entries(False,0, **x), | |
743 |
|
|
743 | entriesnotip=lambda **x: entries(True,0, **x), | |
744 |
|
|
744 | latestentry=lambda **x: entries(True,1, **x)) | |
745 |
|
745 | |||
746 | def summary(self): |
|
746 | def summary(self, tmpl): | |
747 | i = self.repo.tagslist() |
|
747 | i = self.repo.tagslist() | |
748 | i.reverse() |
|
748 | i.reverse() | |
749 |
|
749 | |||
@@ -758,11 +758,11 b' class hgweb(object):' | |||||
758 | if count > 10: # limit to 10 tags |
|
758 | if count > 10: # limit to 10 tags | |
759 | break; |
|
759 | break; | |
760 |
|
760 | |||
761 |
yield |
|
761 | yield tmpl("tagentry", | |
762 |
|
|
762 | parity=parity.next(), | |
763 |
|
|
763 | tag=k, | |
764 |
|
|
764 | node=hex(n), | |
765 |
|
|
765 | date=self.repo.changectx(n).date()) | |
766 |
|
766 | |||
767 |
|
767 | |||
768 | def branches(**map): |
|
768 | def branches(**map): | |
@@ -788,8 +788,8 b' class hgweb(object):' | |||||
788 | n = ctx.node() |
|
788 | n = ctx.node() | |
789 | hn = hex(n) |
|
789 | hn = hex(n) | |
790 |
|
790 | |||
791 |
l.insert(0, |
|
791 | l.insert(0, tmpl( | |
792 |
|
|
792 | 'shortlogentry', | |
793 | parity=parity.next(), |
|
793 | parity=parity.next(), | |
794 | author=ctx.user(), |
|
794 | author=ctx.user(), | |
795 | desc=ctx.description(), |
|
795 | desc=ctx.description(), | |
@@ -806,34 +806,34 b' class hgweb(object):' | |||||
806 | start = max(0, count - self.maxchanges) |
|
806 | start = max(0, count - self.maxchanges) | |
807 | end = min(count, start + self.maxchanges) |
|
807 | end = min(count, start + self.maxchanges) | |
808 |
|
808 | |||
809 |
yield |
|
809 | yield tmpl("summary", | |
810 | desc=self.config("web", "description", "unknown"), |
|
810 | desc=self.config("web", "description", "unknown"), | |
811 | owner=(self.config("ui", "username") or # preferred |
|
811 | owner=(self.config("ui", "username") or # preferred | |
812 | self.config("web", "contact") or # deprecated |
|
812 | self.config("web", "contact") or # deprecated | |
813 | self.config("web", "author", "unknown")), # also |
|
813 | self.config("web", "author", "unknown")), # also | |
814 | lastchange=cl.read(cl.tip())[2], |
|
814 | lastchange=cl.read(cl.tip())[2], | |
815 | tags=tagentries, |
|
815 | tags=tagentries, | |
816 | branches=branches, |
|
816 | branches=branches, | |
817 | shortlog=changelist, |
|
817 | shortlog=changelist, | |
818 | node=hex(cl.tip()), |
|
818 | node=hex(cl.tip()), | |
819 | archives=self.archivelist("tip")) |
|
819 | archives=self.archivelist("tip")) | |
820 |
|
820 | |||
821 | def filediff(self, fctx): |
|
821 | def filediff(self, tmpl, fctx): | |
822 | n = fctx.node() |
|
822 | n = fctx.node() | |
823 | path = fctx.path() |
|
823 | path = fctx.path() | |
824 | parents = fctx.parents() |
|
824 | parents = fctx.parents() | |
825 | p1 = parents and parents[0].node() or nullid |
|
825 | p1 = parents and parents[0].node() or nullid | |
826 |
|
826 | |||
827 | def diff(**map): |
|
827 | def diff(**map): | |
828 | yield self.diff(p1, n, [path]) |
|
828 | yield self.diff(tmpl, p1, n, [path]) | |
829 |
|
829 | |||
830 |
yield |
|
830 | yield tmpl("filediff", | |
831 |
|
|
831 | file=path, | |
832 |
|
|
832 | node=hex(n), | |
833 |
|
|
833 | rev=fctx.rev(), | |
834 |
|
|
834 | parent=self.siblings(parents), | |
835 |
|
|
835 | child=self.siblings(fctx.children()), | |
836 |
|
|
836 | diff=diff) | |
837 |
|
837 | |||
838 | archive_specs = { |
|
838 | archive_specs = { | |
839 | 'bz2': ('application/x-tar', 'tbz2', '.tar.bz2', None), |
|
839 | 'bz2': ('application/x-tar', 'tbz2', '.tar.bz2', None), | |
@@ -841,7 +841,7 b' class hgweb(object):' | |||||
841 | 'zip': ('application/zip', 'zip', '.zip', None), |
|
841 | 'zip': ('application/zip', 'zip', '.zip', None), | |
842 | } |
|
842 | } | |
843 |
|
843 | |||
844 | def archive(self, req, key, type_): |
|
844 | def archive(self, tmpl, req, key, type_): | |
845 | reponame = re.sub(r"\W+", "-", os.path.basename(self.reponame)) |
|
845 | reponame = re.sub(r"\W+", "-", os.path.basename(self.reponame)) | |
846 | cnode = self.repo.lookup(key) |
|
846 | cnode = self.repo.lookup(key) | |
847 | arch_version = key |
|
847 | arch_version = key |
@@ -9,24 +9,24 b' import os' | |||||
9 | from mercurial import revlog |
|
9 | from mercurial import revlog | |
10 | from common import staticfile |
|
10 | from common import staticfile | |
11 |
|
11 | |||
12 | def log(web, req): |
|
12 | def log(web, req, tmpl): | |
13 | if req.form.has_key('file') and req.form['file'][0]: |
|
13 | if req.form.has_key('file') and req.form['file'][0]: | |
14 | filelog(web, req) |
|
14 | filelog(web, req, tmpl) | |
15 | else: |
|
15 | else: | |
16 | changelog(web, req) |
|
16 | changelog(web, req, tmpl) | |
17 |
|
17 | |||
18 | def file(web, req): |
|
18 | def file(web, req, tmpl): | |
19 | path = web.cleanpath(req.form.get('file', [''])[0]) |
|
19 | path = web.cleanpath(req.form.get('file', [''])[0]) | |
20 | if path: |
|
20 | if path: | |
21 | try: |
|
21 | try: | |
22 | req.write(web.filerevision(web.filectx(req))) |
|
22 | req.write(web.filerevision(tmpl, web.filectx(req))) | |
23 | return |
|
23 | return | |
24 | except revlog.LookupError: |
|
24 | except revlog.LookupError: | |
25 | pass |
|
25 | pass | |
26 |
|
26 | |||
27 | req.write(web.manifest(web.changectx(req), path)) |
|
27 | req.write(web.manifest(tmpl, web.changectx(req), path)) | |
28 |
|
28 | |||
29 | def changelog(web, req, shortlog = False): |
|
29 | def changelog(web, req, tmpl, shortlog = False): | |
30 | if req.form.has_key('node'): |
|
30 | if req.form.has_key('node'): | |
31 | ctx = web.changectx(req) |
|
31 | ctx = web.changectx(req) | |
32 | else: |
|
32 | else: | |
@@ -37,52 +37,52 b' def changelog(web, req, shortlog = False' | |||||
37 | try: |
|
37 | try: | |
38 | ctx = web.repo.changectx(hi) |
|
38 | ctx = web.repo.changectx(hi) | |
39 | except hg.RepoError: |
|
39 | except hg.RepoError: | |
40 | req.write(web.search(hi)) # XXX redirect to 404 page? |
|
40 | req.write(web.search(tmpl, hi)) # XXX redirect to 404 page? | |
41 | return |
|
41 | return | |
42 |
|
42 | |||
43 | req.write(web.changelog(ctx, shortlog = shortlog)) |
|
43 | req.write(web.changelog(tmpl, ctx, shortlog = shortlog)) | |
44 |
|
44 | |||
45 | def shortlog(web, req): |
|
45 | def shortlog(web, req, tmpl): | |
46 | changelog(web, req, shortlog = True) |
|
46 | changelog(web, req, tmpl, shortlog = True) | |
47 |
|
47 | |||
48 | def changeset(web, req): |
|
48 | def changeset(web, req, tmpl): | |
49 | req.write(web.changeset(web.changectx(req))) |
|
49 | req.write(web.changeset(tmpl, web.changectx(req))) | |
50 |
|
50 | |||
51 | rev = changeset |
|
51 | rev = changeset | |
52 |
|
52 | |||
53 | def manifest(web, req): |
|
53 | def manifest(web, req, tmpl): | |
54 | req.write(web.manifest(web.changectx(req), |
|
54 | req.write(web.manifest(tmpl, web.changectx(req), | |
55 | web.cleanpath(req.form['path'][0]))) |
|
55 | web.cleanpath(req.form['path'][0]))) | |
56 |
|
56 | |||
57 | def tags(web, req): |
|
57 | def tags(web, req, tmpl): | |
58 | req.write(web.tags()) |
|
58 | req.write(web.tags(tmpl)) | |
59 |
|
59 | |||
60 | def summary(web, req): |
|
60 | def summary(web, req, tmpl): | |
61 | req.write(web.summary()) |
|
61 | req.write(web.summary(tmpl)) | |
62 |
|
62 | |||
63 | def filediff(web, req): |
|
63 | def filediff(web, req, tmpl): | |
64 | req.write(web.filediff(web.filectx(req))) |
|
64 | req.write(web.filediff(tmpl, web.filectx(req))) | |
65 |
|
65 | |||
66 | diff = filediff |
|
66 | diff = filediff | |
67 |
|
67 | |||
68 | def annotate(web, req): |
|
68 | def annotate(web, req, tmpl): | |
69 | req.write(web.fileannotate(web.filectx(req))) |
|
69 | req.write(web.fileannotate(tmpl, web.filectx(req))) | |
70 |
|
70 | |||
71 | def filelog(web, req): |
|
71 | def filelog(web, req, tmpl): | |
72 | req.write(web.filelog(web.filectx(req))) |
|
72 | req.write(web.filelog(tmpl, web.filectx(req))) | |
73 |
|
73 | |||
74 | def archive(web, req): |
|
74 | def archive(web, req, tmpl): | |
75 | type_ = req.form['type'][0] |
|
75 | type_ = req.form['type'][0] | |
76 | allowed = web.configlist("web", "allow_archive") |
|
76 | allowed = web.configlist("web", "allow_archive") | |
77 | if (type_ in web.archives and (type_ in allowed or |
|
77 | if (type_ in web.archives and (type_ in allowed or | |
78 | web.configbool("web", "allow" + type_, False))): |
|
78 | web.configbool("web", "allow" + type_, False))): | |
79 | web.archive(req, req.form['node'][0], type_) |
|
79 | web.archive(tmpl, req, req.form['node'][0], type_) | |
80 | return |
|
80 | return | |
81 |
|
81 | |||
82 |
req.respond(400, |
|
82 | req.respond(400, tmpl('error', | |
83 | error='Unsupported archive type: %s' % type_)) |
|
83 | error='Unsupported archive type: %s' % type_)) | |
84 |
|
84 | |||
85 | def static(web, req): |
|
85 | def static(web, req, tmpl): | |
86 | fname = req.form['file'][0] |
|
86 | fname = req.form['file'][0] | |
87 | # a repo owner may set web.static in .hg/hgrc to get any file |
|
87 | # a repo owner may set web.static in .hg/hgrc to get any file | |
88 | # readable by the user running the CGI script |
|
88 | # readable by the user running the CGI script |
General Comments 0
You need to be logged in to leave comments.
Login now