[issue672] hg merge doesn't find renames after merge

Matt Mackall mercurial-bugs at selenic.com
Tue Aug 7 23:05:06 CDT 2007


New submission from Matt Mackall <mpm at selenic.com>:

From: Edward Lee <edilee at mozilla.com>

It seems that mercurial forgets about renamed files after some amount
of activity and prompts "remote changed <filename> which local deleted
[(k)eep or (d)elete?]" on |hg merge| even though it used to correctly
do "merging <oldname> and <newname>".

Are there any known issues with rename or some commands for me to
track down why mercurial doesn't try merging through the rename?

----

The repositories in question are cvs-mirror [1], mozilla-central [2],
and actionmonkey [3] where (1) acts like a read-only source of changes
for the other two. There's a changeset [4] that renamed some files on
(3) which was merged [5] back to (2). At this point pulling from (1)
into (2) works fine even with renamed files, but some reason after
merging [6] some changes from (1) into (2), pulling new changes
results in "[(k)eep or (d)elete?]"

So some reason after the merge, mercurial doesn't remember that it
renamed some files.

Ed

[1] http://hg.mozilla.org/cvs-trunk-mirror/
[2] http://hg.mozilla.org/mozilla-central/
[3] http://hg.mozilla.org/actionmonkey/
[4] http://hg.mozilla.org/actionmonkey/?rev/bd9c9cbf9ec8
[5] http://hg.mozilla.org/mozilla-central/?rev/0f62afa8267f
[6] http://hg.mozilla.org/mozilla-central/?rev/d7e93861f3f3

On 8/7/07, Edward Lee <edilee at mozilla.com> wrote:                    
> Are there any known issues with rename                                       
                                                                               
              
Good news and bad news. Seems like it's an issue of |hg merge| and not
|hg rename|. By renaming the files back to original, commit, rename to         
                                                                               
              
the new name, commit, mercurial is able to merge the files correctly
when pulling changes. However, this problem of mercurial forgetting
about the rename can occur again fairly easily.                 

> some reason after merging [6] some changes from (1) into (2), pulling        
                                                                               
              
> new changes results in "[(k)eep or (d)elete?]"                               
                                                                               
              
> [6] http://hg.mozilla.org/mozilla-central/?rev/d7e93861f3f3                  
                                                                               
              
The interesting thing here is that it turns out the merge just        
happened to not touch any of the renamed files. So any merges that   
don't involve the renamed files will have mercurial forgetting about
the rename. Similarly, even if some of the renamed files are touched,
the remaining renamed files that are untouched are also forgotten in
the merge.                        

----                                                              
                   
Here is a sample set of commands that result in the "keep or delete" prompt.
  
mkdir testhg
cd testhg                                  
hg init source                            
cd source                              
touch one.c                                             
hg add one.c                                               
touch two.h                                                
hg add two.h                                   
hg commit -m init     
cd ..                
hg clone source dest                         
cd dest                                                                        
                                                                               
              
hg rename one.c one.cpp                                                        
                                                                               
              
hg commit -m rename                                                            
                                                                               
              
cd ../source                                                                   
                                                                               
              
echo hello >> two.h                                                            
                                                                               
              
hg commit -m hello                                                             
                                                                               
              
cd ../dest                                                                     
                                                                               
              
hg pull ../source                                                              
                                                                               
              
hg merge                                                                       
                                                                               
              
hg commit -m mergehello                                                        
                                                                               
              
cd ../source                                                                   
                                                                               
              
echo world >> one.c                                                            
                                                                               
              
hg commit -m world                                                             
                                                                               
              
cd ../dest                                                                     
                                                                               
              
hg pull ../source
hg merge

And the corresponding output..

2 files updated, 0 files merged, 0 files removed, 0 files unresolved
pulling from ../source
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)                             
                                                                               
              
1 files updated, 0 files merged, 0 files removed, 0 files unresolved  
(branch merge, don't forget to commit)                                         
                                                                               
              
pulling from ../source                                              
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)                             
                                                                               
              
remote changed one.c which local deleted                              
(k)eep or (d)elete?                                                  
                                                                    
Ed

----------
assignedto: mpm
messages: 3732
nosy: alexis, mpm
priority: bug
status: chatting
title: hg merge doesn't find renames after merge

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



More information about the Mercurial-devel mailing list