From patchwork Wed Apr 12 02:42:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1, of, 2] windows: add context manager support to mixedfilemodewrapper From: Matt Harbison X-Patchwork-Id: 20125 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Tue, 11 Apr 2017 22:42:42 -0400 # HG changeset patch # User Matt Harbison # Date 1491961091 14400 # Tue Apr 11 21:38:11 2017 -0400 # Node ID ef3aa25da8e5b3137b917e9a1756df7a7eac5c3a # Parent 7b6f5632f09d85b96b2f986961576eb165d44cbf windows: add context manager support to mixedfilemodewrapper I stumbled into this in the next patch. The difference between getting a context manager capable object or not from vfs classes was as subtle as adding a '+' to the file mode. diff --git a/mercurial/windows.py b/mercurial/windows.py --- a/mercurial/windows.py +++ b/mercurial/windows.py @@ -64,6 +64,12 @@ object.__setattr__(self, r'_fp', fp) object.__setattr__(self, r'_lastop', 0) + def __enter__(self): + return self._fp.__enter__() + + def __exit__(self, exc_type, exc_val, exc_tb): + self._fp.__exit__(exc_type, exc_val, exc_tb) + def __getattr__(self, name): return getattr(self._fp, name)