changeset 31891:87f293edabb6

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.
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 11 Apr 2017 21:38:11 -0400
parents ca7af5d15b21
children 9e67ce5c4fd0
files mercurial/windows.py
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/windows.py	Tue Apr 11 18:31:40 2017 -0700
+++ b/mercurial/windows.py	Tue Apr 11 21:38:11 2017 -0400
@@ -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)