[Updated] D12122: dirstate: use a context manager when writing the dirstate

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Thu Feb 3 16:51:35 UTC 2022


Closed by commit rHGcdb0d857afe2: dirstate: use a context manager when writing the dirstate (authored by marmoute).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D12122?vs=32018&id=32040

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D12122/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D12122

AFFECTED FILES
  mercurial/dirstate.py

CHANGE DETAILS

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -713,8 +713,9 @@
             )
             return
 
-        st = self._opener(filename, b"w", atomictemp=True, checkambig=True)
-        self._writedirstate(tr, st)
+        file = lambda f: self._opener(f, b"w", atomictemp=True, checkambig=True)
+        with file(self._filename) as f:
+            self._writedirstate(tr, f)
 
     def addparentchangecallback(self, category, callback):
         """add a callback to be called when the wd parents are changed



To: marmoute, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20220203/0e62c993/attachment-0002.html>


More information about the Mercurial-patches mailing list