diff mercurial/httpconnection.py @ 30142:3dcaf1c4e90d

largefiles: use context for file closing Make the code slightly smaller and safer (and more deeply indented).
author Mads Kiilerich <madski@unity3d.com>
date Sat, 08 Oct 2016 00:59:41 +0200
parents d6b9468eebee
children 90e69badb125
line wrap: on
line diff
--- a/mercurial/httpconnection.py	Sat Oct 08 00:59:40 2016 +0200
+++ b/mercurial/httpconnection.py	Sat Oct 08 00:59:41 2016 +0200
@@ -58,6 +58,12 @@
                          unit=_('kb'), total=self._total)
         return ret
 
+    def __enter__(self):
+        return self
+
+    def __exit__(self, exc_type, exc_val, exc_tb):
+        self.close()
+
 # moved here from url.py to avoid a cycle
 def readauthforuri(ui, uri, user):
     # Read configuration