changeset 36001:fa15a70f88de

changelog: implement context manager method for 'appender' object This object mimics a file and was missing the context manager API.
author Boris Feld <boris.feld@octobus.net>
date Mon, 05 Feb 2018 20:36:51 +0100
parents 0ff41ced4c12
children 69aaad59dc02
files mercurial/changelog.py
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/changelog.py	Sun Feb 04 00:29:22 2018 +0100
+++ b/mercurial/changelog.py	Mon Feb 05 20:36:51 2018 +0100
@@ -127,6 +127,13 @@
         self.offset += len(s)
         self._end += len(s)
 
+    def __enter__(self):
+        self.fp.__enter__()
+        return self
+
+    def __exit__(self, *args):
+        return self.fp.__exit__(*args)
+
 def _divertopener(opener, target):
     """build an opener that writes in 'target.a' instead of 'target'"""
     def _divert(name, mode='r', checkambig=False):