strip: use context manager for locking in strip()
authorMartin von Zweigbergk <martinvonz@google.com>
Mon, 19 Jun 2017 11:17:31 -0700
changeset 32937 daceeed34ad2
parent 32936 04c9dd951a41
child 32938 8dbcb66ac160
strip: use context manager for locking in strip()
hgext/strip.py
--- a/hgext/strip.py	Mon Jun 19 11:18:12 2017 -0700
+++ b/hgext/strip.py	Mon Jun 19 11:17:31 2017 -0700
@@ -59,10 +59,7 @@
     return s
 
 def strip(ui, repo, revs, update=True, backup=True, force=None, bookmarks=None):
-    wlock = lock = None
-    try:
-        wlock = repo.wlock()
-        lock = repo.lock()
+    with repo.wlock(), repo.lock():
 
         if update:
             checklocalchanges(repo, force=force)
@@ -86,9 +83,6 @@
                 repomarks.recordchange(tr)
             for bookmark in sorted(bookmarks):
                 ui.write(_("bookmark '%s' deleted\n") % bookmark)
-    finally:
-        release(lock, wlock)
-
 
 @command("strip",
          [