Mercurial > public > mercurial-scm > hg-stable
diff mercurial/templateutil.py @ 39395:5b1d406b39f1
templatekw: alias {name} of file copies dict to {path}
For the same reason as the previous patch. We might want some hack to
support {source.path}, {source.rev}, etc., but that's a different issue.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 05 Aug 2018 16:27:09 +0900 |
parents | 83f8f7b9fa60 |
children | 28f974d83c0a |
line wrap: on
line diff
--- a/mercurial/templateutil.py Sun Aug 05 16:14:18 2018 +0900 +++ b/mercurial/templateutil.py Sun Aug 05 16:27:09 2018 +0900 @@ -570,6 +570,21 @@ f = _showcompatlist(context, mapping, name, data, plural, separator) return hybridlist(data, name=element or name, fmt=fmt, gen=f) +def compatfilecopiesdict(context, mapping, name, copies): + """Wrap list of (dest, source) file names to support old-style list + template and field names + + This exists for backward compatibility. Use hybriddict for new template + keywords. + """ + # no need to provide {path} to old-style list template + c = [{'name': k, 'source': v} for k, v in copies] + f = _showcompatlist(context, mapping, name, c, plural='file_copies') + copies = util.sortdict(copies) + return hybrid(f, copies, + lambda k: {'name': k, 'path': k, 'source': copies[k]}, + lambda k: '%s (%s)' % (k, copies[k])) + def compatfileslist(context, mapping, name, files): """Wrap list of file names to support old-style list template and field names