You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by "Emin.shopper Martinian.shopper" <em...@gmail.com> on 2007/07/20 22:03:21 UTC
question on svn merge without revision numbers
Dear Experts,
Almost all the documentation I've seen on svn merge suggests using a
revision number for things to merge. Is this really necessary?
Let's say I create a branch called foo and work on it for a while. Then I
want to merge it back into the trunk. Can I just do
svn merge <URL-for-branch> <URL-for-trunk> <URL-for-trunk>
to merge it back into the trunk? Similarly, if I want to merge the trunk
into the branch, can I just do
svn merge <URL-for-trunk> <URL-for-branch> <URL-for-branch>
Re: question on svn merge without revision numbers
Posted by Ryan Schmidt <su...@ryandesign.com>.
On Jul 20, 2007, at 17:03, Emin.shopper Martinian.shopper wrote:
> Almost all the documentation I've seen on svn merge suggests using
> a revision number for things to merge. Is this really necessary?
It depends on what you want, but often, yes, this is really
necessary, until Subversion gets merge tracking, which is currently
in development.
> Let's say I create a branch called foo and work on it for a while.
> Then I want to merge it back into the trunk. Can I just do
>
> svn merge <URL-for-branch> <URL-for-trunk> <URL-for-trunk>
>
> to merge it back into the trunk?
First of all, if would be
svn merge <URL-for-branch> <URL-for-trunk> <working-copy-of-trunk>
But no, that will not do what you want, unless you have made no
changes on the trunk since creating the branch, and that's unlikely,
otherwise you would not have bothered to create the branch.
The above command will *do* to the working copy of trunk all the
things you've done on the branch, which is what you want, but will
also *undo* in the trunk working copy any changes you made only on
the trunk, and that's not what you want.
> Similarly, if I want to merge the trunk into the branch, can I just do
>
> svn merge <URL-for-trunk> <URL-for-branch> <URL-for-branch>
Again, it would be:
svn merge <URL-for-trunk> <URL-for-branch> <working-copy-of-branch>
> From my reading of the svn documentation, it seems like svn merge A
> B C should compare A and B and apply the changes to C so this
> should work.
>
> What are the issues that make the svn documentation focus so
> heavily on doing merges by revision number? If your branch has 20
> revisions, doesn't it get painful to have to do a separate merge
> command for each revision?
merge is only a diff and patch. So svn merge A B C will compute the
diff between A and B and apply it to C.
If you want to merge the trunk into the branch, since Subversion does
not have merge tracking yet, you have to tell Subversion how to
construct the diff. In this case, you want to merge the changes that
occurred on the trunk between the revision where you created the
branch, and now, whatever the revision now is, and apply that to the
branch working copy. If you then continue to work on the branch, and
continue to work on the trunk, and later want to again bring changes
from the trunk into the branch, you need to make sure you use the
correct revisions -- you cannot simply start at the revision where
you created the branch again, since those changes have already been
merged. You need to specifically exclude already-merged changes by
beginning at the revision of your last merge.
There are some tools, like svnmerge, that will help automate some of
this for you. But it helps to understand the issues first.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Re: question on svn merge without revision numbers
Posted by Thomas Wicklund <wi...@eskimo.com>.
Emin.shopper Martinian.shopper writes:
>
> Dear Experts,
>
> Almost all the documentation I've seen on svn merge suggests using a
> revision number for things to merge. Is this really necessary?
>
> Let's say I create a branch called foo and work on it for a while. Then I
> want to merge it back into the trunk. Can I just do
>
> svn merge <URL-for-branch> <URL-for-trunk> <URL-for-trunk>
>
> to merge it back into the trunk? Similarly, if I want to merge the trunk
> into the branch, can I just do
>
> svn merge <URL-for-trunk> <URL-for-branch> <URL-for-branch>
>
> >From my reading of the svn documentation, it seems like svn merge A B C
> should compare A and B and apply the changes to C so this should work.
>
> What are the issues that make the svn documentation focus so heavily on
> doing merges by revision number? If your branch has 20 revisions, doesn't it
> get painful to have to do a separate merge command for each revision?
>
> Thanks,
> -Emin
You can do merges without revision numbers, but you don't want to
merge directly with the trunk unless nothing else has changed in the
trunk since the branch was created.
You also have the arguments backwards -- the order is "original code"
followed by "modified code".
To branch and merge without revision numbers, create a tag of the
trunk when you create the branch. Something like:
svn copy trunk-url tag-url
svn copy tag-url branch-url
The "tag-url" is someplace you keep a snapshot of the trunk when the
branch was created. Note that the trunk is copied to the tag, then
the tag copied to the branch. This guarantees one access to the
trunk, if you copied the trunk twice a commit by somebody else could
sneak in between the copies.
After changing the branch, you merge via:
cd trunk-workspace
svn update # be sure up to date with the trunk repository
svn merge tag-url branch-url .
This will merge all changes made to the branch (differences between
the branch and the original version of the trunk) into the trunk
workspace.
To merge trunk changes into the branch, do something like the
following. First commit any changes to the branch.n
cd branch-workspace
svn copy trunk-url temp-url
svn merge tag-url temp-url .
svn move rm tag-url
svn move temp-url tag-url
This merges trunk changes since the branch was created (from tag-url
to temp-url), then replaces tag-url as the new basis for the branch.
Thomas Wicklund
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org