Patchwork [6,of,9,STABLE] mq: use "dirstateguard" instead of "dirstate.invalidate" (qrefresh)

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Oct. 1, 2014, 4:18 p.m.
Message ID <447660e4e8dcb57daaaa.1412180313@feefifofum>
Download mbox | patch
Permalink /patch/6065/
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 447660e4e8dcb57daaaae380cccce87d4116abeb
# Parent  10fcdb8b9280c28048bcd9f6b298705a0b428b53
mq: use "dirstateguard" instead of "dirstate.invalidate" (qrefresh)

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

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

Patch

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -1494,6 +1494,8 @@ 
         wlock = repo.wlock()
 
         try:
+            dsguard = cmdutil.dirstateguard(repo, 'mq.refresh')
+
             self.checktoppatch(repo)
             (top, patchfn) = (self.applied[-1].node, self.applied[-1].name)
             if repo.changelog.heads(top) != [top]:
@@ -1648,9 +1650,12 @@ 
                 self.applied.pop()
                 self.applieddirty = True
                 strip(self.ui, repo, [top], update=False, backup='strip')
-            except: # re-raises
-                repo.dirstate.invalidate()
-                raise
+            finally:
+                # TODO: get rid of this meaningless try/finally enclosing.
+                # this is kept only to reduce changes in a patch
+                pass
+
+            dsguard.close()
 
             try:
                 # might be nice to attempt to roll back strip after this
@@ -1708,7 +1713,7 @@ 
                                '(revert --all, qpush to recover)\n'))
                 raise
         finally:
-            wlock.release()
+            release(dsguard, wlock)
             self.removeundo(repo)
 
     def init(self, repo, create=False):