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

Re: Common Use-Cases for Merging

From: Christopher Ness <chris_at_nesser.org>
Date: 2004-12-22 18:37:49 CET

On Tue, 2004-21-12 at 23:10 -0500, Joe wrote:
> Chapter 4 of the SVN book doesn't seem to cover what I think is a common
> occurrence: branching back to the trunk a file added in a branch. The
> section discusses mostly the use of "svn merge", but that doesn't seem
> to allow such an operation. I assume the right command is to use "svn
> copy" to propagate the addition (it seems obvious, but maybe not to a
> newbie).
>
> I also have a more complicated scenario. In the branch, I added a new
> file by branching it from an existing file in the branch and modifying
> it prior to committing. For example, svn copy foo.php bar.php and edit
> bar.php prior to svn commit. Now I want to merge bar.php into the trunk.

Interesting it looks like you branched in the same directory of the url
but with a different file name. I'm not sure why, but that's ok.

Usually a branch from /trunk/ is copied to /branch/ using the same file
names but different "paths" or URL's in the repository. But if you have
a base PHP template and you want to start from there on a new file this
is perfectly fine.
 
> One option would be to copy foo.php to bar.php in the trunk and then use
> svn merge to attempt to apply the changes made in the branch (don't know
> if this works). The second option would be to svn copy bar.php directly

I don't think there is any need to "copy" the file back. Try this using
your svn copy command above:

svn merge foo.c@HEAD bar.c@HEAD ./foo.c

I think that should do it. See `svn help merge` example number 2.
I tested it and it "worked for me".

> from the version in the branch. In the former case, the ancestry of the
> trunk bar.php would remain within the trunk, with changes merged from
> the branch. In the latter case, the ancestry of the trunk bar.php would be
>
> bar.php (trunk) <- bar.php (branch) <- foo.php (branch) <- foo.php (trunk)

Is this equivalent to what you have above?
/trunk/bar.php <- /branch/bar.php <- /branch/foo.php <- /trunk/foo.php

I'm not sure why you want to change the name, but that's up to you.

> Is there any advantage to doing this one way or the other? Presumably,
> foo.php and bar.php will lead separate lives in the future, but since
> they still share some (redundant code) it's possible that a change in
> one file may have to be replicated to the other three versions.

What are the 3 versions again? I got lost along the way.

> Incidentally, is there an "error messages explained" somewhere? When I
> was trying some of the merge commands I got a "svn: Cannot replace a
> directory from within". I did a Google search but none of the results
> was very elucidating.

I think this link is relevant to your problem.
http://svn.haxx.se/users/archive-2004-11/1336.shtml

Cheers,
Chris

-- 
Software Engineering IV,
McMaster University
PGP Public Key: http://www.nesser.org/pgp-key/
12:08:50 up 1 day, 14 min, 4 users, load average: 0.08, 0.02, 0.01 
http://www.fsf.org/philosophy/no-word-attachments.html

Received on Wed Dec 22 18:40:06 2004

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

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