Patchwork D8999: git: fix index handling of removed files during commit (issue6398)

login
register
mail settings
Submitter phabricator
Date Sept. 7, 2020, 9:31 p.m.
Message ID <differential-rev-PHID-DREV-ddvslkt2t6n5oidark5y-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47108/
State Superseded
Headers show

Comments

phabricator - Sept. 7, 2020, 9:31 p.m.
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Other changes in this series also changed the behavior here in
  positive ways, but this was the final step that actually fixed things.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/git/dirstate.py
  tests/test-git-interop.t

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-git-interop.t b/tests/test-git-interop.t
--- a/tests/test-git-interop.t
+++ b/tests/test-git-interop.t
@@ -270,3 +270,8 @@ 
   +++ b/beta	Mon Jan 01 00:00:11 2007 +0000
   @@ -0,0 +1,1 @@
   +beta
+
+
+Deleting files should also work (this was issue6398)
+  $ hg rm beta
+  $ hg ci -m 'remove beta'
diff --git a/hgext/git/dirstate.py b/hgext/git/dirstate.py
--- a/hgext/git/dirstate.py
+++ b/hgext/git/dirstate.py
@@ -301,8 +301,10 @@ 
     def drop(self, f):
         index = self.git.index
         index.read()
-        index.remove(pycompat.fsdecode(f))
-        index.write()
+        fs = pycompat.fsdecode(f)
+        if fs in index:
+            index.remove(fs)
+            index.write()
 
     def remove(self, f):
         index = self.git.index