changeset 32937:daceeed34ad2

strip: use context manager for locking in strip()
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 19 Jun 2017 11:17:31 -0700
parents 04c9dd951a41
children 8dbcb66ac160
files hgext/strip.py
diffstat 1 files changed, 1 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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",
          [