Mercurial > hg
comparison mercurial/hgweb/webcommands.py @ 19631:cf9e5e45c1d3
hgweb: add dynamic search function selection, depending on the query
This allows adding other specific search functions, in addition to current
keyword search.
author | Alexander Plavin <alexander@plav.in> |
---|---|
date | Thu, 22 Aug 2013 16:45:23 +0400 |
parents | 983bb4069004 |
children | 299511aabf85 |
comparison
equal
deleted
inserted
replaced
19630:bb67f630b335 | 19631:cf9e5e45c1d3 |
---|---|
136 if miss: | 136 if miss: |
137 continue | 137 continue |
138 | 138 |
139 yield ctx | 139 yield ctx |
140 | 140 |
141 searchfuncs = { | |
142 'keyword': keywordsearch, | |
143 } | |
144 | |
145 def getsearchmode(): | |
146 return 'keyword' | |
147 | |
141 def changelist(**map): | 148 def changelist(**map): |
142 count = 0 | 149 count = 0 |
143 | 150 |
144 for ctx in keywordsearch(): | 151 for ctx in searchfunc(): |
145 count += 1 | 152 count += 1 |
146 n = ctx.node() | 153 n = ctx.node() |
147 showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n) | 154 showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n) |
148 files = webutil.listfilediffs(tmpl, ctx.files(), n, web.maxfiles) | 155 files = webutil.listfilediffs(tmpl, ctx.files(), n, web.maxfiles) |
149 | 156 |
178 lessvars['revcount'] = max(revcount / 2, 1) | 185 lessvars['revcount'] = max(revcount / 2, 1) |
179 lessvars['rev'] = query | 186 lessvars['rev'] = query |
180 morevars = copy.copy(tmpl.defaults['sessionvars']) | 187 morevars = copy.copy(tmpl.defaults['sessionvars']) |
181 morevars['revcount'] = revcount * 2 | 188 morevars['revcount'] = revcount * 2 |
182 morevars['rev'] = query | 189 morevars['rev'] = query |
190 | |
191 mode = getsearchmode() | |
192 searchfunc = searchfuncs[mode] | |
183 | 193 |
184 tip = web.repo['tip'] | 194 tip = web.repo['tip'] |
185 parity = paritygen(web.stripecount) | 195 parity = paritygen(web.stripecount) |
186 | 196 |
187 return tmpl('search', query=query, node=tip.hex(), | 197 return tmpl('search', query=query, node=tip.hex(), |