Show More
@@ -9,7 +9,27 b' from node import hex' | |||
|
9 | 9 | import patch, util, error |
|
10 | 10 | import hbisect |
|
11 | 11 | |
|
12 | def showlist(name, values, plural=None, **args): | |
|
12 | # This helper class allows us to handle both: | |
|
13 | # "{files}" (legacy command-line-specific list hack) and | |
|
14 | # "{files % '{file}\n'}" (hgweb-style with inlining and function support) | |
|
15 | ||
|
16 | class _hybrid(object): | |
|
17 | def __init__(self, gen, values): | |
|
18 | self.gen = gen | |
|
19 | self.values = values | |
|
20 | def __iter__(self): | |
|
21 | return self.gen | |
|
22 | def __call__(self): | |
|
23 | for x in self.values: | |
|
24 | yield x | |
|
25 | ||
|
26 | def showlist(name, values, plural=None, element=None, **args): | |
|
27 | if not element: | |
|
28 | element = name | |
|
29 | f = _showlist(name, values, plural, **args) | |
|
30 | return _hybrid(f, [{element: x} for x in values]) | |
|
31 | ||
|
32 | def _showlist(name, values, plural=None, **args): | |
|
13 | 33 | '''expand set of values. |
|
14 | 34 | name is name of key in template map. |
|
15 | 35 | values is list of strings or dicts. |
@@ -176,7 +196,7 b' def showchildren(**args):' | |||
|
176 | 196 | """:children: List of strings. The children of the changeset.""" |
|
177 | 197 | ctx = args['ctx'] |
|
178 | 198 | childrevs = ['%d:%s' % (cctx, cctx) for cctx in ctx.children()] |
|
179 | return showlist('children', childrevs, **args) | |
|
199 | return showlist('children', childrevs, element='child', **args) | |
|
180 | 200 | |
|
181 | 201 | def showdate(repo, ctx, templ, **args): |
|
182 | 202 | """:date: Date information. The date when the changeset was committed.""" |
@@ -204,7 +224,8 b' def showextras(**args):' | |||
|
204 | 224 | def showfileadds(**args): |
|
205 | 225 | """:file_adds: List of strings. Files added by this changeset.""" |
|
206 | 226 | repo, ctx, revcache = args['repo'], args['ctx'], args['revcache'] |
|
207 |
return showlist('file_add', getfiles(repo, ctx, revcache)[1], |
|
|
227 | return showlist('file_add', getfiles(repo, ctx, revcache)[1], | |
|
228 | element='file', **args) | |
|
208 | 229 | |
|
209 | 230 | def showfilecopies(**args): |
|
210 | 231 | """:file_copies: List of strings. Files copied in this changeset with |
@@ -223,7 +244,8 b' def showfilecopies(**args):' | |||
|
223 | 244 | copies.append((fn, rename[0])) |
|
224 | 245 | |
|
225 | 246 | c = [{'name': x[0], 'source': x[1]} for x in copies] |
|
226 |
return showlist('file_copy', c, plural='file_copies', |
|
|
247 | return showlist('file_copy', c, plural='file_copies', | |
|
248 | element='file', **args) | |
|
227 | 249 | |
|
228 | 250 | # showfilecopiesswitch() displays file copies only if copy records are |
|
229 | 251 | # provided before calling the templater, usually with a --copies |
@@ -234,17 +256,20 b' def showfilecopiesswitch(**args):' | |||
|
234 | 256 | """ |
|
235 | 257 | copies = args['revcache'].get('copies') or [] |
|
236 | 258 | c = [{'name': x[0], 'source': x[1]} for x in copies] |
|
237 |
return showlist('file_copy', c, plural='file_copies', |
|
|
259 | return showlist('file_copy', c, plural='file_copies', | |
|
260 | element='file', **args) | |
|
238 | 261 | |
|
239 | 262 | def showfiledels(**args): |
|
240 | 263 | """:file_dels: List of strings. Files removed by this changeset.""" |
|
241 | 264 | repo, ctx, revcache = args['repo'], args['ctx'], args['revcache'] |
|
242 |
return showlist('file_del', getfiles(repo, ctx, revcache)[2], |
|
|
265 | return showlist('file_del', getfiles(repo, ctx, revcache)[2], | |
|
266 | element='file', **args) | |
|
243 | 267 | |
|
244 | 268 | def showfilemods(**args): |
|
245 | 269 | """:file_mods: List of strings. Files modified by this changeset.""" |
|
246 | 270 | repo, ctx, revcache = args['repo'], args['ctx'], args['revcache'] |
|
247 |
return showlist('file_mod', getfiles(repo, ctx, revcache)[0], |
|
|
271 | return showlist('file_mod', getfiles(repo, ctx, revcache)[0], | |
|
272 | element='file', **args) | |
|
248 | 273 | |
|
249 | 274 | def showfiles(**args): |
|
250 | 275 | """:files: List of strings. All files modified, added, or removed by this |
General Comments 0
You need to be logged in to leave comments.
Login now