diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -203,8 +203,16 @@ def dorecord(ui, repo, commitfunc, cmdsu finally: # 5. finally restore backed-up files try: + dirstate = repo.dirstate for realname, tmpname in backups.iteritems(): ui.debug('restoring %r to %r\n' % (tmpname, realname)) + + if dirstate[realname] == 'n': + # without normallookup, restoring timestamp + # may cause partially committed files + # to be treated as unmodified + dirstate.normallookup(realname) + util.copyfile(tmpname, repo.wjoin(realname)) # Our calls to copystat() here and above are a # hack to trick any editors that have f open that diff --git a/tests/test-commit-interactive.t b/tests/test-commit-interactive.t --- a/tests/test-commit-interactive.t +++ b/tests/test-commit-interactive.t @@ -1381,6 +1381,8 @@ Ignore win32text deprecation warning for record this change to 'subdir/f1'? [Ynesfdaq?] y + $ hg status -A subdir/f1 + C subdir/f1 $ hg tip -p changeset: 28:* (glob) tag: tip @@ -1417,6 +1419,8 @@ Test --user when ui.username not set +e record this change to 'subdir/f1'? [Ynesfdaq?] y + $ hg status -A subdir/f1 + C subdir/f1 $ hg log --template '{author}\n' -l 1 xyz $ HGUSER="test" @@ -1426,7 +1430,7 @@ Test --user when ui.username not set Moving files $ hg update -C . - 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg mv plain plain3 $ echo somechange >> plain3 $ hg commit -i -d '23 0' -mmoving_files << EOF @@ -1447,6 +1451,8 @@ Moving files record this change to 'plain3'? [Ynesfdaq?] y The #if execbit block above changes the hash here on some systems + $ hg status -A plain3 + C plain3 $ hg tip changeset: 30:* (glob) tag: tip @@ -1526,3 +1532,98 @@ The #if execbit block above changes the +foo $ cd .. + + $ hg status -A folder/bar + C folder/bar + +Clear win32text configuration before size/timestamp sensitive test + + $ cat >> .hg/hgrc < [extensions] + > win32text = ! + > [decode] + > ** = ! + > [encode] + > ** = ! + > [patch] + > eol = strict + > EOF + $ hg update -q -C null + $ hg update -q -C tip + +Test that partially committed file is still treated as "modified", +even if none of mode, size and timestamp is changed on the filesystem +(see also issue4583). + + $ cat > subdir/f1 < A + > a + > a + > b + > c + > d + > E + > EOF + $ hg diff --git subdir/f1 + diff --git a/subdir/f1 b/subdir/f1 + --- a/subdir/f1 + +++ b/subdir/f1 + @@ -1,7 +1,7 @@ + -a + +A + a + a + b + c + d + -e + +E + + $ touch -t 200001010000 subdir/f1 + + $ cat >> .hg/hgrc < # emulate invoking patch.internalpatch() at 2000-01-01 00:00 + > [fakepatchtime] + > fakenow = 200001010000 + > + > [extensions] + > fakepatchtime = $TESTDIR/fakepatchtime.py + > EOF + $ hg commit -i -m 'commit subdir/f1 partially' < y + > y + > n + > EOF + diff --git a/subdir/f1 b/subdir/f1 + 2 hunks, 2 lines changed + examine changes to 'subdir/f1'? [Ynesfdaq?] y + + @@ -1,6 +1,6 @@ + -a + +A + a + a + b + c + d + record change 1/2 to 'subdir/f1'? [Ynesfdaq?] y + + @@ -2,6 +2,6 @@ + a + a + b + c + d + -e + +E + record change 2/2 to 'subdir/f1'? [Ynesfdaq?] n + + $ cat >> .hg/hgrc < [extensions] + > fakepatchtime = ! + > EOF + + $ hg debugstate | grep ' subdir/f1$' + n 0 -1 unset subdir/f1 + $ hg status -A subdir/f1 + M subdir/f1