Patchwork [1,of,3] lfs: add the '{pointer}' template keyword to '{lfs_files}'

login
register
mail settings
Submitter Matt Harbison
Date Jan. 18, 2018, 3:08 a.m.
Message ID <5958f27453d90c24f443.1516244915@Envy>
Download mbox | patch
Permalink /patch/26834/
State Accepted
Headers show

Comments

Matt Harbison - Jan. 18, 2018, 3:08 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1515967224 18000
#      Sun Jan 14 17:00:24 2018 -0500
# Node ID 5958f27453d90c24f443d698439c2a8cd39e70c2
# Parent  a62b08f6626bd0f838b2c77a2f1a48068852be1f
lfs: add the '{pointer}' 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.
Yuya Nishihara - Jan. 18, 2018, 11:51 a.m.
On Wed, 17 Jan 2018 22:08:35 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1515967224 18000
> #      Sun Jan 14 17:00:24 2018 -0500
> # Node ID 5958f27453d90c24f443d698439c2a8cd39e70c2
> # Parent  a62b08f6626bd0f838b2c77a2f1a48068852be1f
> lfs: add the '{pointer}' 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.
> 
> diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py
> --- a/hgext/lfs/__init__.py
> +++ b/hgext/lfs/__init__.py
> @@ -314,6 +314,7 @@
>      makemap = lambda v: {
>          'file': v,
>          'oid': pointers[v].oid(),
> +        'pointer': pointers[v],

Better to wrap it by templatekw.hybriddict() because a dict of dicts isn't
a valid template structure.

Patch

diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py
--- a/hgext/lfs/__init__.py
+++ b/hgext/lfs/__init__.py
@@ -314,6 +314,7 @@ 
     makemap = lambda v: {
         'file': v,
         'oid': pointers[v].oid(),
+        'pointer': pointers[v],
     }
 
     # TODO: make the separator ', '?
diff --git a/tests/test-lfs.t b/tests/test-lfs.t
--- a/tests/test-lfs.t
+++ b/tests/test-lfs.t
@@ -865,6 +865,8 @@ 
   oid sha256:5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
   size 29
   x-is-binary 0
+  $ hg --cwd convert_lfs log -r 0 -T '{lfs_files % "{pointer.oid}\n"}'
+  sha256:5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
   $ hg --cwd convert_lfs \
   >     log -r 'all()' -T '{rev}: {lfs_files % "{file}: {oid}\n"}'
   0: a1: 5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024