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