# HG changeset patch # User Martin von Zweigbergk # Date 2022-01-26 23:32:18 # Node ID 576040155dba8a7e228169c1af59dc1d3fd349b5 # Parent 657e490756e62f8c61623b55a3a4b5963e110db2 arbitraryfilectx: use our existing helpers for reading and writing files Differential Revision: https://phab.mercurial-scm.org/D12090 diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -20,7 +20,6 @@ from .node import ( ) from .pycompat import ( getattr, - open, ) from . import ( dagop, @@ -3129,13 +3128,11 @@ class arbitraryfilectx(object): 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)