# HG changeset patch # User Augie Fackler # Date 1286645234 18000 # Node ID ead4e21f49f16789667ee619be7ef7436b494691 # Parent cf24b6b5517cffb6fbffe85c383c13af76a41694 web: add a help view for getting hg help output diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/hgweb/webcommands.py Sat Oct 09 12:27:14 2010 -0500 @@ -13,6 +13,9 @@ 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 @@ __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 @@ 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 -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/coal/map --- a/mercurial/templates/coal/map Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/coal/map Sat Oct 09 12:27:14 2010 -0500 @@ -10,6 +10,11 @@ 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 -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/gitweb/branches.tmpl --- a/mercurial/templates/gitweb/branches.tmpl Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/gitweb/branches.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -18,7 +18,8 @@ graph | tags | branches | -files +files | +help
diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/gitweb/changelog.tmpl --- a/mercurial/templates/gitweb/changelog.tmpl Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/gitweb/changelog.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -25,7 +25,8 @@ graph | tags | branches | -files{archives%archiveentry} +files{archives%archiveentry} | +help
{changenav%nav}
diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/gitweb/changeset.tmpl --- a/mercurial/templates/gitweb/changeset.tmpl Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/gitweb/changeset.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -20,7 +20,9 @@ branches | files | changeset | -raw {archives%archiveentry}
+raw {archives%archiveentry} | +help +
diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/gitweb/filediff.tmpl --- a/mercurial/templates/gitweb/filediff.tmpl Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/gitweb/filediff.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -25,7 +25,8 @@ revisions | annotate | diff | -raw
+raw
| +help
{file|escape}
diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/gitweb/graph.tmpl --- a/mercurial/templates/gitweb/graph.tmpl Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/gitweb/graph.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -25,7 +25,8 @@ graph | tags | branches | -files +files | +help
less more diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/gitweb/help.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/templates/gitweb/help.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -0,0 +1,31 @@ +{header} +{repo|escape}: Branches + + + + + + + + + +
 
+ +
+{doc|escape}
+
+ +{footer} diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/gitweb/helptopics.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/templates/gitweb/helptopics.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -0,0 +1,38 @@ +{header} +{repo|escape}: Branches + + + + + + + + + +
 
+ + +{topics % helpentry} + + +{earlycommands % helpentry} + + +{othercommands % helpentry} +

Topics

Main Commands

Other Commands

+ +{footer} diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/gitweb/manifest.tmpl --- a/mercurial/templates/gitweb/manifest.tmpl Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/gitweb/manifest.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -19,7 +19,9 @@ tags | branches | files | -changeset {archives%archiveentry}
+changeset {archives%archiveentry} | +help +
{path|escape} {inbranch%inbranchtag}{branches%branchtag}{tags%tagtag}
diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/gitweb/map --- a/mercurial/templates/gitweb/map Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/gitweb/map Sat Oct 09 12:27:14 2010 -0500 @@ -7,6 +7,12 @@ 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 -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/gitweb/shortlog.tmpl --- a/mercurial/templates/gitweb/shortlog.tmpl Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/gitweb/shortlog.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -24,7 +24,8 @@ graph | tags | branches | -files{archives%archiveentry} +files{archives%archiveentry} | +help
{changenav%navshort}
diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/gitweb/summary.tmpl --- a/mercurial/templates/gitweb/summary.tmpl Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/gitweb/summary.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -25,7 +25,8 @@ graph | tags | branches | -files{archives%archiveentry} +files{archives%archiveentry} | +help
diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/gitweb/tags.tmpl --- a/mercurial/templates/gitweb/tags.tmpl Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/gitweb/tags.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -18,7 +18,8 @@ graph | tags | branches | -files +files | +help
diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/monoblue/branches.tmpl --- a/mercurial/templates/monoblue/branches.tmpl Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/monoblue/branches.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -25,6 +25,7 @@
  • tags
  • branches
  • files
  • +
  • help
  • diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/monoblue/changelog.tmpl --- a/mercurial/templates/monoblue/changelog.tmpl Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/monoblue/changelog.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -25,6 +25,7 @@
  • tags
  • branches
  • files{archives%archiveentry}
  • +
  • help
  • diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/monoblue/graph.tmpl --- a/mercurial/templates/monoblue/graph.tmpl Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/monoblue/graph.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -26,6 +26,7 @@
  • tags
  • branches
  • files
  • +
  • help
  • diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/monoblue/help.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/templates/monoblue/help.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -0,0 +1,37 @@ +{header} + {repo|escape}: Branches + + + + + +
    + + + +
    +    {doc|escape}
    +    
    + +{footer} diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/monoblue/helptopics.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/templates/monoblue/helptopics.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -0,0 +1,44 @@ +{header} + {repo|escape}: Branches + + + + + +
    + + + + + + {topics % helpentry} + + + {earlycommands % helpentry} + + + {othercommands % helpentry} +

    Topics

    Main Commands

    Other Commands

    + +{footer} diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/monoblue/manifest.tmpl --- a/mercurial/templates/monoblue/manifest.tmpl Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/monoblue/manifest.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -25,6 +25,7 @@
  • tags
  • branches
  • files
  • +
  • help
  • diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/monoblue/map --- a/mercurial/templates/monoblue/map Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/monoblue/map Sat Oct 09 12:27:14 2010 -0500 @@ -7,6 +7,12 @@ 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 @@ {author|user}@{rev} + title="{node|short}: {desc|escape|firstline}">{author|user}@{rev} {linenumber} diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/monoblue/shortlog.tmpl --- a/mercurial/templates/monoblue/shortlog.tmpl Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/monoblue/shortlog.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -24,7 +24,9 @@
  • graph
  • tags
  • branches
  • -
  • files{archives%archiveentry}
  • +
  • files
  • + {archives%archiveentry} +
  • help
  • diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/monoblue/summary.tmpl --- a/mercurial/templates/monoblue/summary.tmpl Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/monoblue/summary.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -25,6 +25,7 @@
  • tags
  • branches
  • files
  • +
  • help
  • diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/monoblue/tags.tmpl --- a/mercurial/templates/monoblue/tags.tmpl Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/monoblue/tags.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -25,6 +25,7 @@
  • tags
  • branches
  • files
  • +
  • help
  • diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/paper/changeset.tmpl --- a/mercurial/templates/paper/changeset.tmpl Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/paper/changeset.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -22,6 +22,9 @@ +
    diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/paper/graph.tmpl --- a/mercurial/templates/paper/graph.tmpl Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/paper/graph.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -24,6 +24,9 @@
  • changeset
  • browse
  • +
    diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/paper/help.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/templates/paper/help.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -0,0 +1,43 @@ +{header} +Help: {topic} + + + + + +
    + + +
    +

    {repo|escape}

    +

    Help: {topic}

    + + +
    +{doc|escape}
    +
    +
    +
    + +{footer} diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/paper/helptopics.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/templates/paper/helptopics.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -0,0 +1,48 @@ +{header} +Help: {title} + + + + + +
    + + +
    +

    {repo|escape}

    + + + +{topics % helpentry} + + +{earlycommands % helpentry} + + +{othercommands % helpentry} +

    Topics

    Main Commands

    Other Commands

    +
    +
    + +{footer} diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/paper/manifest.tmpl --- a/mercurial/templates/paper/manifest.tmpl Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/paper/manifest.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -22,6 +22,9 @@ +
    diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/paper/map --- a/mercurial/templates/paper/map Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/paper/map Sat Oct 09 12:27:14 2010 -0500 @@ -9,6 +9,10 @@ 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 -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/paper/shortlog.tmpl --- a/mercurial/templates/paper/shortlog.tmpl Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/paper/shortlog.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -26,6 +26,9 @@ +
    diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/paper/tags.tmpl --- a/mercurial/templates/paper/tags.tmpl Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/paper/tags.tmpl Sat Oct 09 12:27:14 2010 -0500 @@ -19,6 +19,9 @@
  • tags
  • branches
  • +
    diff -r cf24b6b5517c -r ead4e21f49f1 mercurial/templates/static/style-monoblue.css --- a/mercurial/templates/static/style-monoblue.css Sat Oct 09 15:00:30 2010 -0500 +++ b/mercurial/templates/static/style-monoblue.css Sat Oct 09 12:27:14 2010 -0500 @@ -83,7 +83,7 @@ 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 -r cf24b6b5517c -r ead4e21f49f1 tests/test-hgweb-commands.t --- a/tests/test-hgweb-commands.t Sat Oct 09 15:00:30 2010 -0500 +++ b/tests/test-hgweb-commands.t Sat Oct 09 12:27:14 2010 -0500 @@ -205,6 +205,7 @@
  • graph
  • tags
  • branches
  • +
  • help
  • @@ -294,6 +298,7 @@
  • graph
  • tags
  • branches
  • +
  • help
  • @@ -627,7 +635,8 @@ graph | tags | branches | - files + files | + help
    @@ -778,7 +787,8 @@ graph | tags | branches | - files + files | + help
    less more diff -r cf24b6b5517c -r ead4e21f49f1 tests/test-hgweb-descend-empties.t --- a/tests/test-hgweb-descend-empties.t Sat Oct 09 15:00:30 2010 -0500 +++ b/tests/test-hgweb-descend-empties.t Sat Oct 09 12:27:14 2010 -0500 @@ -52,6 +52,7 @@
  • graph
  • tags
  • branches
  • +
  • help
  • +
    @@ -332,6 +344,7 @@
  • graph
  • tags
  • branches
  • +
  • help
  • diff -r cf24b6b5517c -r ead4e21f49f1 tests/test-hgweb-removed.t --- a/tests/test-hgweb-removed.t Sat Oct 09 15:00:30 2010 -0500 +++ b/tests/test-hgweb-removed.t Sat Oct 09 12:27:14 2010 -0500 @@ -39,6 +39,7 @@
  • graph
  • tags
  • branches
  • +
  • help
  • diff -r cf24b6b5517c -r ead4e21f49f1 tests/test-hgweb.t --- a/tests/test-hgweb.t Sat Oct 09 15:00:30 2010 -0500 +++ b/tests/test-hgweb.t Sat Oct 09 12:27:14 2010 -0500 @@ -213,6 +213,7 @@
  • graph
  • tags
  • branches
  • +
  • help