##// END OF EJS Templates
hgweb: use contexts in more handlers
Brendan Cully -
r3220:32527854 default
parent child Browse files
Show More
@@ -149,7 +149,8 b' class hgweb(object):'
149 149 yield diffblock(mdiff.unidiff(to, date1, tn, date2, f,
150 150 opts=diffopts), f, tn)
151 151
152 def changelog(self, pos, shortlog=False):
152 def changelog(self, ctx, shortlog=False):
153 pos = ctx.rev()
153 154 def changenav(**map):
154 155 def seq(factor, maxchanges=None):
155 156 if maxchanges:
@@ -274,8 +275,7 b' class hgweb(object):'
274 275 node=hex(cl.tip()),
275 276 entries=changelist)
276 277
277 def changeset(self, nodeid):
278 ctx = self.repo.changectx(nodeid)
278 def changeset(self, ctx):
279 279 n = ctx.node()
280 280 parents = ctx.parents()
281 281 p1 = parents[0].node()
@@ -302,7 +302,7 b' class hgweb(object):'
302 302 desc=ctx.description(),
303 303 date=ctx.date(),
304 304 files=files,
305 archives=self.archivelist(nodeid))
305 archives=self.archivelist(hex(n)))
306 306
307 307 def filelog(self, fctx):
308 308 f = fctx.path()
@@ -552,21 +552,21 b' class hgweb(object):'
552 552 node = hex(self.repo.changelog.tip()),
553 553 archives=self.archivelist("tip"))
554 554
555 def filediff(self, file, changeset):
556 ctx = self.repo.changectx(changeset)
557 n = ctx.node()
558 parents = ctx.parents()
555 def filediff(self, fctx):
556 n = fctx.node()
557 path = fctx.path()
558 parents = fctx.changectx().parents()
559 559 p1 = parents[0].node()
560 560
561 561 def diff(**map):
562 yield self.diff(p1, n, [file])
562 yield self.diff(p1, n, [path])
563 563
564 564 yield self.t("filediff",
565 file=file,
565 file=path,
566 566 node=hex(n),
567 rev=ctx.rev(),
567 rev=fctx.rev(),
568 568 parent=self.siblings(parents),
569 child=self.siblings(ctx.children()),
569 child=self.siblings(fctx.children()),
570 570 diff=diff)
571 571
572 572 archive_specs = {
@@ -649,7 +649,7 b' class hgweb(object):'
649 649 del form[k]
650 650
651 651 if form.has_key('manifest'):
652 changeid = req.form['manifest'][0]
652 changeid = form['manifest'][0]
653 653 try:
654 654 req.changectx = self.repo.changectx(changeid)
655 655 except hg.RepoError:
@@ -658,8 +658,8 b' class hgweb(object):'
658 658 req.changectx = self.repo.changectx(man.linkrev(mn))
659 659
660 660 if form.has_key('filenode'):
661 changeid = req.form['filenode'][0]
662 path = self.cleanpath(req.form['file'][0])
661 changeid = form['filenode'][0]
662 path = self.cleanpath(form['file'][0])
663 663 try:
664 664 req.changectx = self.repo.changectx(changeid)
665 665 req.filectx = req.changectx.filectx(path)
@@ -718,31 +718,34 b' class hgweb(object):'
718 718 return 0
719 719
720 720 def do_changelog(self, req):
721 hi = self.repo.changelog.count() - 1
722 721 if req.form.has_key('rev'):
723 722 hi = req.form['rev'][0]
724 try:
725 hi = self.repo.changelog.rev(self.repo.lookup(hi))
726 except hg.RepoError:
727 req.write(self.search(hi)) # XXX redirect to 404 page?
728 return
723 else:
724 hi = self.repo.changelog.count() - 1
725 try:
726 ctx = self.repo.changectx(hi)
727 except hg.RepoError:
728 req.write(self.search(hi)) # XXX redirect to 404 page?
729 return
729 730
730 req.write(self.changelog(hi))
731 req.write(self.changelog(ctx))
731 732
732 733 def do_shortlog(self, req):
733 hi = self.repo.changelog.count() - 1
734 734 if req.form.has_key('rev'):
735 735 hi = req.form['rev'][0]
736 try:
737 hi = self.repo.changelog.rev(self.repo.lookup(hi))
738 except hg.RepoError:
739 req.write(self.search(hi)) # XXX redirect to 404 page?
740 return
736 else:
737 hi = self.repo.changelog.count() - 1
738 try:
739 hi = self.repo.changectx(hi)
740 except hg.RepoError:
741 req.write(self.search(hi)) # XXX redirect to 404 page?
742 return
741 743
742 req.write(self.changelog(hi, shortlog = True))
744 req.write(self.changelog(ctx, shortlog = True))
743 745
744 746 def do_changeset(self, req):
745 req.write(self.changeset(req.form['node'][0]))
747 ctx = self.repo.changectx(req.form['node'][0])
748 req.write(self.changeset(ctx))
746 749
747 750 def do_manifest(self, req):
748 751 req.write(self.manifest(req.changectx,
@@ -755,8 +758,9 b' class hgweb(object):'
755 758 req.write(self.summary())
756 759
757 760 def do_filediff(self, req):
758 req.write(self.filediff(self.cleanpath(req.form['file'][0]),
759 req.form['node'][0]))
761 ctx = self.repo.changectx(req.form['node'][0])
762 fctx = ctx.filectx(self.cleanpath(req.form['file'][0]))
763 req.write(self.filediff(fctx))
760 764
761 765 def do_file(self, req):
762 766 req.write(self.filerevision(req.filectx))
General Comments 0
You need to be logged in to leave comments. Login now