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

Re: question on svn merge without revision numbers

From: Thomas Wicklund <wicklund_at_eskimo.com>
Date: 2007-07-22 22:41:03 CEST

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
Received on Sun Jul 22 22:40:10 2007

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.