arbitraryfilectx: use our existing helpers for reading and writing files
authorMartin von Zweigbergk <martinvonz@google.com>
Wed, 26 Jan 2022 15:32:18 -0800
changeset 48673 576040155dba
parent 48672 657e490756e6
child 48681 e845537f6adb
arbitraryfilectx: use our existing helpers for reading and writing files Differential Revision: https://phab.mercurial-scm.org/D12090
mercurial/context.py
--- a/mercurial/context.py	Thu Feb 11 22:52:43 2021 -0800
+++ b/mercurial/context.py	Wed Jan 26 15:32:18 2022 -0800
@@ -20,7 +20,6 @@
 )
 from .pycompat import (
     getattr,
-    open,
 )
 from . import (
     dagop,
@@ -3129,13 +3128,11 @@
         return util.readfile(self._path)
 
     def decodeddata(self):
-        with open(self._path, b"rb") as f:
-            return f.read()
+        return util.readfile(self._path)
 
     def remove(self):
         util.unlink(self._path)
 
     def write(self, data, flags, **kwargs):
         assert not flags
-        with open(self._path, b"wb") as f:
-            f.write(data)
+        util.writefile(self._path, data)