Patchwork [4,of,4,V4] hgweb: add link to force literal keyword search

login
register
mail settings
Submitter Alexander Plavin
Date Sept. 11, 2013, 4:54 p.m.
Message ID <03dc6a0309a6dea38737.1378918444@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2426/
State Accepted
Commit 186f54d40fdd59224c2893534a5715f843cb5f67
Headers show

Comments

Alexander Plavin - Sept. 11, 2013, 4:54 p.m.
# HG changeset patch
# User Alexander Plavin <alexander@plav.in>
# Date 1378459856 -14400
#      Fri Sep 06 13:30:56 2013 +0400
# Node ID 03dc6a0309a6dea38737946d52103e6791015315
# Parent  e7e7ca867d05d18e2f5ae8e71cfab0cf342a88dd
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.

Patch

diff -r e7e7ca867d05 -r 03dc6a0309a6 mercurial/hgweb/webcommands.py
--- 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
@@ -241,6 +241,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']
@@ -249,7 +262,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):
 
diff -r e7e7ca867d05 -r 03dc6a0309a6 mercurial/templates/paper/search.tmpl
--- 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">
diff -r e7e7ca867d05 -r 03dc6a0309a6 tests/test-hgweb-commands.t
--- 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
@@ -495,6 +495,8 @@ 
   
   <p>
   Assuming literal keyword search.
+  
+  
   </p>
   
   <form class="search" action="/log">