Show More
@@ -78,6 +78,12 b' def unwraphybrid(thing):' | |||||
78 | return thing |
|
78 | return thing | |
79 | return thing.gen |
|
79 | return thing.gen | |
80 |
|
80 | |||
|
81 | def showdict(name, data, mapping, plural=None, key='key', value='value', | |||
|
82 | fmt='%s=%s', separator=' '): | |||
|
83 | c = [{key: k, value: v} for k, v in data.iteritems()] | |||
|
84 | f = _showlist(name, c, mapping, plural, separator) | |||
|
85 | return hybriddict(data, key=key, value=value, fmt=fmt, gen=f) | |||
|
86 | ||||
81 | def showlist(name, values, mapping, plural=None, element=None, separator=' '): |
|
87 | def showlist(name, values, mapping, plural=None, element=None, separator=' '): | |
82 | if not element: |
|
88 | if not element: | |
83 | element = name |
|
89 | element = name | |
@@ -348,14 +354,9 b' def showdiffstat(repo, ctx, templ, **arg' | |||||
348 | @templatekeyword('envvars') |
|
354 | @templatekeyword('envvars') | |
349 | def showenvvars(repo, **args): |
|
355 | def showenvvars(repo, **args): | |
350 | """A dictionary of environment variables. (EXPERIMENTAL)""" |
|
356 | """A dictionary of environment variables. (EXPERIMENTAL)""" | |
351 |
|
||||
352 | env = repo.ui.exportableenviron() |
|
357 | env = repo.ui.exportableenviron() | |
353 | env = util.sortdict((k, env[k]) for k in sorted(env)) |
|
358 | env = util.sortdict((k, env[k]) for k in sorted(env)) | |
354 | makemap = lambda k: {'key': k, 'value': env[k]} |
|
359 | return showdict('envvar', env, args, plural='envvars') | |
355 | c = [makemap(k) for k in env] |
|
|||
356 | f = _showlist('envvar', c, args, plural='envvars') |
|
|||
357 | return _hybrid(f, env, makemap, |
|
|||
358 | lambda x: '%s=%s' % (x['key'], x['value'])) |
|
|||
359 |
|
360 | |||
360 | @templatekeyword('extras') |
|
361 | @templatekeyword('extras') | |
361 | def showextras(**args): |
|
362 | def showextras(**args): | |
@@ -394,11 +395,8 b' def showfilecopies(**args):' | |||||
394 | copies.append((fn, rename[0])) |
|
395 | copies.append((fn, rename[0])) | |
395 |
|
396 | |||
396 | copies = util.sortdict(copies) |
|
397 | copies = util.sortdict(copies) | |
397 | makemap = lambda k: {'name': k, 'source': copies[k]} |
|
398 | return showdict('file_copy', copies, args, plural='file_copies', | |
398 | c = [makemap(k) for k in copies] |
|
399 | key='name', value='source', fmt='%s (%s)') | |
399 | f = _showlist('file_copy', c, args, plural='file_copies') |
|
|||
400 | return _hybrid(f, copies, makemap, |
|
|||
401 | lambda x: '%s (%s)' % (x['name'], x['source'])) |
|
|||
402 |
|
400 | |||
403 | # showfilecopiesswitch() displays file copies only if copy records are |
|
401 | # showfilecopiesswitch() displays file copies only if copy records are | |
404 | # provided before calling the templater, usually with a --copies |
|
402 | # provided before calling the templater, usually with a --copies | |
@@ -410,11 +408,8 b' def showfilecopiesswitch(**args):' | |||||
410 | """ |
|
408 | """ | |
411 | copies = args['revcache'].get('copies') or [] |
|
409 | copies = args['revcache'].get('copies') or [] | |
412 | copies = util.sortdict(copies) |
|
410 | copies = util.sortdict(copies) | |
413 | makemap = lambda k: {'name': k, 'source': copies[k]} |
|
411 | return showdict('file_copy', copies, args, plural='file_copies', | |
414 | c = [makemap(k) for k in copies] |
|
412 | key='name', value='source', fmt='%s (%s)') | |
415 | f = _showlist('file_copy', c, args, plural='file_copies') |
|
|||
416 | return _hybrid(f, copies, makemap, |
|
|||
417 | lambda x: '%s (%s)' % (x['name'], x['source'])) |
|
|||
418 |
|
413 | |||
419 | @templatekeyword('file_dels') |
|
414 | @templatekeyword('file_dels') | |
420 | def showfiledels(**args): |
|
415 | def showfiledels(**args): |
General Comments 0
You need to be logged in to leave comments.
Login now