[issue988] merge incorrectly reverts deletion of files locally deleted but not committed

Jesse Glick mercurial-bugs at selenic.com
Fri Feb 15 09:18:55 CST 2008


New submission from Jesse Glick <jesse.glick at sun.com>:

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 at 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 at 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 at sun.com>
date:        Fri Feb 15 10:07:24 2008 -0500
summary:     -a

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

changeset:   0:be77b27bfbfc
user:        Jesse Glick <jesse.glick at 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 at sun.com>
date:        Fri Feb 15 10:11:08 2008 -0500
summary:     merged

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

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

changeset:   0:be77b27bfbfc
user:        Jesse Glick <jesse.glick at 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 at 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.

----------
messages: 5285
nosy: jglick
priority: critical
status: unread
title: merge incorrectly reverts deletion of files locally deleted but not committed
topic: merge

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



More information about the Mercurial-devel mailing list