[PATCH] hgweb: show current search query in the input field

Alexander Plavin me at aplavin.ru
Fri Jul 12 19:43:18 CDT 2013


# HG changeset patch
# User Alexander Plavin <me at aplavin.ru>
# Date 1373547714 -14400
#      Thu Jul 11 17:01:54 2013 +0400
# Node ID 51a3bd5cb254780584711860691ee72e3012a9fc
# Parent  fab1615db25b28837a9af906566c4d8634f06ff8
hgweb: show current search query in the input field

diff -r fab1615db25b -r 51a3bd5cb254 mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Sat Jul 13 02:36:29 2013 +0400
+++ b/mercurial/hgweb/webcommands.py	Thu Jul 11 17:01:54 2013 +0400
@@ -185,11 +185,13 @@
 
 def changelog(web, req, tmpl, shortlog=False):
 
+    query = ''
     if 'node' in req.form:
         ctx = webutil.changectx(web.repo, req)
     else:
         if 'rev' in req.form:
-            hi = req.form['rev'][0]
+            query = req.form['rev'][0]
+            hi = query
         else:
             hi = 'tip'
         try:
@@ -255,7 +257,7 @@
                 entries=lambda **x: changelist(latestonly=False, **x),
                 latestentry=lambda **x: changelist(latestonly=True, **x),
                 archives=web.archivelist("tip"), revcount=revcount,
-                morevars=morevars, lessvars=lessvars)
+                morevars=morevars, lessvars=lessvars, query=query)
 
 def shortlog(web, req, tmpl):
     return changelog(web, req, tmpl, shortlog = True)
diff -r fab1615db25b -r 51a3bd5cb254 mercurial/templates/paper/search.tmpl
--- a/mercurial/templates/paper/search.tmpl	Sat Jul 13 02:36:29 2013 +0400
+++ b/mercurial/templates/paper/search.tmpl	Thu Jul 11 17:01:54 2013 +0400
@@ -25,7 +25,7 @@
 
 <form class="search" action="{url|urlescape}log">
 {sessionvars%hiddenformentry}
-<p><input name="rev" id="search1" type="text" size="30"></p>
+<p><input name="rev" id="search1" type="text" size="30" value="{query|escape}"></p>
 <div id="hint">find changesets by author, revision,
 files, or words in the commit message</div>
 </form>
diff -r fab1615db25b -r 51a3bd5cb254 mercurial/templates/paper/shortlog.tmpl
--- a/mercurial/templates/paper/shortlog.tmpl	Sat Jul 13 02:36:29 2013 +0400
+++ b/mercurial/templates/paper/shortlog.tmpl	Thu Jul 11 17:01:54 2013 +0400
@@ -44,7 +44,7 @@
 
 <form class="search" action="{url|urlescape}log">
 {sessionvars%hiddenformentry}
-<p><input name="rev" id="search1" type="text" size="30" /></p>
+<p><input name="rev" id="search1" type="text" size="30" value="{query|escape}" /></p>
 <div id="hint">find changesets by author, revision,
 files, or words in the commit message</div>
 </form>
diff -r fab1615db25b -r 51a3bd5cb254 tests/test-hgweb-commands.t
--- a/tests/test-hgweb-commands.t	Sat Jul 13 02:36:29 2013 +0400
+++ b/tests/test-hgweb-commands.t	Thu Jul 11 17:01:54 2013 +0400
@@ -257,7 +257,7 @@
   
   <form class="search" action="/log">
   
-  <p><input name="rev" id="search1" type="text" size="30" /></p>
+  <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
   <div id="hint">find changesets by author, revision,
   files, or words in the commit message</div>
   </form>
@@ -495,7 +495,7 @@
   
   <form class="search" action="/log">
   
-  <p><input name="rev" id="search1" type="text" size="30"></p>
+  <p><input name="rev" id="search1" type="text" size="30" value="base"></p>
   <div id="hint">find changesets by author, revision,
   files, or words in the commit message</div>
   </form>
diff -r fab1615db25b -r 51a3bd5cb254 tests/test-hgweb-empty.t
--- a/tests/test-hgweb-empty.t	Sat Jul 13 02:36:29 2013 +0400
+++ b/tests/test-hgweb-empty.t	Thu Jul 11 17:01:54 2013 +0400
@@ -62,7 +62,7 @@
   
   <form class="search" action="/log">
   
-  <p><input name="rev" id="search1" type="text" size="30" /></p>
+  <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
   <div id="hint">find changesets by author, revision,
   files, or words in the commit message</div>
   </form>
@@ -155,7 +155,7 @@
   
   <form class="search" action="/log">
   
-  <p><input name="rev" id="search1" type="text" size="30" /></p>
+  <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
   <div id="hint">find changesets by author, revision,
   files, or words in the commit message</div>
   </form>


More information about the Mercurial-devel mailing list