changeset 50100:e8c170a6571d

dirstate: use `dirstate.change_files` to scope the change in `import` This is the way.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 14 Dec 2022 00:43:24 +0100
parents 5cfc48354d0f
children bbe3a65bbd96
files mercurial/patch.py
diffstat 1 files changed, 17 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/patch.py	Wed Dec 14 00:52:06 2022 +0100
+++ b/mercurial/patch.py	Wed Dec 14 00:43:24 2022 +0100
@@ -570,22 +570,23 @@
         self.changed.add(fname)
 
     def close(self):
-        wctx = self.repo[None]
-        changed = set(self.changed)
-        for src, dst in self.copied:
-            scmutil.dirstatecopy(self.ui, self.repo, wctx, src, dst)
-        if self.removed:
-            wctx.forget(sorted(self.removed))
-            for f in self.removed:
-                if f not in self.repo.dirstate:
-                    # File was deleted and no longer belongs to the
-                    # dirstate, it was probably marked added then
-                    # deleted, and should not be considered by
-                    # marktouched().
-                    changed.discard(f)
-        if changed:
-            scmutil.marktouched(self.repo, changed, self.similarity)
-        return sorted(self.changed)
+        with self.repo.dirstate.changing_files(self.repo):
+            wctx = self.repo[None]
+            changed = set(self.changed)
+            for src, dst in self.copied:
+                scmutil.dirstatecopy(self.ui, self.repo, wctx, src, dst)
+            if self.removed:
+                wctx.forget(sorted(self.removed))
+                for f in self.removed:
+                    if f not in self.repo.dirstate:
+                        # File was deleted and no longer belongs to the
+                        # dirstate, it was probably marked added then
+                        # deleted, and should not be considered by
+                        # marktouched().
+                        changed.discard(f)
+            if changed:
+                scmutil.marktouched(self.repo, changed, self.similarity)
+            return sorted(self.changed)
 
 
 class filestore: