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

login
register
mail settings
Submitter Alexander Plavin
Date Aug. 9, 2013, 6:56 p.m.
Message ID <c982398539da5f6c32b9.1376074570@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2106/
State Superseded
Headers show

Comments

Alexander Plavin - Aug. 9, 2013, 6:56 p.m.
# HG changeset patch
# User Alexander Plavin <alexander@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.
Laurens Holst - Aug. 10, 2013, 12:59 p.m.
Op 09-08-13 20:56, Alexander Plavin schreef:
> # HG changeset patch
> # User Alexander Plavin <alexander@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'),

Is this localisable?

~Laurens
Laurens Holst - Aug. 10, 2013, 1 p.m.
Op 09-08-13 20:56, Alexander Plavin schreef:
> # HG changeset patch
> # User Alexander Plavin <alexander@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}.

Also, shouldn’t there be <p> tags around these?

> +
>   <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.
> +

Ditto.

>     <form class="search" action="/log">
>     
>     <p><input name="rev" id="search1" type="text" size="30" value="base"></p>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
Alexander Plavin - Aug. 12, 2013, 5:39 p.m.
10.08.2013, 17:00, "Laurens Holst" <laurens.nospam@grauw.nl>:
> Op 09-08-13 20:56, Alexander Plavin schreef:
>
>>  # HG changeset patch
>>  # User Alexander Plavin <alexander@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'),
>
> Is this localisable?

Nope. Not sure if it is ok (enough) to add '_(...)' to it?

Hgweb isn't fully localisable already, by the way (by changing templates only), in particular some error messages.

>
> ~Laurens
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Alexander Plavin - Aug. 12, 2013, 5:42 p.m.
10.08.2013, 17:01, "Laurens Holst" <laurens.nospam@grauw.nl>:
> Op 09-08-13 20:56, Alexander Plavin schreef:
>
>>  # HG changeset patch
>>  # User Alexander Plavin <alexander@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}.
>
> Also, shouldn’t there be <p> tags around these?

Not necessary (i.e. it works fine now), but I agree that they would fit here better than no tags.

>
>>  +
>>    <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.
>>  +
>
> Ditto.

This is just a test, so it will follow the actual code changes anyway :)

>
>>      <form class="search" action="/log">
>>
>>      <p><input name="rev" id="search1" type="text" size="30" value="base"></p>
>>  _______________________________________________
>>  Mercurial-devel mailing list
>>  Mercurial-devel@selenic.com
>>  http://selenic.com/mailman/listinfo/mercurial-devel
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

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>