Patchwork [1,of,3,V2] lfs: convert '{lfs_files}' keyword to a hybrid list

login
register
mail settings
Submitter Matt Harbison
Date Jan. 16, 2018, 2:42 a.m.
Message ID <9a5f40a1d18f0a28538b.1516070538@Envy>
Download mbox | patch
Permalink /patch/26778/
State Accepted
Headers show

Comments

Matt Harbison - Jan. 16, 2018, 2:42 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1515962350 18000
#      Sun Jan 14 15:39:10 2018 -0500
# Node ID 9a5f40a1d18f0a28538b9a38fdee0874c58e680f
# Parent  48fe4f56a3b4138813ba912b012498ce349c4c24
lfs: convert '{lfs_files}' keyword to a hybrid list

This will allow more attributes about the file to be queried.
Yuya Nishihara - Jan. 16, 2018, 2:01 p.m.
On Mon, 15 Jan 2018 21:42:18 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1515962350 18000
> #      Sun Jan 14 15:39:10 2018 -0500
> # Node ID 9a5f40a1d18f0a28538b9a38fdee0874c58e680f
> # Parent  48fe4f56a3b4138813ba912b012498ce349c4c24
> lfs: convert '{lfs_files}' keyword to a hybrid list

Queued the first two, thanks.

Patch

diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py
--- a/hgext/lfs/__init__.py
+++ b/hgext/lfs/__init__.py
@@ -61,9 +61,11 @@ 
     localrepo,
     minifileset,
     node,
+    pycompat,
     registrar,
     revlog,
     scmutil,
+    templatekw,
     upgrade,
     vfs as vfsmod,
     wireproto,
@@ -221,8 +223,18 @@ 
 @templatekeyword('lfs_files')
 def lfsfiles(repo, ctx, **args):
     """List of strings. LFS files added or modified by the changeset."""
+    args = pycompat.byteskwargs(args)
+
     pointers = wrapper.pointersfromctx(ctx) # {path: pointer}
-    return sorted(pointers.keys())
+    files = sorted(pointers.keys())
+
+    makemap = lambda v: {
+        'file': v,
+    }
+
+    # TODO: make the separator ', '?
+    f = templatekw._showlist('lfs_file', files, args)
+    return templatekw._hybrid(f, files, makemap, pycompat.identity)
 
 @command('debuglfsupload',
          [('r', 'rev', [], _('upload large files introduced by REV'))])
diff --git a/tests/test-lfs.t b/tests/test-lfs.t
--- a/tests/test-lfs.t
+++ b/tests/test-lfs.t
@@ -859,6 +859,11 @@ 
   oid sha256:5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
   size 29
   x-is-binary 0
+  $ hg --cwd convert_lfs log -r 'all()' -T '{rev}: {lfs_files % "{file}\n"}'
+  0: a1
+  1: a2
+  2: a2
+
   $ grep 'lfs' convert_lfs/.hg/requires
   lfs