comparison mercurial/hgweb/webcommands.py @ 19633:217f2b9acee0

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.
author Alexander Plavin <alexander@plav.in>
date Fri, 19 Jul 2013 02:41:11 +0400
parents 299511aabf85
children 49a068b8fb0c
comparison
equal deleted inserted replaced
19632:299511aabf85 19633:217f2b9acee0
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 112
113 def revsearch(ctx):
114 yield ctx
115
113 def keywordsearch(query): 116 def keywordsearch(query):
114 lower = encoding.lower 117 lower = encoding.lower
115 qw = lower(query).split() 118 qw = lower(query).split()
116 119
117 def revgen(): 120 def revgen():
137 continue 140 continue
138 141
139 yield ctx 142 yield ctx
140 143
141 searchfuncs = { 144 searchfuncs = {
145 'rev': revsearch,
142 'keyword': keywordsearch, 146 'keyword': keywordsearch,
143 } 147 }
144 148
145 def getsearchmode(query): 149 def getsearchmode(query):
146 return 'keyword', query 150 try:
151 ctx = web.repo[query]
152 except (error.RepoError, error.LookupError):
153 return 'keyword', query
154 else:
155 return 'rev', ctx
147 156
148 def changelist(**map): 157 def changelist(**map):
149 count = 0 158 count = 0
150 159
151 for ctx in searchfunc(funcarg): 160 for ctx in searchfunc(funcarg):