hgweb: add string constants for search mode names
authorAlexander Plavin <alexander@plav.in>
Wed, 04 Sep 2013 19:40:04 +0400
changeset 19656 60ce14e41faf
parent 19655 1d07bf106c2a
child 19657 145636d31bb4
hgweb: add string constants for search mode names It helps detecting mistakes in the mode names.
mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Wed Sep 04 18:42:55 2013 -0700
+++ b/mercurial/hgweb/webcommands.py	Wed Sep 04 19:40:04 2013 +0400
@@ -109,6 +109,8 @@
             raise inst
 
 def _search(web, req, tmpl):
+    MODE_REVISION = 'rev'
+    MODE_KEYWORD = 'keyword'
 
     def revsearch(ctx):
         yield ctx
@@ -142,17 +144,17 @@
             yield ctx
 
     searchfuncs = {
-        'rev': revsearch,
-        'keyword': keywordsearch,
+        MODE_REVISION: revsearch,
+        MODE_KEYWORD: keywordsearch,
     }
 
     def getsearchmode(query):
         try:
             ctx = web.repo[query]
         except (error.RepoError, error.LookupError):
-            return 'keyword', query
+            return MODE_KEYWORD, query
         else:
-            return 'rev', ctx
+            return MODE_REVISION, ctx
 
     def changelist(**map):
         count = 0