[PATCH 1 of 1 RFC] hgweb: graph file history
timeless
timeless at gmail.com
Wed Mar 16 10:10:33 CDT 2011
# HG changeset patch
# User timeless <timeless at gmail.com>
# Date 1300267346 -7200
# Node ID ec7b02c29b77028b8843206299e95e094c4af4fd
# Parent a1dae38acbc645993f270f554754f233e010d6e2
hgweb: graph file history
diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -12,7 +12,7 @@ from mercurial.node import short, hex
from mercurial.util import binary
from common import paritygen, staticfile, get_contact, ErrorResponse
from common import HTTP_OK, HTTP_FORBIDDEN, HTTP_NOT_FOUND
-from mercurial import graphmod
+from mercurial import cmdutil, graphmod
from mercurial import help as helpmod
from mercurial.i18n import _
@@ -736,7 +736,26 @@ def graph(web, req, tmpl):
count = len(web.repo)
changenav = webutil.revnavgen(rev, revcount, count, web.repo.changectx)
- dag = graphmod.revisions(web.repo, rev, downrev)
+ path = webutil.cleanpath(web.repo, req.form.get('file', [''])[0])
+ dag = None
+ if path:
+ file = '"' + web.repo.root + '/' + path + '"'
+ limit = str(revcount / 2)
+ set = 'min(limit(sort(file('+file+') and ancestors('+revnode_hex+'), -rev),'+limit+'))'
+ try:
+ low = cmdutil.revsingle(web.repo, set)
+ except:
+ low = web.repo[revnode]
+ low = low.rev()
+ set = 'max(limit(sort(file('+file+') and descendants('+revnode_hex+'), rev),'+limit+'))'
+ try:
+ high = cmdutil.revsingle(web.repo, set)
+ except:
+ high = web.repo[revnode]
+ high = high.rev()
+ dag = graphmod.filerevs(web.repo, path, high, low)
+ else:
+ dag = graphmod.revisions(web.repo, rev, downrev)
tree = list(graphmod.colored(dag))
canvasheight = (len(tree) + 1) * bg_height - 27
data = []
diff --git a/mercurial/templates/gitweb/filelog.tmpl b/mercurial/templates/gitweb/filelog.tmpl
--- a/mercurial/templates/gitweb/filelog.tmpl
+++ b/mercurial/templates/gitweb/filelog.tmpl
@@ -15,7 +15,7 @@
<a href="{url}summary{sessionvars%urlparameter}">summary</a> |
<a href="{url}shortlog{sessionvars%urlparameter}">shortlog</a> |
<a href="{url}log{sessionvars%urlparameter}">changelog</a> |
-<a href="{url}graph{sessionvars%urlparameter}">graph</a> |
+<a href="{url}graph/{node|short}/{file|urlescape}{sessionvars%urlparameter}">graph</a> |
<a href="{url}tags{sessionvars%urlparameter}">tags</a> |
<a href="{url}branches{sessionvars%urlparameter}">branches</a> |
<a href="{url}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">file</a> |
diff --git a/mercurial/templates/monoblue/filelog.tmpl b/mercurial/templates/monoblue/filelog.tmpl
--- a/mercurial/templates/monoblue/filelog.tmpl
+++ b/mercurial/templates/monoblue/filelog.tmpl
@@ -21,7 +21,7 @@
<li><a href="{url}summary{sessionvars%urlparameter}">summary</a></li>
<li><a href="{url}shortlog{sessionvars%urlparameter}">shortlog</a></li>
<li><a href="{url}log{sessionvars%urlparameter}">changelog</a></li>
- <li><a href="{url}graph/{node|short}{sessionvars%urlparameter}">graph</a></li>
+ <li><a href="{url}graph/{node|short}/{file|urlescape}{sessionvars%urlparameter}">graph</a></li>
<li><a href="{url}tags{sessionvars%urlparameter}">tags</a></li>
<li><a href="{url}branches{sessionvars%urlparameter}">branches</a></li>
<li><a href="{url}file/{node|short}{path|urlescape}{sessionvars%urlparameter}">files</a></li>
diff --git a/mercurial/templates/paper/filelog.tmpl b/mercurial/templates/paper/filelog.tmpl
--- a/mercurial/templates/paper/filelog.tmpl
+++ b/mercurial/templates/paper/filelog.tmpl
@@ -15,7 +15,7 @@
</div>
<ul>
<li><a href="{url}shortlog/{node|short}{sessionvars%urlparameter}">log</a></li>
-<li><a href="{url}graph/{node|short}{sessionvars%urlparameter}">graph</a></li>
+<li><a href="{url}graph/{node|short}/{file|urlescape}{sessionvars%urlparameter}">graph</a></li>
<li><a href="{url}tags{sessionvars%urlparameter}">tags</a></li>
<li><a href="{url}bookmarks{sessionvars%urlparameter}">bookmarks</a></li>
<li><a href="{url}branches{sessionvars%urlparameter}">branches</a></li>
More information about the Mercurial-devel
mailing list