# HG changeset patch # User Pierre-Yves David # Date 2023-02-22 02:35:18 # Node ID 092db64643212c63b4f18a50e3c324f672032034 # Parent b09a0afcb975601adfa2c997a1fad2883872df8b keyword: wrap dirstate mutation in `changing_files` context This is the way. diff --git a/hgext/eol.py b/hgext/eol.py --- a/hgext/eol.py +++ b/hgext/eol.py @@ -421,31 +421,31 @@ def reposetup(ui, repo): 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