hgweb: add link to force literal keyword search
This makes it possible to make keyword search in case the search query also
specifies an exact revision (like '1234' or 'abcdef'), or a revset expression.
--- a/mercurial/hgweb/webcommands.py Fri Sep 06 13:30:56 2013 +0400
+++ b/mercurial/hgweb/webcommands.py Fri Sep 06 13:30:56 2013 +0400
@@ -240,6 +240,19 @@
morevars['rev'] = query
mode, funcarg = getsearchmode(query)
+
+ if 'forcekw' in req.form:
+ showforcekw = ''
+ showunforcekw = searchfuncs[mode][1]
+ mode = MODE_KEYWORD
+ funcarg = query
+ else:
+ if mode != MODE_KEYWORD:
+ showforcekw = searchfuncs[MODE_KEYWORD][1]
+ else:
+ showforcekw = ''
+ showunforcekw = ''
+
searchfunc = searchfuncs[mode]
tip = web.repo['tip']
@@ -248,7 +261,8 @@
return tmpl('search', query=query, node=tip.hex(),
entries=changelist, archives=web.archivelist("tip"),
morevars=morevars, lessvars=lessvars,
- modedesc=searchfunc[1])
+ modedesc=searchfunc[1],
+ showforcekw=showforcekw, showunforcekw=showunforcekw)
def changelog(web, req, tmpl, shortlog=False):
--- a/mercurial/templates/paper/search.tmpl Fri Sep 06 13:30:56 2013 +0400
+++ b/mercurial/templates/paper/search.tmpl Fri Sep 06 13:30:56 2013 +0400
@@ -25,6 +25,10 @@
<p>
Assuming {modedesc}.
+{if(showforcekw, '<a href="{url|urlescape}log?rev={query|urlescape}&forcekw=1">
+Use {showforcekw}</a> instead.')}
+{if(showunforcekw, '<a href="{url|urlescape}log?rev={query|urlescape}">
+Use {showunforcekw}</a> instead.')}
</p>
<form class="search" action="{url|urlescape}log">
--- a/tests/test-hgweb-commands.t Fri Sep 06 13:30:56 2013 +0400
+++ b/tests/test-hgweb-commands.t Fri Sep 06 13:30:56 2013 +0400
@@ -509,6 +509,8 @@
<p>
Assuming literal keyword search.
+
+
</p>
<form class="search" action="/log">