Show More
@@ -323,11 +323,8 b' def showfilecopies(context, mapping):' | |||||
323 | rename = getrenamed(fn, ctx.rev()) |
|
323 | rename = getrenamed(fn, ctx.rev()) | |
324 | if rename: |
|
324 | if rename: | |
325 | copies.append((fn, rename)) |
|
325 | copies.append((fn, rename)) | |
326 |
|
326 | return templateutil.compatfilecopiesdict(context, mapping, 'file_copy', | ||
327 | copies = util.sortdict(copies) |
|
327 | copies) | |
328 | return compatdict(context, mapping, 'file_copy', copies, |
|
|||
329 | key='name', value='source', fmt='%s (%s)', |
|
|||
330 | plural='file_copies') |
|
|||
331 |
|
328 | |||
332 | # showfilecopiesswitch() displays file copies only if copy records are |
|
329 | # showfilecopiesswitch() displays file copies only if copy records are | |
333 | # provided before calling the templater, usually with a --copies |
|
330 | # provided before calling the templater, usually with a --copies | |
@@ -338,10 +335,8 b' def showfilecopiesswitch(context, mappin' | |||||
338 | only if the --copied switch is set. |
|
335 | only if the --copied switch is set. | |
339 | """ |
|
336 | """ | |
340 | copies = context.resource(mapping, 'revcache').get('copies') or [] |
|
337 | copies = context.resource(mapping, 'revcache').get('copies') or [] | |
341 | copies = util.sortdict(copies) |
|
338 | return templateutil.compatfilecopiesdict(context, mapping, 'file_copy', | |
342 | return compatdict(context, mapping, 'file_copy', copies, |
|
339 | copies) | |
343 | key='name', value='source', fmt='%s (%s)', |
|
|||
344 | plural='file_copies') |
|
|||
345 |
|
340 | |||
346 | @templatekeyword('file_dels', requires={'ctx', 'revcache'}) |
|
341 | @templatekeyword('file_dels', requires={'ctx', 'revcache'}) | |
347 | def showfiledels(context, mapping): |
|
342 | def showfiledels(context, mapping): |
@@ -570,6 +570,21 b' def compatlist(context, mapping, name, d' | |||||
570 | f = _showcompatlist(context, mapping, name, data, plural, separator) |
|
570 | f = _showcompatlist(context, mapping, name, data, plural, separator) | |
571 | return hybridlist(data, name=element or name, fmt=fmt, gen=f) |
|
571 | return hybridlist(data, name=element or name, fmt=fmt, gen=f) | |
572 |
|
572 | |||
|
573 | def compatfilecopiesdict(context, mapping, name, copies): | |||
|
574 | """Wrap list of (dest, source) file names to support old-style list | |||
|
575 | template and field names | |||
|
576 | ||||
|
577 | This exists for backward compatibility. Use hybriddict for new template | |||
|
578 | keywords. | |||
|
579 | """ | |||
|
580 | # no need to provide {path} to old-style list template | |||
|
581 | c = [{'name': k, 'source': v} for k, v in copies] | |||
|
582 | f = _showcompatlist(context, mapping, name, c, plural='file_copies') | |||
|
583 | copies = util.sortdict(copies) | |||
|
584 | return hybrid(f, copies, | |||
|
585 | lambda k: {'name': k, 'path': k, 'source': copies[k]}, | |||
|
586 | lambda k: '%s (%s)' % (k, copies[k])) | |||
|
587 | ||||
573 | def compatfileslist(context, mapping, name, files): |
|
588 | def compatfileslist(context, mapping, name, files): | |
574 | """Wrap list of file names to support old-style list template and field |
|
589 | """Wrap list of file names to support old-style list template and field | |
575 | names |
|
590 | names |
@@ -769,6 +769,24 b' Test files list:' | |||||
769 | fourth |
|
769 | fourth | |
770 | third |
|
770 | third | |
771 |
|
771 | |||
|
772 | Test file copies dict: | |||
|
773 | ||||
|
774 | $ hg log -r8 -T '{join(file_copies, " ")}\n' | |||
|
775 | fourth (second) | |||
|
776 | $ hg log -r8 -T '{file_copies % "{name} <- {source}\n"}' | |||
|
777 | fourth <- second | |||
|
778 | $ hg log -r8 -T '{file_copies % "{path} <- {source}\n"}' | |||
|
779 | fourth <- second | |||
|
780 | ||||
|
781 | $ hg log -r8 -T '{join(file_copies_switch, " ")}\n' | |||
|
782 | ||||
|
783 | $ hg log -r8 -C -T '{join(file_copies_switch, " ")}\n' | |||
|
784 | fourth (second) | |||
|
785 | $ hg log -r8 -C -T '{file_copies_switch % "{name} <- {source}\n"}' | |||
|
786 | fourth <- second | |||
|
787 | $ hg log -r8 -C -T '{file_copies_switch % "{path} <- {source}\n"}' | |||
|
788 | fourth <- second | |||
|
789 | ||||
772 | Test index keyword: |
|
790 | Test index keyword: | |
773 |
|
791 | |||
774 | $ hg log -l 2 -T '{index + 10}{files % " {index}:{file}"}\n' |
|
792 | $ hg log -l 2 -T '{index + 10}{files % " {index}:{file}"}\n' |
General Comments 0
You need to be logged in to leave comments.
Login now