with: use context manager in localrepo recover
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:50 -0800
changeset 27846 63821023ea79
parent 27845 7417e1c10253
child 27847 71853c0ba592
with: use context manager in localrepo recover
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Fri Jan 15 13:14:50 2016 -0800
+++ b/mercurial/localrepo.py	Fri Jan 15 13:14:50 2016 -0800
@@ -1126,8 +1126,7 @@
                            self.svfs.tryread("phaseroots"))
 
     def recover(self):
-        lock = self.lock()
-        try:
+        with self.lock():
             if self.svfs.exists("journal"):
                 self.ui.status(_("rolling back interrupted transaction\n"))
                 vfsmap = {'': self.svfs,
@@ -1139,8 +1138,6 @@
             else:
                 self.ui.warn(_("no interrupted transaction available\n"))
                 return False
-        finally:
-            lock.release()
 
     def rollback(self, dryrun=False, force=False):
         wlock = lock = dsguard = None