with: use context manager for wlock in addlargefiles
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:46 -0800
changeset 27821 bf3bf7158f69
parent 27820 d2e9cc9edc08
child 27822 bce0afa1921a
with: use context manager for wlock in addlargefiles
hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py	Fri Jan 15 13:14:46 2016 -0800
+++ b/hgext/largefiles/overrides.py	Fri Jan 15 13:14:46 2016 -0800
@@ -141,8 +141,7 @@
 
     # Need to lock, otherwise there could be a race condition between
     # when standins are created and added to the repo.
-    wlock = repo.wlock()
-    try:
+    with repo.wlock():
         if not opts.get('dry_run'):
             standins = []
             lfdirstate = lfutil.openlfdirstate(ui, repo)
@@ -161,8 +160,6 @@
                     if f in m.files()]
 
         added = [f for f in lfnames if f not in bad]
-    finally:
-        wlock.release()
     return added, bad
 
 def removelargefiles(ui, repo, isaddremove, matcher, **opts):