changeset 28476:bf3bf7158f69

with: use context manager for wlock in addlargefiles
author Bryan O'Sullivan <bryano@fb.com>
date Fri, 15 Jan 2016 13:14:46 -0800
parents d2e9cc9edc08
children bce0afa1921a
files hgext/largefiles/overrides.py
diffstat 1 files changed, 1 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -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):