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

Alexander Plavin alexander at plav.in
Fri Aug 16 15:00:45 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 f36e11723a01737156e3a79887a6b7ccc8fa6ed0
# Parent  7de4329371abefa30c9776084d54fd1cb9e0e6c3
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 7de4329371ab -r f36e11723a01 mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Fri Aug 16 15:35:44 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()
@@ -139,11 +142,17 @@
             yield ctx
 
     searchfuncs = {
+        'rev': revsearch,
         'kw': keywordsearch,
     }
 
     def getsearchmode():
-        return 'kw'
+        try:
+            web.repo[query]
+        except (error.RepoError, error.LookupError):
+            return 'kw'
+        else:
+            return 'rev'
 
     def changelist(**map):
         count = 0


More information about the Mercurial-devel mailing list