hgweb: add string constants for search mode names
It helps detecting mistakes in the mode names.
--- 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