Mercurial > hg
diff hgext/lfs/__init__.py @ 35731:f58245b9e3ea
lfs: add the '{lfsattrs}' template keyword to '{lfs_files}'
This provides access to the metadata dictionary contained within the tracked
pointer file. The OID is probably the most important attribute, and has its own
keyword. But we might as well have this for completeness.
I liked {pointer} better, but couldn't make it work with the singular/plural
forms.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 14 Jan 2018 17:00:24 -0500 |
parents | 1ad1e59b405e |
children | 10e62d5efa73 |
line wrap: on
line diff
--- a/hgext/lfs/__init__.py Thu Jan 18 16:47:14 2018 +0100 +++ b/hgext/lfs/__init__.py Sun Jan 14 17:00:24 2018 -0500 @@ -97,6 +97,7 @@ scmutil, templatekw, upgrade, + util, vfs as vfsmod, wireproto, ) @@ -311,9 +312,16 @@ pointers = wrapper.pointersfromctx(ctx) # {path: pointer} files = sorted(pointers.keys()) + def lfsattrs(v): + # In the file spec, version is first and the other keys are sorted. + sortkeyfunc = lambda x: (x[0] != 'version', x) + items = sorted(pointers[v].iteritems(), key=sortkeyfunc) + return util.sortdict(items) + makemap = lambda v: { 'file': v, 'oid': pointers[v].oid(), + 'lfsattrs': templatekw.hybriddict(lfsattrs(v)), } # TODO: make the separator ', '?