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

login
register
mail settings
Submitter Alexander Plavin
Date Aug. 27, 2013, 6:09 p.m.
Message ID <1ea68b37d07701cc5374.1377626947@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2276/
State Accepted
Headers show

Comments

Alexander Plavin - Aug. 27, 2013, 6:09 p.m.
# HG changeset patch
# User Alexander Plavin <alexander@plav.in>
# Date 1374187271 -14400
#      Fri Jul 19 02:41:11 2013 +0400
# Node ID 1ea68b37d07701cc53741cd96cc042ac5c62b96a
# Parent  e1404f928161fabcf95ad6c32405cc1cff5e2bb0
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 e1404f928161 -r 1ea68b37d077 mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Thu Aug 22 16:42:10 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(ctx):
+        yield ctx
+
     def keywordsearch(query):
         lower = encoding.lower
         qw = lower(query).split()
@@ -139,11 +142,17 @@ 
             yield ctx
 
     searchfuncs = {
+        'rev': revsearch,
         'keyword': keywordsearch,
     }
 
     def getsearchmode(query):
-        return 'keyword', query
+        try:
+            ctx = web.repo[query]
+        except (error.RepoError, error.LookupError):
+            return 'keyword', query
+        else:
+            return 'rev', ctx
 
     def changelist(**map):
         count = 0