Show More
@@ -14,9 +14,10 b' import hbisect' | |||
|
14 | 14 | # "{files % '{file}\n'}" (hgweb-style with inlining and function support) |
|
15 | 15 | |
|
16 | 16 | class _hybrid(object): |
|
17 | def __init__(self, gen, values, joinfmt=None): | |
|
17 | def __init__(self, gen, values, makemap, joinfmt=None): | |
|
18 | 18 | self.gen = gen |
|
19 | 19 | self.values = values |
|
20 | self._makemap = makemap | |
|
20 | 21 | if joinfmt: |
|
21 | 22 | self.joinfmt = joinfmt |
|
22 | 23 | else: |
@@ -24,8 +25,9 b' class _hybrid(object):' | |||
|
24 | 25 | def __iter__(self): |
|
25 | 26 | return self.gen |
|
26 | 27 | def __call__(self): |
|
28 | makemap = self._makemap | |
|
27 | 29 | for x in self.values: |
|
28 | yield x | |
|
30 | yield makemap(x) | |
|
29 | 31 | def __len__(self): |
|
30 | 32 | return len(self.values) |
|
31 | 33 | |
@@ -33,7 +35,7 b' def showlist(name, values, plural=None, ' | |||
|
33 | 35 | if not element: |
|
34 | 36 | element = name |
|
35 | 37 | f = _showlist(name, values, plural, **args) |
|
36 |
return _hybrid(f, |
|
|
38 | return _hybrid(f, values, lambda x: {element: x}) | |
|
37 | 39 | |
|
38 | 40 | def _showlist(name, values, plural=None, **args): |
|
39 | 41 | '''expand set of values. |
@@ -201,9 +203,8 b' def showbookmarks(**args):' | |||
|
201 | 203 | bookmarks = args['ctx'].bookmarks() |
|
202 | 204 | current = repo._bookmarkcurrent |
|
203 | 205 | makemap = lambda v: {'bookmark': v, 'current': current} |
|
204 | c = [makemap(v) for v in bookmarks] | |
|
205 | 206 | f = _showlist('bookmark', bookmarks, **args) |
|
206 |
return _hybrid(f, |
|
|
207 | return _hybrid(f, bookmarks, makemap, lambda x: x['bookmark']) | |
|
207 | 208 | |
|
208 | 209 | def showchildren(**args): |
|
209 | 210 | """:children: List of strings. The children of the changeset.""" |
@@ -246,7 +247,8 b' def showextras(**args):' | |||
|
246 | 247 | makemap = lambda k: {'key': k, 'value': extras[k]} |
|
247 | 248 | c = [makemap(k) for k in extras] |
|
248 | 249 | f = _showlist('extra', c, plural='extras', **args) |
|
249 | return _hybrid(f, c, lambda x: '%s=%s' % (x['key'], x['value'])) | |
|
250 | return _hybrid(f, extras, makemap, | |
|
251 | lambda x: '%s=%s' % (x['key'], x['value'])) | |
|
250 | 252 | |
|
251 | 253 | def showfileadds(**args): |
|
252 | 254 | """:file_adds: List of strings. Files added by this changeset.""" |
@@ -274,7 +276,8 b' def showfilecopies(**args):' | |||
|
274 | 276 | makemap = lambda k: {'name': k, 'source': copies[k]} |
|
275 | 277 | c = [makemap(k) for k in copies] |
|
276 | 278 | f = _showlist('file_copy', c, plural='file_copies', **args) |
|
277 | return _hybrid(f, c, lambda x: '%s (%s)' % (x['name'], x['source'])) | |
|
279 | return _hybrid(f, copies, makemap, | |
|
280 | lambda x: '%s (%s)' % (x['name'], x['source'])) | |
|
278 | 281 | |
|
279 | 282 | # showfilecopiesswitch() displays file copies only if copy records are |
|
280 | 283 | # provided before calling the templater, usually with a --copies |
@@ -288,7 +291,8 b' def showfilecopiesswitch(**args):' | |||
|
288 | 291 | makemap = lambda k: {'name': k, 'source': copies[k]} |
|
289 | 292 | c = [makemap(k) for k in copies] |
|
290 | 293 | f = _showlist('file_copy', c, plural='file_copies', **args) |
|
291 | return _hybrid(f, c, lambda x: '%s (%s)' % (x['name'], x['source'])) | |
|
294 | return _hybrid(f, copies, makemap, | |
|
295 | lambda x: '%s (%s)' % (x['name'], x['source'])) | |
|
292 | 296 | |
|
293 | 297 | def showfiledels(**args): |
|
294 | 298 | """:file_dels: List of strings. Files removed by this changeset.""" |
General Comments 0
You need to be logged in to leave comments.
Login now