diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py +++ b/mercurial/hgweb/hgweb_mod.py @@ -293,7 +293,7 @@ class hgweb(object): parity = 0 for f in changes[3]: files.append(self.t("filenodelink", - filenode=hex(mf.get(f, nullid)), file=f, + node=hex(n), file=f, parity=parity)) parity = 1 - parity @@ -313,10 +313,10 @@ class hgweb(object): files=files, archives=self.archivelist(nodeid)) - def filelog(self, f, filenode): + def filelog(self, fctx): + f = fctx.path() cl = self.repo.changelog - fl = self.repo.file(f) - filenode = hex(fl.lookup(filenode)) + fl = fctx.filelog() count = fl.count() def entries(**map): @@ -326,39 +326,32 @@ class hgweb(object): for i in range(count): n = fl.node(i) lr = fl.linkrev(n) - cn = cl.node(lr) - cs = cl.read(cl.node(lr)) + ctx = self.repo.changectx(lr) l.insert(0, {"parity": parity, - "filenode": hex(n), "filerev": i, "file": f, - "node": hex(cn), - "author": cs[1], - "date": cs[2], + "node": hex(ctx.node()), + "author": ctx.user(), + "date": ctx.date(), "rename": self.renamelink(fl, n), "parent": self.siblings(fl.parents(n), fl.rev, file=f), "child": self.siblings(fl.children(n), fl.rev, file=f), - "desc": cs[4]}) + "desc": ctx.description()}) parity = 1 - parity for e in l: yield e - yield self.t("filelog", file=f, filenode=filenode, entries=entries) + yield self.t("filelog", file=f, node=hex(fctx.node()), entries=entries) - def filerevision(self, f, node): - fl = self.repo.file(f) - n = fl.lookup(node) - node = hex(n) - text = fl.read(n) - changerev = fl.linkrev(n) - cl = self.repo.changelog - cn = cl.node(changerev) - cs = cl.read(cn) - mfn = cs[0] + def filerevision(self, fctx): + f = fctx.path() + text = fctx.data() + fl = fctx.filelog() + n = fctx.filenode() mt = mimetypes.guess_type(f)[0] rawtext = text @@ -375,22 +368,21 @@ class hgweb(object): yield self.t("filerevision", file=f, - filenode=node, path=_up(f), text=lines(), raw=rawtext, mimetype=mt, - rev=changerev, - node=hex(cn), - author=cs[1], - date=cs[2], + rev=fctx.rev(), + node=hex(fctx.node()), + author=fctx.user(), + date=fctx.date(), parent=self.siblings(fl.parents(n), fl.rev, file=f), child=self.siblings(fl.children(n), fl.rev, file=f), rename=self.renamelink(fl, n), - permissions=self.repo.manifest.read(mfn).execf(f)) + permissions=fctx.manifest().execf(f)) - def fileannotate(self, f, node): - fctx = self.repo.filectx(f, fileid=node) + def fileannotate(self, fctx): + f = fctx.path() n = fctx.filenode() fl = fctx.filelog() @@ -407,7 +399,6 @@ class hgweb(object): yield {"parity": parity, "node": hex(f.node()), - "filenode": hex(fnode), "rev": f.rev(), "author": name, "file": f.path(), @@ -415,7 +406,6 @@ class hgweb(object): yield self.t("fileannotate", file=f, - filenode=node, annotate=annotate, path=_up(f), rev=fctx.rev(), @@ -682,6 +672,16 @@ class hgweb(object): mn = man.lookup(changeid) req.changectx = self.repo.changectx(man.linkrev(mn)) + if form.has_key('filenode'): + changeid = req.form['filenode'][0] + path = self.cleanpath(req.form['file'][0]) + try: + req.changectx = self.repo.changectx(changeid) + req.filectx = req.changectx.filectx(path) + except hg.RepoError: + req.filectx = self.repo.filectx(path, fileid=changeid) + req.changectx = req.filectx.changectx() + self.refresh() expand_form(req.form) @@ -774,16 +774,13 @@ class hgweb(object): req.form['node'][0])) def do_file(self, req): - req.write(self.filerevision(self.cleanpath(req.form['file'][0]), - req.form['filenode'][0])) + req.write(self.filerevision(req.filectx)) def do_annotate(self, req): - req.write(self.fileannotate(self.cleanpath(req.form['file'][0]), - req.form['filenode'][0])) + req.write(self.fileannotate(req.filectx)) def do_filelog(self, req): - req.write(self.filelog(self.cleanpath(req.form['file'][0]), - req.form['filenode'][0])) + req.write(self.filelog(req.filectx)) def do_heads(self, req): resp = " ".join(map(hex, self.repo.heads())) + "\n" diff --git a/templates/fileannotate-gitweb.tmpl b/templates/fileannotate-gitweb.tmpl --- a/templates/fileannotate-gitweb.tmpl +++ b/templates/fileannotate-gitweb.tmpl @@ -10,7 +10,7 @@
#file|escape#
diff --git a/templates/fileannotate.tmpl b/templates/fileannotate.tmpl --- a/templates/fileannotate.tmpl +++ b/templates/fileannotate.tmpl @@ -9,9 +9,9 @@ tags changeset manifest -file -revisions -raw +file +revisions +raw

Annotate #file|escape#

diff --git a/templates/filediff.tmpl b/templates/filediff.tmpl --- a/templates/filediff.tmpl +++ b/templates/filediff.tmpl @@ -8,9 +8,9 @@ shortlog tags changeset -file -revisions -annotate +file +revisions +annotate raw diff --git a/templates/filelog-gitweb.tmpl b/templates/filelog-gitweb.tmpl --- a/templates/filelog-gitweb.tmpl +++ b/templates/filelog-gitweb.tmpl @@ -10,7 +10,7 @@
#file|urlescape#
diff --git a/templates/filelog.tmpl b/templates/filelog.tmpl --- a/templates/filelog.tmpl +++ b/templates/filelog.tmpl @@ -10,8 +10,8 @@ changelog shortlog tags -file -annotate +file +annotate rss diff --git a/templates/filelogentry-rss.tmpl b/templates/filelogentry-rss.tmpl --- a/templates/filelogentry-rss.tmpl +++ b/templates/filelogentry-rss.tmpl @@ -1,6 +1,6 @@ #desc|strip|firstline|strip|escape# - #url#?f=#filenode|short#;file=#file|urlescape# + #url#?f=#node|short#;file=#file|urlescape# #author|obfuscate# #date|rfc822date#> diff --git a/templates/filelogentry.tmpl b/templates/filelogentry.tmpl --- a/templates/filelogentry.tmpl +++ b/templates/filelogentry.tmpl @@ -6,9 +6,9 @@ revision #filerev#: - #filenode|short# + #node|short# (diff) - (annotate) + (annotate) #rename%filelogrename# diff --git a/templates/filerevision-gitweb.tmpl b/templates/filerevision-gitweb.tmpl --- a/templates/filerevision-gitweb.tmpl +++ b/templates/filerevision-gitweb.tmpl @@ -10,7 +10,7 @@
#file|escape#
diff --git a/templates/filerevision.tmpl b/templates/filerevision.tmpl --- a/templates/filerevision.tmpl +++ b/templates/filerevision.tmpl @@ -9,9 +9,9 @@ tags changeset manifest -revisions -annotate -raw +revisions +annotate +raw

#file|escape#

diff --git a/templates/map b/templates/map --- a/templates/map +++ b/templates/map @@ -8,21 +8,21 @@ shortlogentry = shortlogentry.tmpl naventry = '#label|escape# ' navshortentry = '#label|escape# ' filedifflink = '#file|escape# ' -filenodelink = '#file|escape# ' +filenodelink = '#file|escape# ' fileellipses = '...' changelogentry = changelogentry.tmpl searchentry = changelogentry.tmpl changeset = changeset.tmpl manifest = manifest.tmpl manifestdirentry = 'drwxr-xr-x #basename|escape#/' -manifestfileentry = '#permissions|permissions# #basename|escape#' +manifestfileentry = '#permissions|permissions# #basename|escape#' filerevision = filerevision.tmpl fileannotate = fileannotate.tmpl filediff = filediff.tmpl filelog = filelog.tmpl fileline = '
#linenumber##line|escape#
' filelogentry = filelogentry.tmpl -annotateline = '#author|obfuscate#@#rev#
#line|escape#
' +annotateline = '#author|obfuscate#@#rev#
#line|escape#
' difflineplus = '#line|escape#' difflineminus = '#line|escape#' difflineat = '#line|escape#' diff --git a/templates/map-gitweb b/templates/map-gitweb --- a/templates/map-gitweb +++ b/templates/map-gitweb @@ -8,19 +8,19 @@ error = error-gitweb.tmpl naventry = '#label|escape# ' navshortentry = '#label|escape# ' filedifflink = '#file|escape# ' -filenodelink = '#file|escape#file | annotate | revisions' +filenodelink = '#file|escape#file | annotate | revisions' fileellipses = '...' changelogentry = changelogentry-gitweb.tmpl searchentry = changelogentry-gitweb.tmpl changeset = changeset-gitweb.tmpl manifest = manifest-gitweb.tmpl manifestdirentry = 'drwxr-xr-x#basename|escape#/manifest' -manifestfileentry = '#permissions|permissions##basename|escape#file | revisions | annotate' +manifestfileentry = '#permissions|permissions##basename|escape#file | revisions | annotate' filerevision = filerevision-gitweb.tmpl fileannotate = fileannotate-gitweb.tmpl filelog = filelog-gitweb.tmpl fileline = '
   #linenumber# #line|escape#
' -annotateline = '#author|obfuscate#@#rev#
#line|escape#
' +annotateline = '#author|obfuscate#@#rev#
#line|escape#
' difflineplus = '
#line|escape#
' difflineminus = '
#line|escape#
' difflineat = '
#line|escape#
' @@ -46,5 +46,5 @@ filediffchild = 'c filelogchild = 'child #rev#: #node|short#' shortlog = shortlog-gitweb.tmpl shortlogentry = '#date|age# ago#author##desc|strip|firstline|escape#changeset | manifest' -filelogentry = '#date|age# ago#desc|strip|firstline|escape#file | annotate #rename%filelogrename#' +filelogentry = '#date|age# ago#desc|strip|firstline|escape#file | annotate #rename%filelogrename#' archiveentry = ' | #type|escape# '