Issue988

Title merge incorrectly reverts deletion of files locally deleted but not committed
Priority critical Status resolved
Superseder Nosy List abuehl, alexis, bos, djc, jcoomes, jglick, mpm, pmezard
Assigned To bos Topics merge, patch

Created on 2008-02-15.15:18:55 by jglick, last changed 2008-03-18.22:08:41 by djc.

Files
File name Uploaded Type Edit Remove
doit alexis, 2008-02-15.17:11:44 text/plain
doit-mv jcoomes, 2008-02-22.10:28:26 text/plain
merge-deleted.patch alexis, 2008-02-15.17:20:44 text/plain
turn_undead.py jglick, 2008-02-25.17:24:17 text/x-python
Messages
msg5647 (view) Author: djc Date: 2008-03-18.22:08:41
In main, resolving.
msg5580 (view) Author: bos Date: 2008-03-12.22:45:41
Alexis's merge-deleted.patch is a375ffc2aa1b in crew.
msg5567 (view) Author: bos Date: 2008-03-11.18:39:07
Part 1 is fixed in crew bd61e44eb2cc.

Alexis, should we go ahead and add merge-deleted.patch?
msg5433 (view) Author: bos Date: 2008-02-29.14:59:07
Ah, I missed a crucial detail, namely that the deleted files are in the '!'
state.  Yes, fetch should abort in that case.  I'll cook something up.
msg5432 (view) Author: jglick Date: 2008-02-29.14:56:49
BTW Alexis noted two problems:

- we should require hg merge --force when there are deleted files

- we should fix handling of deleted files.

but there is only a patch for #2 AFAIK. Has anyone taken a look at #1? In
particular, 'hg fetch' should probably abort in this situation, I think.
msg5415 (view) Author: jglick Date: 2008-02-26.23:41:04
merge-deleted.patch does appear to work at least in a simple test case. After
'hg fetch' without the patch, a deleted file is resurrected; with the patch, it
correctly stays removed.
msg5386 (view) Author: jglick Date: 2008-02-25.17:24:17
Trying to work around this with a server hook that prevents the files from being
accidentally reintroduced.
msg5355 (view) Author: alexis Date: 2008-02-22.17:45:15
jcoomes problem is something different - I've created issue1000 to keep
track of it.

I'm not sure about jglick's last message.  Can you try to write a simple test
case and/or try the patch that is attached to this issue?
msg5350 (view) Author: jglick Date: 2008-02-22.15:26:24
I think we are seeing a similar problem where someone accidentally committed a
build product (matched by an .hgignore entry). They later deleted it, but every
time a clean build is run by someone else, the file is silently deleted and a
subsequent merge silently resurrects it. This pair of files has kept reappearing
for weeks now and no one can kill it for good. I think I can work around by
changing the clean target.
msg5349 (view) Author: jcoomes Date: 2008-02-22.10:28:26
> We'll still have problems if we have a deleted file that remote changed
> instead of removed.

I'm seeing what I think is the same problem with renames.  A file is renamed in
the local repo but not committed.  Remote modifies the file using the old name.
During the merge I get the prompt

   remote changed oldname which local deleted
   use (c)hanged version or leave (d)eleted? 

I expected it to resolve the changes in the locally-renamed file.  Attached
script doit-mv reproduces the problem.  If this is a separate issue let me know
and I'll create one.
msg5290 (view) Author: alexis Date: 2008-02-15.17:27:10
We'll still have problems if we have a deleted file that remote changed
instead of removed.

This is hopefully easy to fix (just add an else: to the "remote changed,
local deleted" prompt), but I'm still not sure there are other such cases.
msg5289 (view) Author: alexis Date: 2008-02-15.17:20:44
Attaching a possible patch.

It calls forgetremoved even in the branchmerge case and teaches it what
to do in this case.
msg5288 (view) Author: alexis Date: 2008-02-15.17:11:44
Adding mpm to the nosy list and attaching a simpler test case.

There are two problems here:

- we should require hg merge --force when there are deleted files

- we should fix handling of deleted files.

For the first one we just have to fix the test for modified working dir.
Right now it looks like "if wc.files():" , but workingctx.files() doesn't
include deleted files.  I'm not sure if it's better to include them there,
or to change the test to 'if wc.files() or wc.deleted():'.

I'll attach a possible patch for the second problem in a bit.
msg5285 (view) Author: jglick Date: 2008-02-15.15:18:53
It seems that if you locally delete some files, but do not commit the deletion,
Mercurial will let you merge a changeset which does delete the files - but the
merge result will quietly resurrect the files. This is very bad because people
can unintentionally restore deleted files which may be harmful. In practice
happens when a file needs to be deleted to make a build pass; someone working on
unrelated changes deletes it just so they can continue working (but does not
feel they have the authority to commit the delete), then the person responsible
for the file actually deletes it, then the first person fetches and pushes,
unknowingly restoring the breakage.

Happens with both fetch and manual merge.


hgtest-bad-merge$ hg init r1
hgtest-bad-merge$ cd r1
r1$ echo a > a
r1$ hg add a
r1$ hg ci -ma
r1$ hg clone . ../r2
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
r1$ hg rem a
r1$ hg ci -m-a
r1$ hg tip
changeset:   1:584ac6cc00ae
tag:         tip
user:        Jesse Glick <jesse.glick@sun.com>
date:        Fri Feb 15 10:07:24 2008 -0500
summary:     -a

r1$ cd ../r2
r2$ rm a
r2$ echo b > b
r2$ hg add b
r2$ hg ci -mb b
r2$ hg fetch ../r1
pulling from ../r1
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 0 changes to 0 files (+1 heads)
merging with new head 2:584ac6cc00ae
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
new changeset 3:755c2bf073af merges remote changes with local
r2$ ls
b
r2$ hg stat
! a
r2$ hg clone . ../r3
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
r2$ cd ../r3
r3$ ls
a  b
r3$ hg log
changeset:   3:755c2bf073af
tag:         tip
parent:      1:c0175266ca9b
parent:      2:584ac6cc00ae
user:        Jesse Glick <jesse.glick@sun.com>
date:        Fri Feb 15 10:07:48 2008 -0500
summary:     Automated merge with file:/tmp/hgtest-bad-merge/r1

changeset:   2:584ac6cc00ae
parent:      0:be77b27bfbfc
user:        Jesse Glick <jesse.glick@sun.com>
date:        Fri Feb 15 10:07:24 2008 -0500
summary:     -a

changeset:   1:c0175266ca9b
user:        Jesse Glick <jesse.glick@sun.com>
date:        Fri Feb 15 10:07:43 2008 -0500
summary:     b

changeset:   0:be77b27bfbfc
user:        Jesse Glick <jesse.glick@sun.com>
date:        Fri Feb 15 10:06:49 2008 -0500
summary:     a

r3$ hg up -r1
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
r3$ hg stat
r3$ hg merge 2
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
(branch merge, don't forget to commit)
r3$ hg di -r3
diff --git a/a b/a
deleted file mode 100644
--- a/a
+++ /dev/null
@@ -1,1 +0,0 @@
-a
r3$ hg clone -r0 ../r1 ../r2a
requesting all changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
r3$ cd ../r2a
r2a$ ls
a
r2a$ echo b > b
r2a$ hg add b
r2a$ hg ci -mb b
r2a$ rm a
r2a$ hg stat
! a
r2a$ hg pull ../r1
pulling from ../r1
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 0 changes to 0 files (+1 heads)
(run 'hg heads' to see heads, 'hg merge' to merge)
r2a$ hg merge
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
r2a$ hg stat
! a
r2a$ hg ci -m merged
r2a$ hg stat
! a
r2a$ hg clone . ../r3a
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
r2a$ cd ../r3a
r3a$ ls
a  b
r3a$ hg log
changeset:   3:3ec88e0daea7
tag:         tip
parent:      1:03ed20f7f7df
parent:      2:584ac6cc00ae
user:        Jesse Glick <jesse.glick@sun.com>
date:        Fri Feb 15 10:11:08 2008 -0500
summary:     merged

changeset:   2:584ac6cc00ae
parent:      0:be77b27bfbfc
user:        Jesse Glick <jesse.glick@sun.com>
date:        Fri Feb 15 10:07:24 2008 -0500
summary:     -a

changeset:   1:03ed20f7f7df
user:        Jesse Glick <jesse.glick@sun.com>
date:        Fri Feb 15 10:10:31 2008 -0500
summary:     b

changeset:   0:be77b27bfbfc
user:        Jesse Glick <jesse.glick@sun.com>
date:        Fri Feb 15 10:06:49 2008 -0500
summary:     a

r3a$ cd ../r2a
r2a$ hg stat
! a
r2a$ hg up
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
r2a$ hg stat
r2a$ ls
a  b
r2a$ hg version
Mercurial Distributed SCM (version 0.9.5)

Copyright (C) 2005-2007 Matt Mackall <mpm@selenic.com> and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
History
Date User Action Args
2008-03-18 22:08:41djcsetstatus: testing -> resolved
nosy: + djc
messages: + msg5647
2008-03-12 22:45:41bossetstatus: chatting -> testing
nosy: mpm, bos, alexis, pmezard, jglick, abuehl, jcoomes
messages: + msg5580
2008-03-11 18:39:07bossetnosy: mpm, bos, alexis, pmezard, jglick, abuehl, jcoomes
messages: + msg5567
2008-03-09 22:25:25mpmsetnosy: mpm, bos, alexis, pmezard, jglick, abuehl, jcoomes
assignedto: bos
2008-02-29 14:59:07bossetnosy: mpm, bos, alexis, pmezard, jglick, abuehl, jcoomes
messages: + msg5433
2008-02-29 14:56:49jglicksetnosy: mpm, bos, alexis, pmezard, jglick, abuehl, jcoomes
messages: + msg5432
2008-02-29 05:14:51bossetnosy: + bos
2008-02-26 23:41:04jglicksetnosy: mpm, alexis, pmezard, jglick, abuehl, jcoomes
messages: + msg5415
2008-02-25 17:24:18jglicksetfiles: + turn_undead.py
nosy: mpm, alexis, pmezard, jglick, abuehl, jcoomes
messages: + msg5386
2008-02-22 17:45:15alexissetnosy: mpm, alexis, pmezard, jglick, abuehl, jcoomes
messages: + msg5355
2008-02-22 15:26:29jglicksetnosy: mpm, alexis, pmezard, jglick, abuehl, jcoomes
messages: + msg5350
2008-02-22 10:28:27jcoomessetfiles: + doit-mv
nosy: + jcoomes
messages: + msg5349
2008-02-16 12:39:48pmezardsetnosy: + pmezard
2008-02-16 09:56:54djcsettopic: + patch
nosy: mpm, alexis, jglick, abuehl
2008-02-15 17:27:10alexissetnosy: mpm, alexis, jglick, abuehl
messages: + msg5290
2008-02-15 17:20:45alexissetfiles: + merge-deleted.patch
nosy: mpm, alexis, jglick, abuehl
messages: + msg5289
2008-02-15 17:11:45alexissetfiles: + doit
nosy: + mpm, alexis
status: unread -> chatting
messages: + msg5288
2008-02-15 16:07:28abuehlsetnosy: + abuehl
2008-02-15 15:18:55jglickcreate