[issue1482] hg import tries to apply patches twice when an empty file is added

Andrew Church mercurial-bugs at selenic.com
Sun Jan 25 01:33:12 CST 2009


New submission from Andrew Church <mercurial at achurch.org>:

When "hg import" encounters a new, empty file in a patchset created with "hg
export --git", it sometimes tries to apply all the patches it has seen before
that file a second time, causing the import to fail (since the patches were
already applied).  The exact conditions under which this happens are unclear,
but a simple example shows what would seem to be related behavior.  On running
the following script:

======================
#!/bin/sh

set -e
set -x

hg init test
cd test
echo hello >a
hg add a
hg commit -mtest
echo goodbye >a
touch b
hg add b
hg commit -magain
hg export 0 >../r0
hg export 1 >../r1
cd ..

hg init test2
cd test2
hg -v import ../r0
hg -v import ../r1
cd ..
======================

the second "hg import" prints:

======================
applying ../r1
patching file a
patching file a
adding b
a
b
======================

Note the double "patching a" (though the import does succeed in this case).  If
the filename of "a" is changed to "c", however (so that it appears after the
addition of "b" in the patchset), the "patching c" line is only shown once:

======================
applying ../r1
patching file c
adding b
b
c
======================

For reference, the output from an import that actually failed was as follows:

======================
applying /tmp/t
patching file transcode/trunk/configure.in
patching file transcode/trunk/libsupport/Makefile.am
patching file transcode/trunk/configure.in
Reversed (or previously applied) patch detected!  Assume -R? [n]
Apply anyway? [n]
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file transcode/trunk/configure.in.rej
1 out of 1 hunk ignored -- saving rejects to file transcode/trunk/configure.in.rej
patching file transcode/trunk/libsupport/Makefile.am
adding transcode/trunk/libsupport/dummy.c
abort: patch command failed: exited with status 1
======================

I can provide a copy of the failing patchset and corresponding repository (87MB)
if needed.

----------
messages: 8479
nosy: achurch
priority: bug
status: unread
title: hg import tries to apply patches twice when an empty file is added

____________________________________________________
Mercurial issue tracker <mercurial-bugs at selenic.com>
<http://www.selenic.com/mercurial/bts/issue1482>
____________________________________________________



More information about the Mercurial-devel mailing list