Patchwork D12090: arbitraryfilectx: use our existing helpers for reading and writing files

login
register
mail settings
Submitter phabricator
Date Jan. 26, 2022, 11:40 p.m.
Message ID <differential-rev-PHID-DREV-ijimtiyaeje6vdmpw4m5-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50416/
State New
Headers show

Comments

phabricator - Jan. 26, 2022, 11:40 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/context.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -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)