Patchwork [8,of,9,STABLE] rebase: use "dirstateguard" instead of "dirstate.invalidate"

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Oct. 1, 2014, 4:18 p.m.
Message ID <d8586da794d74d402b24.1412180315@feefifofum>
Download mbox | patch
Permalink /patch/6069/
State Changes Requested
Headers show

Comments

Katsunori FUJIWARA - Oct. 1, 2014, 4:18 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1412179386 -32400
#      Thu Oct 02 01:03:06 2014 +0900
# Branch stable
# Node ID d8586da794d74d402b24899fc5ea3db4a96bd425
# Parent  7f54cc7e716b76e9e05240d2d43a02f40599c090
rebase: use "dirstateguard" instead of "dirstate.invalidate"

Before this patch, "rebase.concludenode" uses "dirstate.invalidate()"
to restore dirstate to original status at failure. But it doesn't work
correctly, if "dirstate.write()" is executed while committing.

This patch uses "dirstateguard" instead of "dirstate.invalidate" to
restore dirstate easily and certainly, even if "dirstate.write()" is
executed.

This is the preparation for fixing the issue that recent (in memory)
dirstate isn't visible to external process (e.g. "precommit" hook).

BTW, "cmdutil.duplicatecopies()" invocation on the caller side of
"concludenode()" prevents "dirstateguard" from saving dirstate at the
construction time.

In the future, "duplicatecopies()" invocation should be moved into
"dirstateguard" scope in "concludenode()", and "dirstateguard" should
save dirstate at the construction time for readability.

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -466,6 +466,7 @@ 
 
 def concludenode(repo, rev, p1, p2, commitmsg=None, editor=None, extrafn=None):
     'Commit the changes and store useful information in extra'
+    dsguard = cmdutil.dirstateguard(repo, 'rebase')
     try:
         repo.setparents(repo[p1].node(), repo[p2].node())
         ctx = repo[rev]
@@ -483,11 +484,10 @@ 
         newnode = repo[newrev].node()
         if newnode:
             phases.retractboundary(repo, targetphase, [newnode])
+        dsguard.close()
         return newrev
-    except util.Abort:
-        # Invalidate the previous setparents
-        repo.dirstate.invalidate()
-        raise
+    finally:
+        release(dsguard)
 
 def rebasenode(repo, rev, p1, state, collapse):
     'Rebase a single revision'