# HG changeset patch # User Pierre-Yves David # Date 1670975004 -3600 # Node ID e8c170a6571d588384be066b840748673b04ea5b # Parent 5cfc48354d0f04ab57ad144425af634d46f385e2 dirstate: use `dirstate.change_files` to scope the change in `import` This is the way. diff -r 5cfc48354d0f -r e8c170a6571d mercurial/patch.py --- 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: