changeset 35452:488634db5928

lfs: fix committing deleted files caused by e0a1b9ee93cd e0a1b9ee93cd (lfs: add a repo requirement for this extension once an lfs file is committed) introduced a regression that prevents committing file deletion. This patch fixes that. Differential Revision: https://phab.mercurial-scm.org/D1717
author Jun Wu <quark@fb.com>
date Mon, 18 Dec 2017 14:37:00 -0800
parents d624c8558c61
children 44fd4cfc6c0a
files hgext/lfs/__init__.py tests/test-lfs.t
diffstat 2 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/lfs/__init__.py	Mon Dec 18 13:15:10 2017 -0500
+++ b/hgext/lfs/__init__.py	Mon Dec 18 14:37:00 2017 -0800
@@ -124,7 +124,7 @@
             if 'lfs' not in repo.requirements:
                 ctx = repo[kwargs['node']]
                 # TODO: is there a way to just walk the files in the commit?
-                if any(ctx[f].islfs() for f in ctx.files()):
+                if any(ctx[f].islfs() for f in ctx.files() if f in ctx):
                     repo.requirements.add('lfs')
                     repo._writerequirements()
 
--- a/tests/test-lfs.t	Mon Dec 18 13:15:10 2017 -0500
+++ b/tests/test-lfs.t	Mon Dec 18 14:37:00 2017 -0800
@@ -680,3 +680,12 @@
 
   $ hg -R convert_lfs2 config --debug extensions | grep lfs
   $TESTTMP/convert_lfs2/.hg/hgrc:*: extensions.lfs= (glob)
+
+Committing deleted files works:
+
+  $ hg init $TESTTMP/repo-del
+  $ cd $TESTTMP/repo-del
+  $ echo 1 > A
+  $ hg commit -m 'add A' -A A
+  $ hg rm A
+  $ hg commit -m 'rm A'