[PATCH 2 of 3 V2] lfs: add the '{oid}' template keyword to '{lfs_files}'

Matt Harbison mharbison72 at gmail.com
Mon Jan 15 21:42:19 EST 2018


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1515963382 18000
#      Sun Jan 14 15:56:22 2018 -0500
# Node ID 4f66e5c58c21d6a743d1ea69398b7fa2b9ff6419
# Parent  9a5f40a1d18f0a28538b9a38fdee0874c58e680f
lfs: add the '{oid}' template keyword to '{lfs_files}'

The 'sha256:' prefix is skipped because this seems like the most convenient way
to consume it.  Maybe we should also add a '{oid_type}' keyword?  Then again,
that can be added in the future if a different algorithm is supported.

diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py
--- a/hgext/lfs/__init__.py
+++ b/hgext/lfs/__init__.py
@@ -230,6 +230,7 @@
 
     makemap = lambda v: {
         'file': v,
+        'oid': pointers[v].oid(),
     }
 
     # 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
@@ -859,10 +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
+  $ hg --cwd convert_lfs \
+  >     log -r 'all()' -T '{rev}: {lfs_files % "{file}: {oid}\n"}'
+  0: a1: 5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
+  1: a2: 5bb8341bee63b3649f222b2215bde37322bea075a30575aa685d8f8d21c77024
+  2: a2: 876dadc86a8542f9798048f2c47f51dbf8e4359aed883e8ec80c5db825f0d943
 
   $ grep 'lfs' convert_lfs/.hg/requires
   lfs


More information about the Mercurial-devel mailing list