Patchwork D1717: lfs: fix committing deleted files caused by e0a1b9ee93cd

login
register
mail settings
Submitter phabricator
Date Dec. 18, 2017, 10:48 p.m.
Message ID <differential-rev-PHID-DREV-b7bqgfna4bupkxm7zllh-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26339/
State Superseded
Headers show

Comments

phabricator - Dec. 18, 2017, 10:48 p.m.
quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  https://phab.mercurial-scm.org/rHGe0a1b9ee93cdfb40ba43e8838a1edf4ea3ea24f3 (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.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1717

AFFECTED FILES
  hgext/lfs/__init__.py
  tests/test-lfs.t

CHANGE DETAILS




To: quark, #hg-reviewers
Cc: mercurial-devel
phabricator - Dec. 19, 2017, 1:08 a.m.
mharbison72 added a comment.


  LGTM.  Sorry about that.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1717

To: quark, #hg-reviewers, mharbison72
Cc: mercurial-devel
phabricator - Dec. 19, 2017, 3:52 a.m.
krbullock accepted this revision.
krbullock added a comment.
This revision is now accepted and ready to land.


  Queued per Matt's review, thanks.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1717

To: quark, #hg-reviewers, mharbison72, krbullock
Cc: krbullock, mercurial-devel

Patch

diff --git a/tests/test-lfs.t b/tests/test-lfs.t
--- a/tests/test-lfs.t
+++ b/tests/test-lfs.t
@@ -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'
diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py
--- a/hgext/lfs/__init__.py
+++ b/hgext/lfs/__init__.py
@@ -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()