statichttprepo: implement __enter__ and __exit__ on httprangeheader
httprangeheader behaves like a file object. Implement __enter__ and
__exit__ so it can be used as a context manager, just like file objects.
--- a/mercurial/statichttprepo.py Sat Jan 02 16:41:57 2016 -0800
+++ b/mercurial/statichttprepo.py Sat Jan 02 15:33:01 2016 -0800
@@ -35,6 +35,13 @@
self.pos = 0
self.opener = opener
self.name = url
+
+ def __enter__(self):
+ return self
+
+ def __exit__(self, exc_type, exc_value, traceback):
+ self.close()
+
def seek(self, pos):
self.pos = pos
def read(self, bytes=None):