[PATCH 4 of 9 STABLE] import: use "dirstateguard" instead of "dirstate.invalidate"
foozy at lares.dti.ne.jp
Wed Oct 1 11:18:31 CDT 2014
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1412179386 -32400
# Thu Oct 02 01:03:06 2014 +0900
# Branch stable
# Node ID 6675629ec0d25dc2a198a714e0c5ebed8f854303
# Parent 4bd28b652e70c69916dc1db74a77175eb97f8670
import: use "dirstateguard" instead of "dirstate.invalidate"
Before this patch, "commands.import" uses "dirstate.invalidate()" to
restore dirstate to original status at failure. But it doesn't work
correctly, if "dirstate.write()" is executed while importing.
This patch uses "dirstateguard" instead of "dirstate.invalidate" to
restore dirstate easily and certainly, even if "dirstate.write()" is
This is the preparation for fixing the issue that recent (in memory)
dirstate isn't visible to external process (e.g. "precommit" hook).
diff --git a/mercurial/commands.py b/mercurial/commands.py
@@ -3875,7 +3875,7 @@
base = opts["base"]
- wlock = lock = tr = None
+ wlock = dsguard = lock = tr = None
msgs = 
ret = 0
@@ -3883,6 +3883,7 @@
wlock = repo.wlock()
+ dsguard = cmdutil.dirstateguard(repo, 'import')
if not opts.get('no_commit'):
lock = repo.lock()
tr = repo.transaction('import')
@@ -3921,19 +3922,18 @@
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