changeset 27846:63821023ea79

with: use context manager in localrepo recover
author Bryan O'Sullivan <bryano@fb.com>
date Fri, 15 Jan 2016 13:14:50 -0800
parents 7417e1c10253
children 71853c0ba592
files mercurial/localrepo.py
diffstat 1 files changed, 1 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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