Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/webcommands.py @ 19656:60ce14e41faf
hgweb: add string constants for search mode names
It helps detecting mistakes in the mode names.
author | Alexander Plavin <alexander@plav.in> |
---|---|
date | Wed, 04 Sep 2013 19:40:04 +0400 |
parents | 49a068b8fb0c |
children | 145636d31bb4 |
comparison
equal
deleted
inserted
replaced
19655:1d07bf106c2a | 19656:60ce14e41faf |
---|---|
107 return manifest(web, req, tmpl) | 107 return manifest(web, req, tmpl) |
108 except ErrorResponse: | 108 except ErrorResponse: |
109 raise inst | 109 raise inst |
110 | 110 |
111 def _search(web, req, tmpl): | 111 def _search(web, req, tmpl): |
112 MODE_REVISION = 'rev' | |
113 MODE_KEYWORD = 'keyword' | |
112 | 114 |
113 def revsearch(ctx): | 115 def revsearch(ctx): |
114 yield ctx | 116 yield ctx |
115 | 117 |
116 def keywordsearch(query): | 118 def keywordsearch(query): |
140 continue | 142 continue |
141 | 143 |
142 yield ctx | 144 yield ctx |
143 | 145 |
144 searchfuncs = { | 146 searchfuncs = { |
145 'rev': revsearch, | 147 MODE_REVISION: revsearch, |
146 'keyword': keywordsearch, | 148 MODE_KEYWORD: keywordsearch, |
147 } | 149 } |
148 | 150 |
149 def getsearchmode(query): | 151 def getsearchmode(query): |
150 try: | 152 try: |
151 ctx = web.repo[query] | 153 ctx = web.repo[query] |
152 except (error.RepoError, error.LookupError): | 154 except (error.RepoError, error.LookupError): |
153 return 'keyword', query | 155 return MODE_KEYWORD, query |
154 else: | 156 else: |
155 return 'rev', ctx | 157 return MODE_REVISION, ctx |
156 | 158 |
157 def changelist(**map): | 159 def changelist(**map): |
158 count = 0 | 160 count = 0 |
159 | 161 |
160 for ctx in searchfunc(funcarg): | 162 for ctx in searchfunc(funcarg): |