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