Mercurial > hg-stable
changeset 3206:79fd7a92f3e2
hgweb: kill off #filenode#
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Fri, 29 Sep 2006 16:26:09 -0700 |
parents | 48395d2692de |
children | 0790dce2f3a8 |
files | mercurial/hgweb/hgweb_mod.py templates/fileannotate-gitweb.tmpl templates/fileannotate.tmpl templates/filediff.tmpl templates/filelog-gitweb.tmpl templates/filelog.tmpl templates/filelogentry-rss.tmpl templates/filelogentry.tmpl templates/filerevision-gitweb.tmpl templates/filerevision.tmpl templates/map templates/map-gitweb |
diffstat | 12 files changed, 59 insertions(+), 62 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hgweb/hgweb_mod.py Fri Sep 29 16:26:09 2006 -0700 +++ b/mercurial/hgweb/hgweb_mod.py Fri Sep 29 16:26:09 2006 -0700 @@ -293,7 +293,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ yield {"parity": parity, "node": hex(f.node()), - "filenode": hex(fnode), "rev": f.rev(), "author": name, "file": f.path(), @@ -415,7 +406,6 @@ yield self.t("fileannotate", file=f, - filenode=node, annotate=annotate, path=_up(f), rev=fctx.rev(), @@ -682,6 +672,16 @@ 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 @@ 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"
--- a/templates/fileannotate-gitweb.tmpl Fri Sep 29 16:26:09 2006 -0700 +++ b/templates/fileannotate-gitweb.tmpl Fri Sep 29 16:26:09 2006 -0700 @@ -10,7 +10,7 @@ </div> <div class="page_nav"> -<a href="?cmd=summary;style=gitweb">summary</a> | <a href="?cmd=shortlog;style=gitweb">shortlog</a> | <a href="?cmd=changelog;style=gitweb">changelog</a> | <a href="?cmd=tags;style=gitweb">tags</a> | <a href="?mf=#node|short#;path=#path|urlescape#;style=gitweb">manifest</a> | <a href="?cmd=changeset;node=#node#;style=gitweb">changeset</a> | <a href="?cmd=file;file=#file|urlescape#;filenode=#filenode#;style=gitweb">file</a> | <a href="?cmd=filelog;file=#file|urlescape#;filenode=#filenode#;style=gitweb">revisions</a> | annotate | <a href="?cmd=annotate;file=#file|urlescape#;filenode=#filenode#;style=raw">raw</a><br/> +<a href="?cmd=summary;style=gitweb">summary</a> | <a href="?cmd=shortlog;style=gitweb">shortlog</a> | <a href="?cmd=changelog;style=gitweb">changelog</a> | <a href="?cmd=tags;style=gitweb">tags</a> | <a href="?mf=#node|short#;path=#path|urlescape#;style=gitweb">manifest</a> | <a href="?cmd=changeset;node=#node#;style=gitweb">changeset</a> | <a href="?cmd=file;file=#file|urlescape#;filenode=#node|short#;style=gitweb">file</a> | <a href="?cmd=filelog;file=#file|urlescape#;filenode=#node|short#;style=gitweb">revisions</a> | annotate | <a href="?cmd=annotate;file=#file|urlescape#;filenode=#node|short#;style=raw">raw</a><br/> </div> <div class="title">#file|escape#</div>
--- a/templates/fileannotate.tmpl Fri Sep 29 16:26:09 2006 -0700 +++ b/templates/fileannotate.tmpl Fri Sep 29 16:26:09 2006 -0700 @@ -9,9 +9,9 @@ <a href="?tags=">tags</a> <a href="?cs=#node|short#">changeset</a> <a href="?mf=#node|short#;path=#path|urlescape#">manifest</a> -<a href="?f=#filenode|short#;file=#file|urlescape#">file</a> -<a href="?fl=#filenode|short#;file=#file|urlescape#">revisions</a> -<a href="?fa=#filenode|short#;file=#file|urlescape#;style=raw">raw</a> +<a href="?f=#node|short#;file=#file|urlescape#">file</a> +<a href="?fl=#node|short#;file=#file|urlescape#">revisions</a> +<a href="?fa=#node|short#;file=#file|urlescape#;style=raw">raw</a> </div> <h2>Annotate #file|escape#</h2>
--- a/templates/filediff.tmpl Fri Sep 29 16:26:09 2006 -0700 +++ b/templates/filediff.tmpl Fri Sep 29 16:26:09 2006 -0700 @@ -8,9 +8,9 @@ <a href="?sl=#rev#">shortlog</a> <a href="?tags=">tags</a> <a href="?cs=#node|short#">changeset</a> -<a href="?f=#filenode|short#;file=#file|urlescape#">file</a> -<a href="?fl=#filenode|short#;file=#file|urlescape#">revisions</a> -<a href="?fa=#filenode|short#;file=#file|urlescape#">annotate</a> +<a href="?f=#node|short#;file=#file|urlescape#">file</a> +<a href="?fl=#node|short#;file=#file|urlescape#">revisions</a> +<a href="?fa=#node|short#;file=#file|urlescape#">annotate</a> <a href="?fd=#node|short#;file=#file|urlescape#;style=raw">raw</a> </div>
--- a/templates/filelog-gitweb.tmpl Fri Sep 29 16:26:09 2006 -0700 +++ b/templates/filelog-gitweb.tmpl Fri Sep 29 16:26:09 2006 -0700 @@ -10,7 +10,7 @@ </div> <div class="page_nav"> -<a href="?cmd=summary;style=gitweb">summary</a> | <a href="?cmd=shortlog;style=gitweb">shortlog</a> | <a href="?cmd=changelog;style=gitweb">changelog</a> | <a href="?cmd=tags;style=gitweb">tags</a> | <a href="?cmd=file;file=#file|urlescape#;filenode=#filenode#;style=gitweb">file</a> | revisions | <a href="?cmd=annotate;file=#file|urlescape#;filenode=#filenode#;style=gitweb">annotate</a> | <a href="?fl=#filenode|short#;file=#file|urlescape#;style=rss">rss</a><br/> +<a href="?cmd=summary;style=gitweb">summary</a> | <a href="?cmd=shortlog;style=gitweb">shortlog</a> | <a href="?cmd=changelog;style=gitweb">changelog</a> | <a href="?cmd=tags;style=gitweb">tags</a> | <a href="?cmd=file;file=#file|urlescape#;filenode=#node|short#;style=gitweb">file</a> | revisions | <a href="?cmd=annotate;file=#file|urlescape#;filenode=#node|short#;style=gitweb">annotate</a> | <a href="?fl=#node|short#;file=#file|urlescape#;style=rss">rss</a><br/> </div> <div class="title" >#file|urlescape#</div>
--- a/templates/filelog.tmpl Fri Sep 29 16:26:09 2006 -0700 +++ b/templates/filelog.tmpl Fri Sep 29 16:26:09 2006 -0700 @@ -10,8 +10,8 @@ <a href="?cl=tip">changelog</a> <a href="?sl=tip">shortlog</a> <a href="?tags=">tags</a> -<a href="?f=#filenode|short#;file=#file|urlescape#">file</a> -<a href="?fa=#filenode|short#;file=#file|urlescape#">annotate</a> +<a href="?f=#node|short#;file=#file|urlescape#">file</a> +<a href="?fa=#node|short#;file=#file|urlescape#">annotate</a> <a type="application/rss+xml" href="?fl=0;file=#file|urlescape#;style=rss">rss</a> </div>
--- a/templates/filelogentry-rss.tmpl Fri Sep 29 16:26:09 2006 -0700 +++ b/templates/filelogentry-rss.tmpl Fri Sep 29 16:26:09 2006 -0700 @@ -1,6 +1,6 @@ <item> <title>#desc|strip|firstline|strip|escape#</title> - <link>#url#?f=#filenode|short#;file=#file|urlescape#</link> + <link>#url#?f=#node|short#;file=#file|urlescape#</link> <description><![CDATA[#desc|strip|escape|addbreaks#]]></description> <author>#author|obfuscate#</author> <pubDate>#date|rfc822date#</pubDate>>
--- a/templates/filelogentry.tmpl Fri Sep 29 16:26:09 2006 -0700 +++ b/templates/filelogentry.tmpl Fri Sep 29 16:26:09 2006 -0700 @@ -6,9 +6,9 @@ <tr> <th class="revision">revision #filerev#:</td> <td class="node"> - <a href="?f=#filenode|short#;file=#file|urlescape#">#filenode|short#</a> + <a href="?f=#node|short#;file=#file|urlescape#">#node|short#</a> <a href="?fd=#node|short#;file=#file|urlescape#">(diff)</a> - <a href="?fa=#filenode|short#;file=#file|urlescape#">(annotate)</a> + <a href="?fa=#node|short#;file=#file|urlescape#">(annotate)</a> </td> </tr> #rename%filelogrename#
--- a/templates/filerevision-gitweb.tmpl Fri Sep 29 16:26:09 2006 -0700 +++ b/templates/filerevision-gitweb.tmpl Fri Sep 29 16:26:09 2006 -0700 @@ -10,7 +10,7 @@ </div> <div class="page_nav"> -<a href="?cmd=summary;style=gitweb">summary</a> | <a href="?cmd=shortlog;style=gitweb">shortlog</a> | <a href="?cmd=changelog;style=gitweb">changelog</a> | <a href="?cmd=tags;style=gitweb">tags</a> | <a href="?mf=#node|short#;path=#path|urlescape#;style=gitweb">manifest</a> | <a href="?cmd=changeset;node=#node#;style=gitweb">changeset</a> | file | <a href="?cmd=filelog;file=#file|urlescape#;filenode=#filenode#;style=gitweb">revisions</a> | <a href="?cmd=annotate;file=#file|urlescape#;filenode=#filenode#;style=gitweb">annotate</a> | <a href="?cmd=file;file=#file|urlescape#;filenode=#filenode#;style=raw">raw</a><br/> +<a href="?cmd=summary;style=gitweb">summary</a> | <a href="?cmd=shortlog;style=gitweb">shortlog</a> | <a href="?cmd=changelog;style=gitweb">changelog</a> | <a href="?cmd=tags;style=gitweb">tags</a> | <a href="?mf=#node|short#;path=#path|urlescape#;style=gitweb">manifest</a> | <a href="?cmd=changeset;node=#node#;style=gitweb">changeset</a> | file | <a href="?cmd=filelog;file=#file|urlescape#;filenode=#node|short#;style=gitweb">revisions</a> | <a href="?cmd=annotate;file=#file|urlescape#;filenode=#node|short#;style=gitweb">annotate</a> | <a href="?cmd=file;file=#file|urlescape#;filenode=#node#;style=raw">raw</a><br/> </div> <div class="title">#file|escape#</div>
--- a/templates/filerevision.tmpl Fri Sep 29 16:26:09 2006 -0700 +++ b/templates/filerevision.tmpl Fri Sep 29 16:26:09 2006 -0700 @@ -9,9 +9,9 @@ <a href="?tags=">tags</a> <a href="?cs=#node|short#">changeset</a> <a href="?mf=#node|short#;path=#path|urlescape#">manifest</a> -<a href="?fl=#filenode|short#;file=#file|urlescape#">revisions</a> -<a href="?fa=#filenode|short#;file=#file|urlescape#">annotate</a> -<a href="?f=#filenode|short#;file=#file|urlescape#;style=raw">raw</a> +<a href="?fl=#node|short#;file=#file|urlescape#">revisions</a> +<a href="?fa=#node|short#;file=#file|urlescape#">annotate</a> +<a href="?f=#node|short#;file=#file|urlescape#;style=raw">raw</a> </div> <h2>#file|escape#</h2>
--- a/templates/map Fri Sep 29 16:26:09 2006 -0700 +++ b/templates/map Fri Sep 29 16:26:09 2006 -0700 @@ -8,21 +8,21 @@ naventry = '<a href="?cl=#rev#">#label|escape#</a> ' navshortentry = '<a href="?sl=#rev#">#label|escape#</a> ' filedifflink = '<a href="?fd=#node|short#;file=#file|urlescape#">#file|escape#</a> ' -filenodelink = '<a href="?f=#filenode|short#;file=#file|urlescape#">#file|escape#</a> ' +filenodelink = '<a href="?f=#node|short#;file=#file|urlescape#">#file|escape#</a> ' fileellipses = '...' changelogentry = changelogentry.tmpl searchentry = changelogentry.tmpl changeset = changeset.tmpl manifest = manifest.tmpl manifestdirentry = '<tr class="parity#parity#"><td><tt>drwxr-xr-x</tt> <td><a href="?mf=#node|short#;path=#path|urlescape#">#basename|escape#/</a>' -manifestfileentry = '<tr class="parity#parity#"><td><tt>#permissions|permissions#</tt> <td><a href="?f=#filenode|short#;file=#file|urlescape#">#basename|escape#</a>' +manifestfileentry = '<tr class="parity#parity#"><td><tt>#permissions|permissions#</tt> <td><a href="?f=#node|short#;file=#file|urlescape#">#basename|escape#</a>' filerevision = filerevision.tmpl fileannotate = fileannotate.tmpl filediff = filediff.tmpl filelog = filelog.tmpl fileline = '<div class="parity#parity#"><span class="lineno">#linenumber#</span>#line|escape#</div>' filelogentry = filelogentry.tmpl -annotateline = '<tr class="parity#parity#"><td class="annotate"><a href="?fa=#filenode|short#;file=#file|urlescape#">#author|obfuscate#@#rev#</a></td><td><pre>#line|escape#</pre></td></tr>' +annotateline = '<tr class="parity#parity#"><td class="annotate"><a href="?fa=#node|short#;file=#file|urlescape#">#author|obfuscate#@#rev#</a></td><td><pre>#line|escape#</pre></td></tr>' difflineplus = '<span class="plusline">#line|escape#</span>' difflineminus = '<span class="minusline">#line|escape#</span>' difflineat = '<span class="atline">#line|escape#</span>'
--- a/templates/map-gitweb Fri Sep 29 16:26:09 2006 -0700 +++ b/templates/map-gitweb Fri Sep 29 16:26:09 2006 -0700 @@ -8,19 +8,19 @@ naventry = '<a href="?cmd=changelog;rev=#rev#;style=gitweb">#label|escape#</a> ' navshortentry = '<a href="?cmd=shortlog;rev=#rev#;style=gitweb">#label|escape#</a> ' filedifflink = '<a href="?cmd=filediff;node=#node#;file=#file|urlescape#;style=gitweb">#file|escape#</a> ' -filenodelink = '<tr class="parity#parity#"><td><a class="list" href="">#file|escape#</a></td><td></td><td class="link"><a href="?cmd=file;filenode=#filenode#;file=#file|urlescape#;style=gitweb">file</a> | <a href="?fa=#filenode|short#;file=#file|urlescape#;style=gitweb">annotate</a> | <!-- FIXME: <a href="?fd=#filenode|short#;file=#file|urlescape#;style=gitweb">diff</a> | --> <a href="?cmd=filelog;filenode=#filenode|short#;file=#file|urlescape#;style=gitweb">revisions</a></td></tr>' +filenodelink = '<tr class="parity#parity#"><td><a class="list" href="">#file|escape#</a></td><td></td><td class="link"><a href="?f=#node|short#;file=#file|urlescape#;style=gitweb">file</a> | <a href="?fa=#node|short#;file=#file|urlescape#;style=gitweb">annotate</a> | <!-- FIXME: <a href="?fd=#node|short#;file=#file|urlescape#;style=gitweb">diff</a> | --> <a href="?cmd=filelog;filenode=#node|short#;file=#file|urlescape#;style=gitweb">revisions</a></td></tr>' fileellipses = '...' changelogentry = changelogentry-gitweb.tmpl searchentry = changelogentry-gitweb.tmpl changeset = changeset-gitweb.tmpl manifest = manifest-gitweb.tmpl manifestdirentry = '<tr class="parity#parity#"><td style="font-family:monospace">drwxr-xr-x</td><td><a href="?mf=#node|short#;path=#path|urlescape#;style=gitweb">#basename|escape#/</a></td><td class="link"><a href="?mf=#node|short#;path=#path|urlescape#;style=gitweb">manifest</a></td></tr>' -manifestfileentry = '<tr class="parity#parity#"><td style="font-family:monospace">#permissions|permissions#</td><td class="list"><a class="list" href="?f=#filenode|short#;file=#file|urlescape#;style=gitweb">#basename|escape#</a></td><td class="link"><a href="?f=#filenode|short#;file=#file|urlescape#;style=gitweb">file</a> | <a href="?fl=#filenode|short#;file=#file|urlescape#;style=gitweb">revisions</a> | <a href="?fa=#filenode|short#;file=#file|urlescape#;style=gitweb">annotate</a></td></tr>' +manifestfileentry = '<tr class="parity#parity#"><td style="font-family:monospace">#permissions|permissions#</td><td class="list"><a class="list" href="?f=#node|short#;file=#file|urlescape#;style=gitweb">#basename|escape#</a></td><td class="link"><a href="?f=#node|short#;file=#file|urlescape#;style=gitweb">file</a> | <a href="?fl=#node|short#;file=#file|urlescape#;style=gitweb">revisions</a> | <a href="?fa=#node|short#;file=#file|urlescape#;style=gitweb">annotate</a></td></tr>' filerevision = filerevision-gitweb.tmpl fileannotate = fileannotate-gitweb.tmpl filelog = filelog-gitweb.tmpl fileline = '<div style="font-family:monospace" class="parity#parity#"><pre><span class="linenr"> #linenumber#</span> #line|escape#</pre></div>' -annotateline = '<tr style="font-family:monospace" class="parity#parity#"><td class="linenr" style="text-align: right;"><a href="?fa=#filenode|short#;file=#file|urlescape#;style=gitweb">#author|obfuscate#@#rev#</a></td><td><pre>#line|escape#</pre></td></tr>' +annotateline = '<tr style="font-family:monospace" class="parity#parity#"><td class="linenr" style="text-align: right;"><a href="?fa=#node|short#;file=#file|urlescape#;style=gitweb">#author|obfuscate#@#rev#</a></td><td><pre>#line|escape#</pre></td></tr>' difflineplus = '<div style="color:#008800;">#line|escape#</div>' difflineminus = '<div style="color:#cc0000;">#line|escape#</div>' difflineat = '<div style="color:#990099;">#line|escape#</div>' @@ -46,5 +46,5 @@ filelogchild = '<tr><td align="right">child #rev#: </td><td><a href="?cmd=file;file=#file|urlescape#;filenode=#node#;style=gitweb">#node|short#</a></td></tr>' shortlog = shortlog-gitweb.tmpl shortlogentry = '<tr class="parity#parity#"><td class="age"><i>#date|age# ago</i></td><td><i>#author#</i></td><td><a class="list" href="?cmd=changeset;node=#node|short#;style=gitweb"><b>#desc|strip|firstline|escape#</b></a></td><td class="link"><a href="?cmd=changeset;node=#node|short#;style=gitweb">changeset</a> | <a href="?cmd=manifest;manifest=#node|short#;path=/;style=gitweb">manifest</a></td></tr>' -filelogentry = '<tr class="parity#parity#"><td class="age"><i>#date|age# ago</i></td><td><a class="list" href="?cmd=changeset;node=#node|short#;style=gitweb"><b>#desc|strip|firstline|escape#</b></a></td><td class="link"><a href="?f=#node|short#;file=#file|urlescape#;style=gitweb">file</a> | <!-- FIXME: <a href="?fd=#node|short#;file=#file|urlescape#;style=gitweb">diff</a> | --> <a href="?fa=#filenode|short#;file=#file|urlescape#;style=gitweb">annotate</a> #rename%filelogrename#</td></tr>' +filelogentry = '<tr class="parity#parity#"><td class="age"><i>#date|age# ago</i></td><td><a class="list" href="?cmd=changeset;node=#node|short#;style=gitweb"><b>#desc|strip|firstline|escape#</b></a></td><td class="link"><a href="?f=#node|short#;file=#file|urlescape#;style=gitweb">file</a> | <!-- FIXME: <a href="?fd=#node|short#;file=#file|urlescape#;style=gitweb">diff</a> | --> <a href="?fa=#node|short#;file=#file|urlescape#;style=gitweb">annotate</a> #rename%filelogrename#</td></tr>' archiveentry = ' | <a href="?ca=#node|short#;type=#type|urlescape#">#type|escape#</a> '