Patchwork [3,of,4] hgweb: search() function supports direct pointing to revision

login
register
mail settings
Submitter Alexander Plavin
Date Aug. 2, 2013, 9:55 p.m.
Message ID <9a4e5f7309fb53e800d0.1375480542@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/1998/
State Superseded
Headers show

Comments

Alexander Plavin - Aug. 2, 2013, 9:55 p.m.
# HG changeset patch
# User Alexander Plavin <alexander@plav.in>
# Date 1374187271 -14400
#      Fri Jul 19 02:41:11 2013 +0400
# Node ID 9a4e5f7309fb53e800d0ada415ce4944ef241704
# Parent  4d2594e04563e2a8b0f63f46a6ad867bec686691
hgweb: search() function supports direct pointing to revision

This doesn't change the behavior, as queries directly pointing to revisions
are not delegated to the search() function now.

Patch

diff -r 4d2594e04563 -r 9a4e5f7309fb mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Fri Jul 19 02:08:19 2013 +0400
+++ b/mercurial/hgweb/webcommands.py	Fri Jul 19 02:41:11 2013 +0400
@@ -110,6 +110,9 @@ 
 
 def _search(web, req, tmpl):
 
+    def revsearch():
+        yield web.repo[query]
+
     def keywordsearch():
         lower = encoding.lower
         qw = lower(query).split()
@@ -138,10 +141,15 @@ 
 
             yield ctx
 
+    searchfuncs = {
+        'rev': revsearch,
+        'kw': keywordsearch,
+    }
+
     def changelist(**map):
         count = 0
 
-        for ctx in keywordsearch():
+        for ctx in searchfunc():
             count += 1
             n = ctx.node()
             showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n)
@@ -181,6 +189,14 @@ 
     morevars['revcount'] = revcount * 2
     morevars['rev'] = query
 
+    try:
+        ctx = web.repo[query]
+        modename = 'rev'
+    except (error.RepoError, error.LookupError):
+        modename = 'kw'
+
+    searchfunc = searchfuncs[modename]
+
     tip = web.repo['tip']
     parity = paritygen(web.stripecount)