Patrick Mézard avatar Patrick Mézard committed 18854db

evolve: simplify locking in _solveconflicting()

Comments (0)

Files changed (1)

         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):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.