mercurial/templatekw.py
changeset 24237 9ad02823dc5b
parent 24157 d091f62be5ae
child 24238 49cee6d8573d
equal deleted inserted replaced
24236:de14c3972c2f 24237:9ad02823dc5b
   239 
   239 
   240 def showextras(**args):
   240 def showextras(**args):
   241     """:extras: List of dicts with key, value entries of the 'extras'
   241     """:extras: List of dicts with key, value entries of the 'extras'
   242     field of this changeset."""
   242     field of this changeset."""
   243     extras = args['ctx'].extra()
   243     extras = args['ctx'].extra()
   244     c = [{'key': x[0], 'value': x[1]} for x in sorted(extras.items())]
   244     extras = util.sortdict((k, extras[k]) for k in sorted(extras))
       
   245     c = [{'key': k, 'value': extras[k]} for k in extras]
   245     f = _showlist('extra', c, plural='extras', **args)
   246     f = _showlist('extra', c, plural='extras', **args)
   246     return _hybrid(f, c, lambda x: '%s=%s' % (x['key'], x['value']))
   247     return _hybrid(f, c, lambda x: '%s=%s' % (x['key'], x['value']))
   247 
   248 
   248 def showfileadds(**args):
   249 def showfileadds(**args):
   249     """:file_adds: List of strings. Files added by this changeset."""
   250     """:file_adds: List of strings. Files added by this changeset."""
   265         for fn in ctx.files():
   266         for fn in ctx.files():
   266             rename = getrenamed(fn, ctx.rev())
   267             rename = getrenamed(fn, ctx.rev())
   267             if rename:
   268             if rename:
   268                 copies.append((fn, rename[0]))
   269                 copies.append((fn, rename[0]))
   269 
   270 
   270     c = [{'name': x[0], 'source': x[1]} for x in copies]
   271     copies = util.sortdict(copies)
       
   272     c = [{'name': k, 'source': copies[k]} for k in copies]
   271     f = _showlist('file_copy', c, plural='file_copies', **args)
   273     f = _showlist('file_copy', c, plural='file_copies', **args)
   272     return _hybrid(f, c, lambda x: '%s (%s)' % (x['name'], x['source']))
   274     return _hybrid(f, c, lambda x: '%s (%s)' % (x['name'], x['source']))
   273 
   275 
   274 # showfilecopiesswitch() displays file copies only if copy records are
   276 # showfilecopiesswitch() displays file copies only if copy records are
   275 # provided before calling the templater, usually with a --copies
   277 # provided before calling the templater, usually with a --copies
   277 def showfilecopiesswitch(**args):
   279 def showfilecopiesswitch(**args):
   278     """:file_copies_switch: List of strings. Like "file_copies" but displayed
   280     """:file_copies_switch: List of strings. Like "file_copies" but displayed
   279     only if the --copied switch is set.
   281     only if the --copied switch is set.
   280     """
   282     """
   281     copies = args['revcache'].get('copies') or []
   283     copies = args['revcache'].get('copies') or []
   282     c = [{'name': x[0], 'source': x[1]} for x in copies]
   284     copies = util.sortdict(copies)
       
   285     c = [{'name': k, 'source': copies[k]} for k in copies]
   283     f = _showlist('file_copy', c, plural='file_copies', **args)
   286     f = _showlist('file_copy', c, plural='file_copies', **args)
   284     return _hybrid(f, c, lambda x: '%s (%s)' % (x['name'], x['source']))
   287     return _hybrid(f, c, lambda x: '%s (%s)' % (x['name'], x['source']))
   285 
   288 
   286 def showfiledels(**args):
   289 def showfiledels(**args):
   287     """:file_dels: List of strings. Files removed by this changeset."""
   290     """:file_dels: List of strings. Files removed by this changeset."""