mercurial/lock.py
changeset 27797 054abf2377e8
parent 26498 e8564e04382d
child 28027 14033c5dd261
--- a/mercurial/lock.py	Fri Jan 15 13:14:50 2016 -0800
+++ b/mercurial/lock.py	Fri Jan 15 13:14:45 2016 -0800
@@ -58,6 +58,12 @@
         if self.acquirefn:
             self.acquirefn()
 
+    def __enter__(self):
+        return self
+
+    def __exit__(self, exc_type, exc_value, exc_tb):
+        self.release()
+
     def __del__(self):
         if self.held:
             warnings.warn("use lock.release instead of del lock",