[PATCH 6 of 9 V2] mq: use dirstateguard instead of dirstate.invalidate (qpush)
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Sat May 2 15:59:41 UTC 2015
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1430582197 -32400
# Sun May 03 00:56:37 2015 +0900
# Node ID ab0a35bdac68de0d93544799e93a914b339f1aa3
# Parent c0b3c5c755e2f3a9e79462eddb0c9b999c585fc0
mq: use dirstateguard instead of dirstate.invalidate (qpush)
Before this patch, "mq.queue.apply()" 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 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
@@ -807,9 +807,10 @@
def apply(self, repo, series, list=False, update_status=True,
strict=False, patchdir=None, merge=None, all_files=None,
tobackup=None, keepchanges=False):
- wlock = lock = tr = None
+ wlock = dsguard = lock = tr = None
try:
wlock = repo.wlock()
+ dsguard = cmdutil.dirstateguard(repo, 'mq.apply')
lock = repo.lock()
tr = repo.transaction("qpush")
try:
@@ -818,21 +819,22 @@
tobackup=tobackup, keepchanges=keepchanges)
tr.close()
self.savedirty()
+ dsguard.close()
return ret
except AbortNoCleanup:
tr.close()
self.savedirty()
+ dsguard.close()
raise
except: # re-raises
try:
tr.abort()
finally:
repo.invalidate()
- repo.dirstate.invalidate()
self.invalidate()
raise
finally:
- release(tr, lock, wlock)
+ release(tr, lock, dsguard, wlock)
self.removeundo(repo)
def _apply(self, repo, series, list=False, update_status=True,
More information about the Mercurial-devel
mailing list