changeset 45420:c67529569643

git: fix up dirstate use of index This was super-broken before, and somehow none of the existing attempts to use this code tripped on the defects here. Sigh. Differential Revision: https://phab.mercurial-scm.org/D8996
author Augie Fackler <raf@durin42.com>
date Mon, 07 Sep 2020 17:12:29 -0400
parents 6739ef7c5fcf
children 0c6b2cc9a7bb
files hgext/git/dirstate.py
diffstat 1 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/git/dirstate.py	Mon Sep 07 16:27:12 2020 -0400
+++ b/hgext/git/dirstate.py	Mon Sep 07 17:12:29 2020 -0400
@@ -276,13 +276,22 @@
         pass
 
     def add(self, f):
-        self.git.index.add(pycompat.fsdecode(f))
+        index = self.git.index
+        index.read()
+        index.add(pycompat.fsdecode(f))
+        index.write()
 
     def drop(self, f):
-        self.git.index.remove(pycompat.fsdecode(f))
+        index = self.git.index
+        index.read()
+        index.remove(pycompat.fsdecode(f))
+        index.write()
 
     def remove(self, f):
-        self.git.index.remove(pycompat.fsdecode(f))
+        index = self.git.index
+        index.read()
+        index.remove(pycompat.fsdecode(f))
+        index.write()
 
     def copied(self, path):
         # TODO: track copies?