changeset 50200:092db6464321

keyword: wrap dirstate mutation in `changing_files` context This is the way.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 22 Feb 2023 03:35:18 +0100
parents b09a0afcb975
children e9379b55ed80
files hgext/eol.py
diffstat 1 files changed, 24 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/eol.py	Wed Feb 22 03:34:48 2023 +0100
+++ b/hgext/eol.py	Wed Feb 22 03:35:18 2023 +0100
@@ -421,31 +421,31 @@
                 wlock = None
                 try:
                     wlock = self.wlock()
-                    for f in self.dirstate:
-                        if not self.dirstate.get_entry(f).maybe_clean:
-                            continue
-                        if oldeol is not None:
-                            if not oldeol.match(f) and not neweol.match(f):
+                    with self.dirstate.changing_files(self):
+                        for f in self.dirstate:
+                            if not self.dirstate.get_entry(f).maybe_clean:
                                 continue
-                            oldkey = None
-                            for pattern, key, m in oldeol.patterns:
-                                if m(f):
-                                    oldkey = key
-                                    break
-                            newkey = None
-                            for pattern, key, m in neweol.patterns:
-                                if m(f):
-                                    newkey = key
-                                    break
-                            if oldkey == newkey:
-                                continue
-                        # all normal files need to be looked at again since
-                        # the new .hgeol file specify a different filter
-                        self.dirstate.set_possibly_dirty(f)
-                    # Write the cache to update mtime and cache .hgeol
-                    with self.vfs(b"eol.cache", b"w") as f:
-                        f.write(hgeoldata)
-                    self.dirstate.write(self.currenttransaction())
+                            if oldeol is not None:
+                                if not oldeol.match(f) and not neweol.match(f):
+                                    continue
+                                oldkey = None
+                                for pattern, key, m in oldeol.patterns:
+                                    if m(f):
+                                        oldkey = key
+                                        break
+                                newkey = None
+                                for pattern, key, m in neweol.patterns:
+                                    if m(f):
+                                        newkey = key
+                                        break
+                                if oldkey == newkey:
+                                    continue
+                            # all normal files need to be looked at again since
+                            # the new .hgeol file specify a different filter
+                            self.dirstate.set_possibly_dirty(f)
+                        # Write the cache to update mtime and cache .hgeol
+                        with self.vfs(b"eol.cache", b"w") as f:
+                            f.write(hgeoldata)
                 except errormod.LockUnavailable:
                     # If we cannot lock the repository and clear the
                     # dirstate, then a commit might not see all files