Commits

Patrick Mézard committed 0b60c28

fold: simplify locking

Comments (0)

Files changed (1)

     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')