with: use context manager for wlock in overridepurge
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:46 -0800
changeset 27825 4692571df9ee
parent 27824 0e55e93b50b5
child 27826 f087b7095381
with: use context manager for wlock in overridepurge
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
@@ -1223,8 +1223,7 @@
     orig(ui, repo, *dirs, **opts)
     repo.status = oldstatus
 def overriderollback(orig, ui, repo, **opts):
-    wlock = repo.wlock()
-    try:
+    with repo.wlock():
         before = repo.dirstate.parents()
         orphans = set(f for f in repo.dirstate
                       if lfutil.isstandin(f) and repo.dirstate[f] != 'r')
@@ -1258,8 +1257,6 @@
         for lfile in orphans:
             lfdirstate.drop(lfile)
         lfdirstate.write()
-    finally:
-        wlock.release()
     return result
 
 def overridetransplant(orig, ui, repo, *revs, **opts):