Issue1830

Title Rebase or merge bug
Priority bug Status resolved
Superseder unnecessary merge conflicts in rebase
View: 1561
Nosy List abuehl, astratto, cboos, friedrich, jcoomes, sborho
Assigned To Topics

Created on 2009-09-14.15:27:24 by sborho, last changed 2009-11-27.07:03:14 by cboos.

Messages
msg11095 (view) Author: cboos Date: 2009-11-27.07:03:14
With Mercurial 1.4 and issue1561 fixed, the recipe given in msg10505 now 
seems to produce the expected results:

$ hg st --rev 2:3
M b\bar
M b\foo

and:

$ cat b/bar
bar
bar2

$ cat b/foo
foo
foo2


Marking as superseded.
msg10523 (view) Author: astratto Date: 2009-09-17.04:12:31
Here's a more detailed log of the bug.
I suspect this is related to other rebase's bugs and the way we look for
ancestors.
In this period I can hardly follow the ML and I've got very few time to
spend on hg, but please add me to the nosy list whenever you find a bug like
this, thanks.

o  3:4007d7a1b0ea Summary: rev 3: M a/bar
|
|  diff --git a/a/bar b/a/bar
|  --- a/a/bar
|  +++ b/a/bar
|  @@ -1,1 +1,2 @@
|   bar
|  +bar2
|
| @  2:3590b74f1c93 Summary: rev 2: a->b
|/
|    diff --git a/a/foo b/a/foo
|    deleted file mode 100644
|    --- a/a/foo
|    +++ /dev/null
|    @@ -1,2 +0,0 @@
|    -foo
|    -foo2
|    diff --git a/a/bar b/b/bar
|    rename from a/bar
|    rename to b/bar
|    diff --git a/b/foo b/b/foo
|    new file mode 100644
|    --- /dev/null
|    +++ b/b/foo
|    @@ -0,0 +1,2 @@
|    +foo
|    +foo2
|
o  1:4b7ce962c71a Summary: rev 1: M a/foo
|
|  diff --git a/a/foo b/a/foo
|  --- a/a/foo
|  +++ b/a/foo
|  @@ -1,1 +1,2 @@
|   foo
|  +foo2
|
o  0:a1aa4efc3042 Summary: rev 0; A a

   diff --git a/a/bar b/a/bar
   new file mode 100644
   --- /dev/null
   +++ b/a/bar
   @@ -0,0 +1,1 @@
   +bar
   diff --git a/a/foo b/a/foo
   new file mode 100644
   --- /dev/null
   +++ b/a/foo
   @@ -0,0 +1,1 @@
   +foo

rebase onto 2 starting from 3
rebase status stored
rebasing 3:4007d7a1b0ea
 future parents are 2 and -1
 already in target
 merge against 3:4007d7a1b0ea
first revision, do not change ancestor
  searching for copies back to rev 2
  unmatched files in local:
   b/bar
   b/foo
  all copies found (* = to merge, ! = divergent):
   b/bar -> a/bar *
  checking for directory renames
  dir a/ -> b/
resolving manifests
 overwrite False partial False
 ancestor 4b7ce962c71a local 3590b74f1c93+ remote 4007d7a1b0ea
 b/bar: local copied/moved to a/bar -> m
preserving b/bar for resolve of b/bar
picked tool 'internal:merge' for b/bar (binary False symlink False)
merging b/bar and a/bar to b/bar
my b/bar@3590b74f1c93+ other a/bar@4007d7a1b0ea ancestor a/bar@a1aa4efc3042
 premerge successful
  searching for copies back to rev 2
  unmatched files in local:
   a/bar
   a/foo
  unmatched files in other:
   b/bar
   b/foo
  all copies found (* = to merge, ! = divergent):
   b/bar -> a/bar *
  checking for directory renames
  dir a/ -> b/
  file a/foo -> b/foo
 set parents
b/bar
 b/bar: searching for copy revision for a/bar
 b/bar: copy a/bar:b004912a8510032a0350a74daa2803dadfb00e12
rebase merging completed
1 changesets found
list of changesets:
13beafaa564ffa12dd3858acbded4c05ae019eec
saving bundle to /tmp/test/.hg/strip-backup/4007d7a1b0ea-temp
adding branch
adding changesets
add changeset 13beafaa564f
adding manifests
adding file changes
adding b/bar revisions
added 1 changesets with 1 changes to 1 files
updating the branch cache
invalidating branch cache (tip differs)
rebase completed
@  3:13beafaa564f Summary: rev 3: M a/bar
|
|  diff --git a/b/bar b/b/bar
|  --- a/b/bar
|  +++ b/b/bar
|  @@ -1,1 +1,2 @@
|   bar
|  +bar2
|  diff --git a/b/foo b/b/foo
|  deleted file mode 100644
|  --- a/b/foo
|  +++ /dev/null
|  @@ -1,2 +0,0 @@
|  -foo
|  -foo2
|
o  2:3590b74f1c93 Summary: rev 2: a->b
|
|  diff --git a/a/foo b/a/foo
|  deleted file mode 100644
|  --- a/a/foo
|  +++ /dev/null
|  @@ -1,2 +0,0 @@
|  -foo
|  -foo2
|  diff --git a/a/bar b/b/bar
|  rename from a/bar
|  rename to b/bar
|  diff --git a/b/foo b/b/foo
|  new file mode 100644
|  --- /dev/null
|  +++ b/b/foo
|  @@ -0,0 +1,2 @@
|  +foo
|  +foo2
|
o  1:4b7ce962c71a Summary: rev 1: M a/foo
|
|  diff --git a/a/foo b/a/foo
|  --- a/a/foo
|  +++ b/a/foo
|  @@ -1,1 +1,2 @@
|   foo
|  +foo2
|
o  0:a1aa4efc3042 Summary: rev 0; A a

   diff --git a/a/bar b/a/bar
   new file mode 100644
   --- /dev/null
   +++ b/a/bar
   @@ -0,0 +1,1 @@
   +bar
   diff --git a/a/foo b/a/foo
   new file mode 100644
   --- /dev/null
   +++ b/a/foo
   @@ -0,0 +1,1 @@
   +foo

M b/bar
R b/foo
msg10510 (view) Author: sborho Date: 2009-09-15.19:13:51
I should mention that doing a merge in lieu of the final rebase does not
expose the problem.  It seems to require rebase to cause the problem.
msg10505 (view) Author: sborho Date: 2009-09-14.22:13:33
Simpler repro script

hg init test
cd test
mkdir a
echo foo > a/foo
echo bar > a/bar
hg ci -Am "rev 0; A a"
echo foo2 >> a/foo
hg ci -m "rev 1; M a/foo"
hg co 0
hg mv a b
hg ci -m "rev 2; a->b"
hg co 1
echo bar2 >> a/bar
hg ci -m "rev 3; M a/bar"
hg rebase -s 3 -d 2

% hg st --rev 2:3
M b/bar
R b/foo
msg10504 (view) Author: sborho Date: 2009-09-14.15:27:20
% hg init test
% cd test
% mkdir a
% echo foo > a/foo
% echo bar > a/bar
% hg add
adding a/bar
adding a/foo
% hg commit -m "initial"
% cd ..
% hg clone test test2
updating working directory
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
% cd test2
% echo foo2 >> a/foo
% hg commit -m "2nd foo"
% cd ../test
% hg mv a b
moving a/bar to b/bar
moving a/foo to b/foo
% hg pull ../test2
pulling from ../test2
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
(run 'hg update' to get a working copy)
% hg up
merging b/foo and a/foo to b/foo
0 files updated, 1 files merged, 0 files removed, 0 files unresolved
% hg st
M b/foo
A b/bar
R a/bar
R a/foo
% hg commit -m "rename a to b"
% cd ../test2
% echo bar2 >> a/bar
% hg commit -m "2nd bar"
% cd ../test
% hg pull ../test2
pulling from ../test2
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
(run 'hg heads' to see heads, 'hg merge' to merge)
% hg glog  
o  changeset:   3:95542652a062
|  tag:         tip
|  parent:      1:0c61290d1078
|  user:        Steve Borho <steve@borho.org>
|  date:        Mon Sep 14 10:19:48 2009 -0500
|  summary:     2nd bar
|
| @  changeset:   2:edf5ac93ffc0
|/   user:        Steve Borho <steve@borho.org>
|    date:        Mon Sep 14 10:18:33 2009 -0500
|    summary:     rename a to b
|
o  changeset:   1:0c61290d1078
|  user:        Steve Borho <steve@borho.org>
|  date:        Mon Sep 14 10:17:43 2009 -0500
|  summary:     2nd foo
|
o  changeset:   0:e80c052f1e31
   user:        Steve Borho <steve@borho.org>
   date:        Mon Sep 14 10:16:44 2009 -0500
   summary:     initial

% hg rebase -s 3 -d 2
merging b/bar and a/bar to b/bar
saving bundle to /home/steve/tools/test/.hg/strip-backup/95542652a062-temp
adding branch
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
rebase completed
% hg tip -p
changeset:   3:ae603ef9806d
tag:         tip
user:        Steve Borho <steve@borho.org>
date:        Mon Sep 14 10:19:48 2009 -0500
summary:     2nd bar

diff --git a/b/bar b/b/bar
--- a/b/bar
+++ b/b/bar
@@ -1,1 +1,2 @@
 bar
+bar2
diff --git a/b/foo b/b/foo
deleted file mode 100644
--- a/b/foo
+++ /dev/null
@@ -1,2 +0,0 @@
-foo
-foo2

% hg st
? b/foo


The bug is that during the rebase this changeset picked up a delete of
b/foo, probably because the rename commit showed b/foo as M instead of A. 
Note that b/foo is still in the repository, but is unrevisioned.

% hg version
Mercurial Distributed SCM (version 2de7d96593db)

Copyright (C) 2005-2009 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
2009-11-27 07:03:14cboossetstatus: chatting -> resolved
superseder: + unnecessary merge conflicts in rebase
messages: + msg11095
nosy: + cboos
2009-10-20 14:56:30friedrichsetnosy: + friedrich
2009-09-17 19:16:18jcoomessetnosy: + jcoomes
2009-09-17 04:12:31astrattosetnosy: + astratto
messages: + msg10523
2009-09-15 19:13:52sborhosetnosy: sborho, abuehl
messages: + msg10510
2009-09-15 18:43:05abuehlsetnosy: + abuehl
2009-09-14 22:13:33sborhosetstatus: unread -> chatting
messages: + msg10505
2009-09-14 15:27:24sborhocreate