[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Problems merging renamed file with contents changes

From: Colin D Bennett <cbennett_at_radsoft.com>
Date: 2002-09-10 20:39:17 CEST

Is there an easier way to merge changes containing file moves on files you've
changed? If someone else has renamed a file I've edited, and I merge in their
changes, my changed file is conveniently deleted and the changes lost.

It is possible to do an svn revert on the file with my changes, and then merge
by hand. (I'm not sure what the best way to merge these two files then...)
What do you do when you encounter this situation?

I understand that the diff (and, as a result, the merge) don't detail file
name changes, but the diff basically just deletes all the lines in the old
file, and adds all the lines to the new file.

Here's a simple test that shows my dilemma. Bob and Joe are working on two
separate branches, and Joe renames a file, that Bob has edited. Then Bob
merges Joe's changes (with the file rename) into his workspace.

(The lines starting with '###' are my annotations.)
---------------------------------------------------

[cdb@merlin:~/t]$ svnadmin create /tmp/repos
[cdb_at_merlin:~/t]$ svn mkdir file:///tmp/repos/trunk -m "initial creation"
Committed revision 1.
[cdb_at_merlin:~/t]$ svn co file:///tmp/repos/trunk trunk
Checked out revision 1.
[cdb@merlin:~/t]$ cd trunk
[cdb@merlin:~/t/trunk]$ echo "This is the README." >REAMDE
[cdb@merlin:~/t/trunk]$ svn add REAMDE
A REAMDE
[cdb@merlin:~/t/trunk]$ svn ci -m "added readme"
Adding REAMDE
Transmitting file data .
Committed revision 2.
[cdb_at_merlin:~/t/trunk]$ svn cp file:///tmp/repos/trunk
file:///tmp/repos/joes-branch -m "made joe's branch"

Committed revision 3.
[cdb_at_merlin:~/t/trunk]$ svn cp file:///tmp/repos/trunk
file:///tmp/repos/bobs-branch -m "made bob's branch"

Committed revision 4.
[cdb@merlin:~/t/trunk]$ cd ..
[cdb_at_merlin:~/t]$ svn co file:///tmp/repos/bobs-branch bob
A bob/REAMDE
Checked out revision 4.
[cdb_at_merlin:~/t]$ svn co file:///tmp/repos/joes-branch joe
A joe/REAMDE
Checked out revision 4.
[cdb@merlin:~/t]$ cd bob
[cdb@merlin:~/t/bob]$ ls
REAMDE

### So Bob updates the 'REAMDE' file.

[cdb@merlin:~/t/bob]$ echo "This is an update to the README file" >>REAMDE
[cdb@merlin:~/t/bob]$ svn ci -m "updated readme"
Sending REAMDE
Transmitting file data .
Committed revision 5.
[cdb@merlin:~/t/bob]$ cd ../joe/
[cdb@merlin:~/t/joe]$ svn up
At revision 5.

### Now Joe renames the file, fixing the spelling error.

[cdb@merlin:~/t/joe]$ svn mv REAMDE README
A README
D REAMDE
[cdb@merlin:~/t/joe]$ svn ci -m "fixed speeling error in README"
Adding README
Deleting REAMDE

Committed revision 6.

### Bob wants Joe's fix, so he merges the changes in.

[cdb@merlin:~/t/joe]$ cd ../bob/
[cdb@merlin:~/t/bob]$ svn st -u
Head revision: 6
[cdb@merlin:~/t/bob]$ ls
REAMDE
[cdb@merlin:~/t/bob]$ svn log
------------------------------------------------------------------------
rev 5: cdb | 2002-09-10 11:19:01 -0700 (Tue, 10 Sep 2002) | 1 line

updated readme
------------------------------------------------------------------------
rev 4: cdb | 2002-09-10 11:17:32 -0700 (Tue, 10 Sep 2002) | 1 line

made bob's branch
------------------------------------------------------------------------
rev 2: cdb | 2002-09-10 11:16:58 -0700 (Tue, 10 Sep 2002) | 1 line

added readme
------------------------------------------------------------------------
rev 1: cdb | 2002-09-10 11:11:58 -0700 (Tue, 10 Sep 2002) | 1 line

initial creation
------------------------------------------------------------------------
[cdb@merlin:~/t/bob]$ svn log ../joe
------------------------------------------------------------------------
rev 6: cdb | 2002-09-10 11:19:51 -0700 (Tue, 10 Sep 2002) | 1 line

fixed speeling error in README
------------------------------------------------------------------------
rev 3: cdb | 2002-09-10 11:17:26 -0700 (Tue, 10 Sep 2002) | 1 line

made joe's branch
------------------------------------------------------------------------
rev 2: cdb | 2002-09-10 11:16:58 -0700 (Tue, 10 Sep 2002) | 1 line

added readme
------------------------------------------------------------------------
rev 1: cdb | 2002-09-10 11:11:58 -0700 (Tue, 10 Sep 2002) | 1 line

initial creation
------------------------------------------------------------------------
[cdb_at_merlin:~/t/bob]$ svn merge file:///tmp/repos/joes-branch_at_3
file:///tmp/repos/joes-branch .
A README
D REAMDE

### I lost my changes !

[cdb@merlin:~/t/bob]$ ll
total 1
-rw-rw-r-- 1 cdb cdb 20 Sep 10 11:21 README
[cdb@merlin:~/t/bob]$ cat README
This is the README.
[cdb@merlin:~/t/bob]$ svn revert REAMDE
Reverted REAMDE
[cdb@merlin:~/t/bob]$ mv REAMDE README
mv: overwrite `README'? y
[cdb@merlin:~/t/bob]$ svn st
A + README
! REAMDE
[cdb@merlin:~/t/bob]$ svn rm REAMDE
D REAMDE
[cdb@merlin:~/t/bob]$ svn ci

Log message unchanged or not specified
a)bort, c)ontinue, e)dit
a
[cdb@merlin:~/t/bob]$ svn ci -m "merged with joe's rename"
Adding README
Deleting REAMDE
Transmitting file data .s
Committed revision 7.
[cdb@merlin:~/t/bob]$ svn up
At revision 7.
[cdb@merlin:~/t/bob]$ svn st
[cdb@merlin:~/t/bob]$ ll
total 1
-rw-rw-r-- 1 cdb cdb 57 Sep 10 11:21 README
[cdb@merlin:~/t/bob]$ cat README
This is the README.
This is an update to the README file
[cdb@merlin:~/t/bob]$

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Sep 10 20:40:22 2002

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.