[PATCH 7 of 9 V3] mq: use dirstateguard instead of dirstate.invalidate (qrefresh)
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Wed May 6 22:15:54 CDT 2015
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1430968031 -32400
# Thu May 07 12:07:11 2015 +0900
# Node ID 2f29e941bba8f976558beff7108bc47323b91c30
# Parent db7e61c95b942797050eb0cbd26d46cf3fe043a4
mq: use dirstateguard instead of dirstate.invalidate (qrefresh)
Before this patch, "mq.queue.refresh()" uses "dirstate.invalidate()"
as a kind of "restore .hg/dirstate to the original status" at failure.
But it just discards changes in memory, and doesn't actually restore
".hg/dirstate". Then, it can't work as expected, if "dirstate.write()"
is executed while processing.
This patch uses "dirstateguard" instead of "dirstate.invalidate()" to
restore ".hg/dirstate" at failure even if "dirstate.write()" is
executed before failure.
This patch also removes "beginparentchage()" and "endparentchange()",
because "dirstateguard" makes them useless, too.
This is a part of preparations to fix the issue that recent (in
memory) dirstate isn't visible to external process (e.g. "precommit"
hook).
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -1683,8 +1683,9 @@
bmlist = repo[top].bookmarks()
+ dsguard = None
try:
- repo.dirstate.beginparentchange()
+ dsguard = cmdutil.dirstateguard(repo, 'mq.refresh')
if diffopts.git or diffopts.upgrade:
copies = {}
for dst in a:
@@ -1737,13 +1738,12 @@
# assumes strip can roll itself back if interrupted
repo.setparents(*cparents)
- repo.dirstate.endparentchange()
self.applied.pop()
self.applieddirty = True
strip(self.ui, repo, [top], update=False, backup=False)
- except: # re-raises
- repo.dirstate.invalidate()
- raise
+ dsguard.close()
+ finally:
+ release(dsguard)
try:
# might be nice to attempt to roll back strip after this
More information about the Mercurial-devel
mailing list