Mercurial > hg
comparison mercurial/hgweb/webcommands.py @ 19632:299511aabf85
hgweb: pass arguments which a function depends on explicitly in search
This changes makes clearer which arguments can a function depend on. Now all
the modified functions depend on the 'query' argument only, but future additions
will change it.
author | Alexander Plavin <alexander@plav.in> |
---|---|
date | Thu, 22 Aug 2013 16:42:10 +0400 |
parents | cf9e5e45c1d3 |
children | 217f2b9acee0 |
comparison
equal
deleted
inserted
replaced
19631:cf9e5e45c1d3 | 19632:299511aabf85 |
---|---|
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 keywordsearch(): | 113 def keywordsearch(query): |
114 lower = encoding.lower | 114 lower = encoding.lower |
115 qw = lower(query).split() | 115 qw = lower(query).split() |
116 | 116 |
117 def revgen(): | 117 def revgen(): |
118 cl = web.repo.changelog | 118 cl = web.repo.changelog |
140 | 140 |
141 searchfuncs = { | 141 searchfuncs = { |
142 'keyword': keywordsearch, | 142 'keyword': keywordsearch, |
143 } | 143 } |
144 | 144 |
145 def getsearchmode(): | 145 def getsearchmode(query): |
146 return 'keyword' | 146 return 'keyword', query |
147 | 147 |
148 def changelist(**map): | 148 def changelist(**map): |
149 count = 0 | 149 count = 0 |
150 | 150 |
151 for ctx in searchfunc(): | 151 for ctx in searchfunc(funcarg): |
152 count += 1 | 152 count += 1 |
153 n = ctx.node() | 153 n = ctx.node() |
154 showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n) | 154 showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n) |
155 files = webutil.listfilediffs(tmpl, ctx.files(), n, web.maxfiles) | 155 files = webutil.listfilediffs(tmpl, ctx.files(), n, web.maxfiles) |
156 | 156 |
186 lessvars['rev'] = query | 186 lessvars['rev'] = query |
187 morevars = copy.copy(tmpl.defaults['sessionvars']) | 187 morevars = copy.copy(tmpl.defaults['sessionvars']) |
188 morevars['revcount'] = revcount * 2 | 188 morevars['revcount'] = revcount * 2 |
189 morevars['rev'] = query | 189 morevars['rev'] = query |
190 | 190 |
191 mode = getsearchmode() | 191 mode, funcarg = getsearchmode(query) |
192 searchfunc = searchfuncs[mode] | 192 searchfunc = searchfuncs[mode] |
193 | 193 |
194 tip = web.repo['tip'] | 194 tip = web.repo['tip'] |
195 parity = paritygen(web.stripecount) | 195 parity = paritygen(web.stripecount) |
196 | 196 |