@@ -12,7 +12,7 @@ from mercurial.node import short, hex
from mercurial import util
from common import paritygen, staticfile, get_contact, ErrorResponse
from common import HTTP_OK, HTTP_FORBIDDEN, HTTP_NOT_FOUND
-from mercurial import graphmod, patch
+from mercurial import graphmod, patch, minirst
from mercurial import help as helpmod
from mercurial import scmutil
from mercurial.i18n import _
@@ -26,6 +26,7 @@ from mercurial import revset
'log', 'rawfile', 'file', 'changelog', 'shortlog', 'changeset', 'rev',
'manifest', 'tags', 'bookmarks', 'branches', 'summary', 'filediff', 'diff',
'comparison', 'annotate', 'filelog', 'archive', 'static', 'graph', 'help',
+ 'searchhelp',
]
def log(web, req, tmpl):
@@ -1063,6 +1064,25 @@ def _getdoc(e):
doc = _('(no help text available)')
return doc
+def searchhelp(web, req, tmpl):
+ kw = req.form.get('q')[0]
+ matches = helpmod.topicmatch(kw)
+ doclines = []
+ if matches:
+ output = []
+ for t, title in (('topics', _('Topics')),
+ ('commands', _('Commands')),
+ ('extensions', _('Extensions')),
+ ('extensioncommands', _('Extension Commands'))):
+ if matches[t]:
+ doclines.append({'topic': title, 'summary':''})
+ for lhs, rhs in matches[t]:
+ doclines.append({'topic': lhs, 'summary': rhs})
+ doc = ''
+ else:
+ doc = _('No matches found.')
+ return tmpl('searchhelp', doclines=doclines, doc=doc, kw=kw)
+
def help(web, req, tmpl):
from mercurial import commands # avoid cycle
@@ -19,6 +19,10 @@
<ul>
<li class="active"><a href="{url|urlescape}help{sessionvars%urlparameter}">help</a></li>
</ul>
+<form class="searchhelp" action="{url}searchhelp">
+{sessionvars%hiddenformentry}
+<p><input name="q" id="searchhelp" type="text" size="10" value="{kw|escape}"/></p>
+</form>
</div>
<div class="main">
@@ -19,6 +19,10 @@
<ul>
<li class="active">help</li>
</ul>
+<form class="searchhelp" action="{url}searchhelp">
+{sessionvars%hiddenformentry}
+<p><input name="q" id="searchhelp" type="text" size="10" value="{kw|escape}"/></p>
+</form>
</div>
<div class="main">
@@ -11,6 +11,7 @@ shortlogentry = shortlogentry.tmpl
graph = graph.tmpl
help = help.tmpl
helptopics = helptopics.tmpl
+searchhelp = searchhelp.tmpl
helpentry = '
<tr><td>
@@ -21,6 +22,10 @@ helpentry = '
{summary|escape}
</td></tr>'
+helpsearchresult = '{if(summary,
+ "{helpentry}",
+ "\n\n<tr><td colspan=2><h2>{topic}</h2></td></tr>")}'
+
naventry = '<a href="{url|urlescape}log/{node|short}{sessionvars%urlparameter}">{label|escape}</a> '
navshortentry = '<a href="{url|urlescape}shortlog/{node|short}{sessionvars%urlparameter}">{label|escape}</a> '
navgraphentry = '<a href="{url|urlescape}graph/{node|short}{sessionvars%urlparameter}">{label|escape}</a> '
new file mode 100644
@@ -0,0 +1,49 @@
+{header}
+<title>Help Search: {kw|escape}</title>
+<link rel="alternate" type="application/atom+xml"
+ href="{url}atom-tags" title="Atom feed for {repo|escape}" />
+<link rel="alternate" type="application/rss+xml"
+ href="{url}rss-tags" title="RSS feed for {repo|escape}" />
+</head>
+<body>
+
+<div class="container">
+<div class="menu">
+<div class="logo">
+<a href="{logourl}">
+<img src="{staticurl}{logoimg}" alt="mercurial" /></a>
+</div>
+<ul>
+<li><a href="{url}shortlog{sessionvars%urlparameter}">log</a></li>
+<li><a href="{url}graph{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>
+</ul>
+<ul>
+ <li class="active"><a href="{url}help{sessionvars%urlparameter}">help</a></li>
+</ul>
+<form class="searchhelp" action="{url}searchhelp">
+{sessionvars%hiddenformentry}
+<p><input name="q" id="searchhelp" type="text" size="10" value="{kw|escape}"/></p>
+</form>
+</div>
+
+<div class="main">
+<h2><a href="{url}{sessionvars%urlparameter}">{repo|escape}</a></h2>
+
+<form class="search" action="{url}log">
+{sessionvars%hiddenformentry}
+<p><input name="rev" id="search1" type="text" size="30" /></p>
+<div id="hint">find changesets by author, revision,
+files, or words in the commit message</div>
+</form>
+{doc}
+<table class="bigtable">
+<tbody>{doclines % helpsearchresult}
+</tbody>
+</table>
+</div>
+</div>
+
+{footer}
@@ -1145,6 +1145,10 @@ Dish up an empty repo; serve it cold.
<ul>
<li class="active">help</li>
</ul>
+ <form class="searchhelp" action="/searchhelp">
+
+ <p><input name="q" id="searchhelp" type="text" size="10" value=""/></p>
+ </form>
</div>
<div class="main">
@@ -1696,6 +1700,10 @@ Dish up an empty repo; serve it cold.
<ul>
<li class="active"><a href="/help">help</a></li>
</ul>
+ <form class="searchhelp" action="/searchhelp">
+
+ <p><input name="q" id="searchhelp" type="text" size="10" value=""/></p>
+ </form>
</div>
<div class="main">
@@ -1856,6 +1864,10 @@ Dish up an empty repo; serve it cold.
<ul>
<li class="active"><a href="/help">help</a></li>
</ul>
+ <form class="searchhelp" action="/searchhelp">
+
+ <p><input name="q" id="searchhelp" type="text" size="10" value=""/></p>
+ </form>
</div>
<div class="main">
@@ -2046,6 +2058,10 @@ Dish up an empty repo; serve it cold.
<ul>
<li class="active"><a href="/help">help</a></li>
</ul>
+ <form class="searchhelp" action="/searchhelp">
+
+ <p><input name="q" id="searchhelp" type="text" size="10" value=""/></p>
+ </form>
</div>
<div class="main">
@@ -2109,6 +2125,81 @@ Dish up an empty repo; serve it cold.
</body>
</html>
+ $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "searchhelp?q=ignore"
+ 200 Script output follows
+
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
+ <head>
+ <link rel="icon" href="/static/hgicon.png" type="image/png" />
+ <meta name="robots" content="index, nofollow" />
+ <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
+ <script type="text/javascript" src="/static/mercurial.js"></script>
+
+ <title>Help Search: ignore</title>
+ <link rel="alternate" type="application/atom+xml"
+ href="/atom-tags" title="Atom feed for test" />
+ <link rel="alternate" type="application/rss+xml"
+ href="/rss-tags" title="RSS feed for test" />
+ </head>
+ <body>
+
+ <div class="container">
+ <div class="menu">
+ <div class="logo">
+ <a href="http://mercurial.selenic.com/">
+ <img src="/static/hglogo.png" alt="mercurial" /></a>
+ </div>
+ <ul>
+ <li><a href="/shortlog">log</a></li>
+ <li><a href="/graph">graph</a></li>
+ <li><a href="/tags">tags</a></li>
+ <li><a href="/bookmarks">bookmarks</a></li>
+ <li><a href="/branches">branches</a></li>
+ </ul>
+ <ul>
+ <li class="active"><a href="/help">help</a></li>
+ </ul>
+ <form class="searchhelp" action="/searchhelp">
+
+ <p><input name="q" id="searchhelp" type="text" size="10" value="ignore"/></p>
+ </form>
+ </div>
+
+ <div class="main">
+ <h2><a href="/">test</a></h2>
+
+ <form class="search" action="/log">
+
+ <p><input name="rev" id="search1" type="text" size="30" /></p>
+ <div id="hint">find changesets by author, revision,
+ files, or words in the commit message</div>
+ </form>
+
+ <table class="bigtable">
+ <tbody>
+
+ <tr><td colspan=2><h2>Topics</h2></td></tr>
+ <tr><td>
+ <a href="/help/config">
+ config
+ </a>
+ </td><td>
+ Configuration Files
+ </td></tr>
+
+ <tr><td colspan=2><h2>Commands</h2></td></tr>
+ </tbody>
+ </table>
+ </div>
+ </div>
+
+ <script type="text/javascript">process_dates()</script>
+
+
+ </body>
+ </html>
+
$ "$TESTDIR/killdaemons.py" $DAEMON_PIDS