changeset 35999:8c7d5e90e6bd

lfs: teach '{lfs_files}' to handle removed files
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 27 Jan 2018 19:22:15 -0500
parents dce43aaaf209
children 91aac8e6604d
files hgext/lfs/__init__.py tests/test-lfs-largefiles.t tests/test-lfs.t
diffstat 3 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/lfs/__init__.py	Sat Jan 27 18:56:24 2018 -0500
+++ b/hgext/lfs/__init__.py	Sat Jan 27 19:22:15 2018 -0500
@@ -360,10 +360,11 @@
 
 @templatekeyword('lfs_files')
 def lfsfiles(repo, ctx, **args):
-    """List of strings. LFS files added or modified by the changeset."""
+    """List of strings. All files modified, added, or removed by this
+    changeset."""
     args = pycompat.byteskwargs(args)
 
-    pointers = wrapper.pointersfromctx(ctx) # {path: pointer}
+    pointers = wrapper.pointersfromctx(ctx, removed=True) # {path: pointer}
     files = sorted(pointers.keys())
 
     def pointer(v):
@@ -374,7 +375,7 @@
 
     makemap = lambda v: {
         'file': v,
-        'lfsoid': pointers[v].oid(),
+        'lfsoid': pointers[v].oid() if pointers[v] else None,
         'lfspointer': templatekw.hybriddict(pointer(v)),
     }
 
--- a/tests/test-lfs-largefiles.t	Sat Jan 27 18:56:24 2018 -0500
+++ b/tests/test-lfs-largefiles.t	Sat Jan 27 19:22:15 2018 -0500
@@ -298,7 +298,7 @@
   $TESTTMP/nolargefiles/.hg/hgrc:*: extensions.lfs= (glob)
 
   $ hg log -r 'all()' -G -T '{rev} {join(lfs_files, ", ")} ({desc})\n'
-  o  8  (remove large_by_size.bin)
+  o  8 large_by_size.bin (remove large_by_size.bin)
   |
   o  7 large_by_size.bin (large by size)
   |
--- a/tests/test-lfs.t	Sat Jan 27 18:56:24 2018 -0500
+++ b/tests/test-lfs.t	Sat Jan 27 19:22:15 2018 -0500
@@ -186,7 +186,7 @@
 
   $ hg log -r 'all()' -T '{rev} {join(lfs_files, ", ")}\n'
   0 large
-  1 l
+  1 l, large
   2 s
   3 s
   4 l
@@ -1032,6 +1032,16 @@
   $ hg rm lfs.test
   $ hg ci -qm 'remove lfs'
 
+{lfs_files} will list deleted files too
+
+  $ hg log -T "{lfs_files % '{rev} {file}: {lfspointer.oid}\n'}"
+  6 lfs.test: 
+  5 lfs.test: sha256:43f8f41171b6f62a6b61ba4ce98a8a6c1649240a47ebafd43120aa215ac9e7f6
+  3 lfs.catchall: sha256:31f43b9c62b540126b0ad5884dc013d21a61c9329b77de1fceeae2fc58511573
+  3 lfs.test: sha256:8acd23467967bc7b8cc5a280056589b0ba0b17ff21dbd88a7b6474d6290378a6
+  2 lfs.catchall: sha256:d4ec46c2869ba22eceb42a729377432052d9dd75d82fc40390ebaadecee87ee9
+  2 lfs.test: sha256:5489e6ced8c36a7b267292bde9fd5242a5f80a7482e8f23fa0477393dfaa4d6c
+
 TODO: This should notice the deleted lfs files in rev 6
   $ hg log -r 'file("set:lfs()")' -T '{rev} {join(lfs_files, ", ")}\n'
   2 lfs.catchall, lfs.test