fold: simplify locking stable
authorPatrick Mezard <patrick@mezard.eu>
Sat, 25 Aug 2012 09:18:40 +0200
branchstable
changeset 515 0b60c28d9c43
parent 514 ea667749ccd1
child 516 18854dbc92e7
fold: simplify locking
hgext/evolve.py
--- a/hgext/evolve.py	Sat Aug 25 09:20:15 2012 +0200
+++ b/hgext/evolve.py	Sat Aug 25 09:18:40 2012 +0200
@@ -2040,31 +2040,29 @@
     if len(heads) > 1:
         raise util.Abort("set have multiple heads")
     head = repo[heads[0]]
-    wlock = repo.wlock()
+    wlock = lock = None
     try:
+        wlock = repo.wlock()
         lock = repo.lock()
+        tr = repo.transaction('touch')
         try:
-            tr = repo.transaction('touch')
-            try:
-                allctx = [repo[r] for r in revs]
-                targetphase = max(c.phase() for c in allctx)
-                msg = '\n\n***\n\n'.join(c.description() for c in allctx)
-                newid, _ = rewrite(repo, root, allctx, head,
-                                 [root.p1().node(), root.p2().node()],
-                                 commitopts={'message': msg})
-                phases.retractboundary(repo, targetphase, [newid])
-                createmarkers(repo, [(ctx, (repo[newid],))
-                                               for ctx in allctx])
-                tr.close()
-            finally:
-                tr.release()
+            allctx = [repo[r] for r in revs]
+            targetphase = max(c.phase() for c in allctx)
+            msg = '\n\n***\n\n'.join(c.description() for c in allctx)
+            newid, _ = rewrite(repo, root, allctx, head,
+                             [root.p1().node(), root.p2().node()],
+                             commitopts={'message': msg})
+            phases.retractboundary(repo, targetphase, [newid])
+            createmarkers(repo, [(ctx, (repo[newid],))
+                                 for ctx in allctx])
+            tr.close()
         finally:
-            lock.release()
+            tr.release()
         ui.status('%i changesets folded\n' % len(revs))
         if repo.revs('. and %ld', revs):
             repo.dirstate.setparents(newid, node.nullid)
     finally:
-        wlock.release()
+        lockmod.release(lock, wlock)
 
 
 @eh.wrapcommand('graft')