[PATCH 1 of 2] hgweb: show current search mode at search results

Alexander Plavin alexander at plav.in
Fri Aug 9 13:56:10 CDT 2013


# HG changeset patch
# User Alexander Plavin <alexander at plav.in>
# Date 1374341357 -14400
#      Sat Jul 20 21:29:17 2013 +0400
# Node ID c982398539da5f6c32b98c9d68a339f527a8335a
# Parent  e495c742bf85e0aef4919c94f08effa6effd3695
hgweb: show current search mode at search results

This can help user in some corner cases or when he mistyped a
function name in his query.

diff -r e495c742bf85 -r c982398539da mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Sat Jul 20 01:32:38 2013 +0400
+++ b/mercurial/hgweb/webcommands.py	Sat Jul 20 21:29:17 2013 +0400
@@ -149,15 +149,15 @@
             yield web.repo[r]
 
     searchfuncs = {
-        'rev': revsearch,
-        'kw': keywordsearch,
-        'revset': revsetsearch,
+        'rev': (revsearch, 'exact revision'),
+        'kw': (keywordsearch, 'literal keyword'),
+        'revset': (revsetsearch, 'revset expression'),
     }
 
     def changelist(**map):
         count = 0
 
-        for ctx in searchfunc():
+        for ctx in searchfunc[0]():
             count += 1
             n = ctx.node()
             showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n)
@@ -238,7 +238,8 @@
 
     return tmpl('search', query=query, node=tip.hex(),
                 entries=changelist, archives=web.archivelist("tip"),
-                morevars=morevars, lessvars=lessvars)
+                morevars=morevars, lessvars=lessvars,
+                modedesc=searchfunc[1])
 
 def changelog(web, req, tmpl, shortlog=False):
 
diff -r e495c742bf85 -r c982398539da mercurial/templates/paper/search.tmpl
--- a/mercurial/templates/paper/search.tmpl	Sat Jul 20 01:32:38 2013 +0400
+++ b/mercurial/templates/paper/search.tmpl	Sat Jul 20 21:29:17 2013 +0400
@@ -23,6 +23,8 @@
 <h2 class="breadcrumb"><a href="/">Mercurial</a> {pathdef%breadcrumb}</h2>
 <h3>searching for '{query|escape}'</h3>
 
+Assuming {modedesc}.
+
 <form class="search" action="{url|urlescape}log">
 {sessionvars%hiddenformentry}
 <p><input name="rev" id="search1" type="text" size="30" value="{query|escape}"></p>
diff -r e495c742bf85 -r c982398539da tests/test-hgweb-commands.t
--- a/tests/test-hgweb-commands.t	Sat Jul 20 01:32:38 2013 +0400
+++ b/tests/test-hgweb-commands.t	Sat Jul 20 21:29:17 2013 +0400
@@ -493,6 +493,8 @@
   <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
   <h3>searching for 'base'</h3>
   
+  Assuming literal keyword.
+  
   <form class="search" action="/log">
   
   <p><input name="rev" id="search1" type="text" size="30" value="base"></p>


More information about the Mercurial-devel mailing list