Patchwork [1,of,3,V4] hgweb: add string constants for search mode names

login
register
mail settings
Submitter Alexander Plavin
Date Sept. 4, 2013, 7:12 p.m.
Message ID <06cc57487670cc3801de.1378321940@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2323/
State Accepted
Commit 60ce14e41fafadad64d4b4eecc683e8c14de0ad6
Delegated to: Kevin Bullock
Headers show

Comments

Alexander Plavin - Sept. 4, 2013, 7:12 p.m.
# HG changeset patch
# User Alexander Plavin <alexander@plav.in>
# Date 1378309204 -14400
#      Wed Sep 04 19:40:04 2013 +0400
# Node ID 06cc57487670cc3801de227fa179d61de3f1dd4a
# Parent  743ea1862ac66c37eb3f5de7e542b1fd2f26210e
hgweb: add string constants for search mode names

It helps detecting mistakes in the mode names.

Patch

diff -r 743ea1862ac6 -r 06cc57487670 mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Wed Jul 24 03:20:26 2013 +0400
+++ 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