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

Alexander Plavin alexander at plav.in
Thu Aug 22 10:09:29 CDT 2013


# HG changeset patch
# User Alexander Plavin <alexander at plav.in>
# Date 1374187271 -14400
#      Fri Jul 19 02:41:11 2013 +0400
# Node ID ffa9a6d28047bfe1803676327269a1426769a7a8
# Parent  16fe12bb559fe7e920fa413470c29780d1810983
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.

diff -r 16fe12bb559f -r ffa9a6d28047 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,
         'kw': keywordsearch,
     }
 
     def getsearchmode(query):
-        return 'kw', query
+        try:
+            ctx = web.repo[query]
+        except (error.RepoError, error.LookupError):
+            return 'kw', query
+        else:
+            return 'rev', ctx
 
     def changelist(**map):
         count = 0


More information about the Mercurial-devel mailing list