diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -13,6 +13,9 @@ 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 help as helpmod
+from mercurial import ui
+from mercurial.i18n import _
# __all__ is populated with the allowed commands. Be sure to add to it if
# you're adding a new command, or the new command won't work.
@@ -20,7 +23,7 @@ from mercurial import graphmod
__all__ = [
'log', 'rawfile', 'file', 'changelog', 'shortlog', 'changeset', 'rev',
'manifest', 'tags', 'branches', 'summary', 'filediff', 'diff', 'annotate',
- 'filelog', 'archive', 'static', 'graph',
+ 'filelog', 'archive', 'static', 'graph', 'help',
]
def log(web, req, tmpl):
@@ -724,3 +727,58 @@ def graph(web, req, tmpl):
lessvars=lessvars, morevars=morevars, downrev=downrev,
canvasheight=canvasheight, jsdata=data, bg_height=bg_height,
node=revnode_hex, changenav=changenav)
+
+def _getdoc(e):
+ doc = e[0].__doc__
+ if doc:
+ doc = doc.split('\n')[0]
+ else:
+ doc = _('(no help text available)')
+ return doc
+
+def help(web, req, tmpl):
+ from mercurial import commands # avoid cycle
+
+ topicname = req.form.get('node', [None])[0]
+ if not topicname:
+ topic = []
+
+ def topics(**map):
+ for entries, summary, _ in helpmod.helptable:
+ entries = sorted(entries, key=len)
+ yield {'topic': entries[-1], 'summary': summary}
+
+ early, other = [], []
+ primary = lambda s: s.split('|')[0]
+ for c, e in commands.table.iteritems():
+ doc = _getdoc(e)
+ if 'DEPRECATED' in doc or c.startswith('debug'):
+ continue
+ cmd = primary(c)
+ if cmd.startswith('^'):
+ early.append((cmd[1:], doc))
+ else:
+ other.append((cmd, doc))
+
+ early.sort()
+ other.sort()
+
+ def earlycommands(**map):
+ for c, doc in early:
+ yield {'topic': c, 'summary': doc}
+
+ def othercommands(**map):
+ for c, doc in other:
+ yield {'topic': c, 'summary': doc}
+
+ return tmpl('helptopics', topics=topics, earlycommands=earlycommands,
+ othercommands=othercommands, title='Index')
+
+ u = ui.ui()
+ u.pushbuffer()
+ try:
+ commands.help_(u, topicname)
+ except error.UnknownCommand:
+ raise ErrorResponse(HTTP_NOT_FOUND)
+ doc = u.popbuffer()
+ return tmpl('help', topic=topicname, doc=doc)
diff --git a/mercurial/templates/coal/map b/mercurial/templates/coal/map
--- a/mercurial/templates/coal/map
+++ b/mercurial/templates/coal/map
@@ -10,6 +10,11 @@ shortlog = ../paper/shortlog.tmpl
shortlogentry = ../paper/shortlogentry.tmpl
graph = ../paper/graph.tmpl
+help = ../paper/help.tmpl
+helptopics = ../paper/helptopics.tmpl
+
+helpentry = '
{topic|escape} {summary|escape} '
+
naventry = '{label|escape} '
navshortentry = '{label|escape} '
navgraphentry = '{label|escape} '
diff --git a/mercurial/templates/gitweb/branches.tmpl b/mercurial/templates/gitweb/branches.tmpl
--- a/mercurial/templates/gitweb/branches.tmpl
+++ b/mercurial/templates/gitweb/branches.tmpl
@@ -18,7 +18,8 @@
graph |
tags |
branches |
-files
+files |
+help
diff --git a/mercurial/templates/gitweb/changelog.tmpl b/mercurial/templates/gitweb/changelog.tmpl
--- a/mercurial/templates/gitweb/changelog.tmpl
+++ b/mercurial/templates/gitweb/changelog.tmpl
@@ -25,7 +25,8 @@ changelog |
graph |
tags |
branches |
-files {archives%archiveentry}
+files {archives%archiveentry} |
+help
{changenav%nav}
diff --git a/mercurial/templates/gitweb/changeset.tmpl b/mercurial/templates/gitweb/changeset.tmpl
--- a/mercurial/templates/gitweb/changeset.tmpl
+++ b/mercurial/templates/gitweb/changeset.tmpl
@@ -20,7 +20,9 @@
branches |
files |
changeset |
-raw {archives%archiveentry}
+raw {archives%archiveentry} |
+help
+
diff --git a/mercurial/templates/gitweb/filediff.tmpl b/mercurial/templates/gitweb/filediff.tmpl
--- a/mercurial/templates/gitweb/filediff.tmpl
+++ b/mercurial/templates/gitweb/filediff.tmpl
@@ -25,7 +25,8 @@
revisions |
annotate |
diff |
-
raw
+
raw |
+
help
{file|escape}
diff --git a/mercurial/templates/gitweb/graph.tmpl b/mercurial/templates/gitweb/graph.tmpl
--- a/mercurial/templates/gitweb/graph.tmpl
+++ b/mercurial/templates/gitweb/graph.tmpl
@@ -25,7 +25,8 @@
graph |
tags |
branches |
-files
+files |
+help
less
more
diff --git a/mercurial/templates/gitweb/branches.tmpl b/mercurial/templates/gitweb/help.tmpl
copy from mercurial/templates/gitweb/branches.tmpl
copy to mercurial/templates/gitweb/help.tmpl
--- a/mercurial/templates/gitweb/branches.tmpl
+++ b/mercurial/templates/gitweb/help.tmpl
@@ -23,8 +23,9 @@ branches |
-
+
+
+{doc|escape}
+
{footer}
diff --git a/mercurial/templates/gitweb/branches.tmpl b/mercurial/templates/gitweb/helptopics.tmpl
copy from mercurial/templates/gitweb/branches.tmpl
copy to mercurial/templates/gitweb/helptopics.tmpl
--- a/mercurial/templates/gitweb/branches.tmpl
+++ b/mercurial/templates/gitweb/helptopics.tmpl
@@ -17,14 +17,22 @@
changelog |
graph |
tags |
-branches |
-files
+branches |
+files |
+help
-{entries%branchentry}
+
+{topics % helpentry}
+
+
+{earlycommands % helpentry}
+
+
+{othercommands % helpentry}
{footer}
diff --git a/mercurial/templates/gitweb/manifest.tmpl b/mercurial/templates/gitweb/manifest.tmpl
--- a/mercurial/templates/gitweb/manifest.tmpl
+++ b/mercurial/templates/gitweb/manifest.tmpl
@@ -19,7 +19,9 @@
tags |
branches |
files |
-changeset {archives%archiveentry}
+changeset {archives%archiveentry} |
+help
+
{path|escape} {inbranch%inbranchtag}{branches%branchtag}{tags%tagtag}
diff --git a/mercurial/templates/gitweb/map b/mercurial/templates/gitweb/map
--- a/mercurial/templates/gitweb/map
+++ b/mercurial/templates/gitweb/map
@@ -7,6 +7,12 @@ changelog = changelog.tmpl
summary = summary.tmpl
error = error.tmpl
notfound = notfound.tmpl
+
+help = help.tmpl
+helptopics = helptopics.tmpl
+
+helpentry = '{topic|escape} {summary|escape} '
+
naventry = '{label|escape} '
navshortentry = '{label|escape} '
navgraphentry = '{label|escape} '
diff --git a/mercurial/templates/gitweb/shortlog.tmpl b/mercurial/templates/gitweb/shortlog.tmpl
--- a/mercurial/templates/gitweb/shortlog.tmpl
+++ b/mercurial/templates/gitweb/shortlog.tmpl
@@ -24,7 +24,8 @@ shortlog |
graph |
tags |
branches |
-files {archives%archiveentry}
+files {archives%archiveentry} |
+help
{changenav%navshort}
diff --git a/mercurial/templates/gitweb/summary.tmpl b/mercurial/templates/gitweb/summary.tmpl
--- a/mercurial/templates/gitweb/summary.tmpl
+++ b/mercurial/templates/gitweb/summary.tmpl
@@ -25,7 +25,8 @@ summary |
graph |
tags |
branches |
-files {archives%archiveentry}
+files {archives%archiveentry} |
+help
diff --git a/mercurial/templates/gitweb/tags.tmpl b/mercurial/templates/gitweb/tags.tmpl
--- a/mercurial/templates/gitweb/tags.tmpl
+++ b/mercurial/templates/gitweb/tags.tmpl
@@ -18,7 +18,8 @@
graph |
tags |
branches |
-files
+files |
+help
diff --git a/mercurial/templates/monoblue/branches.tmpl b/mercurial/templates/monoblue/branches.tmpl
--- a/mercurial/templates/monoblue/branches.tmpl
+++ b/mercurial/templates/monoblue/branches.tmpl
@@ -25,6 +25,7 @@
tags
branches
files
+ help
diff --git a/mercurial/templates/monoblue/changelog.tmpl b/mercurial/templates/monoblue/changelog.tmpl
--- a/mercurial/templates/monoblue/changelog.tmpl
+++ b/mercurial/templates/monoblue/changelog.tmpl
@@ -25,6 +25,7 @@
tags
branches
files {archives%archiveentry}
+ help
diff --git a/mercurial/templates/monoblue/graph.tmpl b/mercurial/templates/monoblue/graph.tmpl
--- a/mercurial/templates/monoblue/graph.tmpl
+++ b/mercurial/templates/monoblue/graph.tmpl
@@ -26,6 +26,7 @@
tags
branches
files
+ help
diff --git a/mercurial/templates/monoblue/branches.tmpl b/mercurial/templates/monoblue/help.tmpl
copy from mercurial/templates/monoblue/branches.tmpl
copy to mercurial/templates/monoblue/help.tmpl
--- a/mercurial/templates/monoblue/branches.tmpl
+++ b/mercurial/templates/monoblue/help.tmpl
@@ -23,14 +23,15 @@
changelog
graph
tags
- branches
+ branches
files
+ help
branches
-
+
+ {doc|escape}
+
{footer}
diff --git a/mercurial/templates/monoblue/branches.tmpl b/mercurial/templates/monoblue/helptopics.tmpl
copy from mercurial/templates/monoblue/branches.tmpl
copy to mercurial/templates/monoblue/helptopics.tmpl
--- a/mercurial/templates/monoblue/branches.tmpl
+++ b/mercurial/templates/monoblue/helptopics.tmpl
@@ -23,14 +23,22 @@
changelog
graph
tags
- branches
+ branches
files
+ help
branches
-{entries%branchentry}
+
+ {topics % helpentry}
+
+
+ {earlycommands % helpentry}
+
+
+ {othercommands % helpentry}
{footer}
diff --git a/mercurial/templates/monoblue/manifest.tmpl b/mercurial/templates/monoblue/manifest.tmpl
--- a/mercurial/templates/monoblue/manifest.tmpl
+++ b/mercurial/templates/monoblue/manifest.tmpl
@@ -25,6 +25,7 @@
tags
branches
files
+ help
diff --git a/mercurial/templates/monoblue/map b/mercurial/templates/monoblue/map
--- a/mercurial/templates/monoblue/map
+++ b/mercurial/templates/monoblue/map
@@ -7,6 +7,12 @@ changelog = changelog.tmpl
summary = summary.tmpl
error = error.tmpl
notfound = notfound.tmpl
+
+help = help.tmpl
+helptopics = helptopics.tmpl
+
+helpentry = '{topic|escape} {summary|escape} '
+
naventry = '{label|escape} '
navshortentry = '{label|escape} '
navgraphentry = '{label|escape} '
@@ -75,7 +81,7 @@ annotateline = '
{author|user}@{rev}
+ title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}
{linenumber}
diff --git a/mercurial/templates/monoblue/shortlog.tmpl b/mercurial/templates/monoblue/shortlog.tmpl
--- a/mercurial/templates/monoblue/shortlog.tmpl
+++ b/mercurial/templates/monoblue/shortlog.tmpl
@@ -24,7 +24,9 @@
graph
tags
branches
- files {archives%archiveentry}
+ files
+ {archives%archiveentry}
+ help
diff --git a/mercurial/templates/monoblue/summary.tmpl b/mercurial/templates/monoblue/summary.tmpl
--- a/mercurial/templates/monoblue/summary.tmpl
+++ b/mercurial/templates/monoblue/summary.tmpl
@@ -25,6 +25,7 @@
tags
branches
files
+ help
diff --git a/mercurial/templates/monoblue/tags.tmpl b/mercurial/templates/monoblue/tags.tmpl
--- a/mercurial/templates/monoblue/tags.tmpl
+++ b/mercurial/templates/monoblue/tags.tmpl
@@ -25,6 +25,7 @@
tags
branches
files
+ help
diff --git a/mercurial/templates/paper/changeset.tmpl b/mercurial/templates/paper/changeset.tmpl
--- a/mercurial/templates/paper/changeset.tmpl
+++ b/mercurial/templates/paper/changeset.tmpl
@@ -22,6 +22,9 @@
+
diff --git a/mercurial/templates/paper/graph.tmpl b/mercurial/templates/paper/graph.tmpl
--- a/mercurial/templates/paper/graph.tmpl
+++ b/mercurial/templates/paper/graph.tmpl
@@ -24,6 +24,9 @@
changeset
browse
+
diff --git a/mercurial/templates/paper/help.tmpl b/mercurial/templates/paper/help.tmpl
new file mode 100644
--- /dev/null
+++ b/mercurial/templates/paper/help.tmpl
@@ -0,0 +1,43 @@
+{header}
+
Help: {topic}
+
+
+
+
+
+
+
+
+
+
+
Help: {topic}
+
+
+
+{doc|escape}
+
+
+
+
+{footer}
diff --git a/mercurial/templates/paper/helptopics.tmpl b/mercurial/templates/paper/helptopics.tmpl
new file mode 100644
--- /dev/null
+++ b/mercurial/templates/paper/helptopics.tmpl
@@ -0,0 +1,48 @@
+{header}
+
Help: {title}
+
+
+
+
+
+
+
+
+
+
+
+
+
+{topics % helpentry}
+
+
+{earlycommands % helpentry}
+
+
+{othercommands % helpentry}
+
+
+
+
+{footer}
diff --git a/mercurial/templates/paper/manifest.tmpl b/mercurial/templates/paper/manifest.tmpl
--- a/mercurial/templates/paper/manifest.tmpl
+++ b/mercurial/templates/paper/manifest.tmpl
@@ -22,6 +22,9 @@
+
diff --git a/mercurial/templates/paper/map b/mercurial/templates/paper/map
--- a/mercurial/templates/paper/map
+++ b/mercurial/templates/paper/map
@@ -9,6 +9,10 @@ changelog = shortlog.tmpl
shortlog = shortlog.tmpl
shortlogentry = shortlogentry.tmpl
graph = graph.tmpl
+help = help.tmpl
+helptopics = helptopics.tmpl
+
+helpentry = '
{topic|escape} {summary|escape} '
naventry = '
{label|escape} '
navshortentry = '
{label|escape} '
diff --git a/mercurial/templates/paper/shortlog.tmpl b/mercurial/templates/paper/shortlog.tmpl
--- a/mercurial/templates/paper/shortlog.tmpl
+++ b/mercurial/templates/paper/shortlog.tmpl
@@ -26,6 +26,9 @@
+
diff --git a/mercurial/templates/paper/tags.tmpl b/mercurial/templates/paper/tags.tmpl
--- a/mercurial/templates/paper/tags.tmpl
+++ b/mercurial/templates/paper/tags.tmpl
@@ -19,6 +19,9 @@
tags
branches
+
diff --git a/mercurial/templates/static/style-monoblue.css b/mercurial/templates/static/style-monoblue.css
--- a/mercurial/templates/static/style-monoblue.css
+++ b/mercurial/templates/static/style-monoblue.css
@@ -83,7 +83,7 @@ div.page-header {
margin: 10px 0 0 0;
list-style-type: none;
overflow: hidden;
- width: 800px;
+ width: 900px;
}
ul.page-nav li {
margin: 0 2px 0 0;
diff --git a/tests/test-hgweb-commands.t b/tests/test-hgweb-commands.t
--- a/tests/test-hgweb-commands.t
+++ b/tests/test-hgweb-commands.t
@@ -205,6 +205,7 @@ Logs and changes
graph
tags
branches
+
help
changeset
@@ -213,6 +214,9 @@ Logs and changes
+
@@ -294,6 +298,7 @@ Logs and changes
graph
tags
branches
+
help
changeset
@@ -303,6 +308,9 @@ Logs and changes
+
@@ -627,7 +635,8 @@ Overviews
graph |
tags |
branches |
-
files
+
files |
+
help
@@ -778,7 +787,8 @@ Overviews
graph |
tags |
branches |
- files
+ files |
+ help
less
more
diff --git a/tests/test-hgweb-descend-empties.t b/tests/test-hgweb-descend-empties.t
--- a/tests/test-hgweb-descend-empties.t
+++ b/tests/test-hgweb-descend-empties.t
@@ -52,6 +52,7 @@ manifest with descending
graph
tags
branches
+ help
changeset
@@ -60,6 +61,9 @@ manifest with descending
+
diff --git a/tests/test-hgweb-diffs.t b/tests/test-hgweb-diffs.t
--- a/tests/test-hgweb-diffs.t
+++ b/tests/test-hgweb-diffs.t
@@ -44,6 +44,7 @@ revision
graph
tags
branches
+
help
changeset
@@ -53,6 +54,9 @@ revision
+
@@ -263,6 +267,7 @@ revision
graph
tags
branches
+
help
changeset
@@ -272,6 +277,9 @@ revision
+
diff --git a/tests/test-hgweb-empty.t b/tests/test-hgweb-empty.t
--- a/tests/test-hgweb-empty.t
+++ b/tests/test-hgweb-empty.t
@@ -33,6 +33,7 @@ Some tests for hgweb in an empty reposit
graph
tags
branches
+
help
changeset
@@ -41,6 +42,9 @@ Some tests for hgweb in an empty reposit
+
@@ -112,6 +116,7 @@ Some tests for hgweb in an empty reposit
graph
tags
branches
+
help
changeset
@@ -120,6 +125,9 @@ Some tests for hgweb in an empty reposit
+
@@ -192,11 +200,15 @@ Some tests for hgweb in an empty reposit
graph
tags
branches
+
help
+
@@ -332,6 +344,7 @@ Some tests for hgweb in an empty reposit
graph
tags
branches
+
help
changeset
@@ -340,6 +353,9 @@ Some tests for hgweb in an empty reposit
+
diff --git a/tests/test-hgweb-removed.t b/tests/test-hgweb-removed.t
--- a/tests/test-hgweb-removed.t
+++ b/tests/test-hgweb-removed.t
@@ -39,6 +39,7 @@ revision
graph
tags
branches
+
help
changeset
@@ -48,6 +49,9 @@ revision
+
diff --git a/tests/test-hgweb.t b/tests/test-hgweb.t
--- a/tests/test-hgweb.t
+++ b/tests/test-hgweb.t
@@ -213,6 +213,7 @@ try bad style
graph
tags
branches
+
help
changeset
@@ -221,6 +222,9 @@ try bad style
+