[PATCH 4 of 9 V2] import: use dirstateguard instead of dirstate.invalidate
foozy at lares.dti.ne.jp
Sat May 2 10:59:39 CDT 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 f0826bbe149010938a73288e8cfe12a012728f54
# Parent 80a0f16dcf3cbce2ea50db0d6408f848bc1a75e2
import: use dirstateguard instead of dirstate.invalidate
Before this patch, "commands.import()" 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"
diff --git a/mercurial/commands.py b/mercurial/commands.py
@@ -4213,7 +4213,7 @@
base = opts["base"]
- wlock = lock = tr = None
+ wlock = dsguard = lock = tr = None
msgs = 
ret = 0
@@ -4221,7 +4221,7 @@
wlock = repo.wlock()
+ dsguard = cmdutil.dirstateguard(repo, 'import')
if not opts.get('no_commit'):
lock = repo.lock()
tr = repo.transaction('import')
@@ -4262,18 +4262,16 @@
repo.savecommitmessage('\n* * *\n'.join(msgs))
- except: # re-raises
- # wlock.release() indirectly calls dirstate.write(): since
- # we're crashing, we do not want to change the working dir
- # parent after all, so make sure it writes nothing
+ # TODO: get rid of this meaningless try/finally enclosing.
+ # this is kept only to reduce changes in a patch.
- release(lock, wlock)
+ release(lock, dsguard, wlock)
[('f', 'force', None,
More information about the Mercurial-devel