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

login
register
mail settings
Submitter Alexander Plavin
Date Aug. 22, 2013, 3:12 p.m.
Message ID <b495249eb9ea62a43259.1377184344@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2253/
State Superseded
Commit 186f54d40fdd59224c2893534a5715f843cb5f67
Headers show

Comments

Alexander Plavin - Aug. 22, 2013, 3:12 p.m.
# HG changeset patch
# User Alexander Plavin <alexander@plav.in>
# Date 1376680910 -14400
#      Fri Aug 16 23:21:50 2013 +0400
# Node ID b495249eb9ea62a43259c05bde1560989be4fba7
# Parent  db2d5658d6dc5322aea42a72e1aeb60dcb44dd13
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 db2d5658d6dc -r b495249eb9ea mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Fri Aug 16 23:16:15 2013 +0400
+++ b/mercurial/hgweb/webcommands.py	Fri Aug 16 23:21:50 2013 +0400
@@ -241,6 +241,15 @@ 
     morevars['rev'] = query
 
     mode, funcarg = getsearchmode(query)
+
+    if 'forcekw' in req.form:
+        showforcekw = ''
+        showunforcekw = searchfuncs[mode][1]
+        mode = 'kw'
+    else:
+        showforcekw = mode != 'kw' and searchfuncs['kw'][1] or ''
+        showunforcekw = ''
+
     searchfunc = searchfuncs[mode]
 
     tip = web.repo['tip']
@@ -249,7 +258,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 db2d5658d6dc -r b495249eb9ea mercurial/templates/paper/search.tmpl
--- a/mercurial/templates/paper/search.tmpl	Fri Aug 16 23:16:15 2013 +0400
+++ b/mercurial/templates/paper/search.tmpl	Fri Aug 16 23:21:50 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 db2d5658d6dc -r b495249eb9ea tests/test-hgweb-commands.t
--- a/tests/test-hgweb-commands.t	Fri Aug 16 23:16:15 2013 +0400
+++ b/tests/test-hgweb-commands.t	Fri Aug 16 23:21:50 2013 +0400
@@ -495,6 +495,8 @@ 
   
   <p>
   Assuming literal keyword.
+  
+  
   </p>
   
   <form class="search" action="/log">