changeset 516:18854dbc92e7 stable

evolve: simplify locking in _solveconflicting()
author Patrick Mezard <patrick@mezard.eu>
date Sat, 25 Aug 2012 09:32:05 +0200
parents 0b60c28d9c43
children 0bc0c9edcb15
files hgext/evolve.py
diffstat 1 files changed, 35 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- 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):