evolve: simplify locking in _solveconflicting() stable
authorPatrick Mezard <patrick@mezard.eu>
Sat, 25 Aug 2012 09:32:05 +0200
branchstable
changeset 516 18854dbc92e7
parent 515 0b60c28d9c43
child 517 0bc0c9edcb15
evolve: simplify locking in _solveconflicting()
hgext/evolve.py
--- a/hgext/evolve.py	Sat Aug 25 09:18:40 2012 +0200
+++ b/hgext/evolve.py	Sat Aug 25 09:32:05 2012 +0200
@@ -1554,48 +1554,46 @@
         ui.write('hg commit -m "`hg log -r %s --template={desc}`";\n' % conflicting)
         return
     #oldphase = max(conflicting.phase(), other.phase())
-    wlock = repo.wlock()
+    wlock = lock = None
     try:
+        wlock = repo.wlock()
         lock = repo.lock()
+        if conflicting not in repo[None].parents():
+            repo.ui.status(_('updating to "local" conflict\n'))
+            hg.update(repo, conflicting.rev())
+        repo.ui.note(_('merging conflicting changeset\n'))
+        stats = merge.update(repo,
+                             other.node(),
+                             branchmerge=True,
+                             force=False,
+                             partial=None,
+                             ancestor=base.node(),
+                             mergeancestor=True)
+        hg._showstats(repo, stats)
+        if stats[3]:
+            repo.ui.status(_("use 'hg resolve' to retry unresolved file merges "
+                             "or 'hg update -C .' to abandon\n"))
+        #repo.dirstate.write()
+        if stats[3] > 0:
+            raise util.Abort('GASP! Merge Conflict! You are on you own chap!',
+                             hint='/!\\ hg evolve --continue will NOT work /!\\')
+        tr = repo.transaction('stabilize-conflicting')
         try:
-            if conflicting not in repo[None].parents():
-                repo.ui.status(_('updating to "local" conflict\n'))
-                hg.update(repo, conflicting.rev())
-            repo.ui.note(_('merging conflicting changeset\n'))
-            stats = merge.update(repo,
-                                 other.node(),
-                                 branchmerge=True,
-                                 force=False,
-                                 partial=None,
-                                 ancestor=base.node(),
-                                 mergeancestor=True)
-            hg._showstats(repo, stats)
-            if stats[3]:
-                repo.ui.status(_("use 'hg resolve' to retry unresolved file merges "
-                                 "or 'hg update -C .' to abandon\n"))
-            #repo.dirstate.write()
-            if stats[3] > 0:
-                raise util.Abort('GASP! Merge Conflict! You are on you own chap!',
-                                 hint='/!\\ hg evolve --continue will NOT work /!\\')
-            tr = repo.transaction('stabilize-conflicting')
-            try:
-                repo.dirstate.setparents(conflicting.node(), node.nullid)
-                oldlen = len(repo)
-                amend(ui, repo)
-                if oldlen == len(repo):
-                    new = conflicting
-                    # no changes
-                else:
-                    new = repo['.']
-                createmarkers(repo, [(other, (new,))])
-                phases.retractboundary(repo, other.phase(), [new.node()])
-                tr.close()
-            finally:
-                tr.release()
+            repo.dirstate.setparents(conflicting.node(), node.nullid)
+            oldlen = len(repo)
+            amend(ui, repo)
+            if oldlen == len(repo):
+                new = conflicting
+                # no changes
+            else:
+                new = repo['.']
+            createmarkers(repo, [(other, (new,))])
+            phases.retractboundary(repo, other.phase(), [new.node()])
+            tr.close()
         finally:
-            lock.release()
+            tr.release()
     finally:
-        wlock.release()
+        lockmod.release(lock, wlock)
 
 
 def conflictingdata(ctx):