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

Re: cherry picking without subversion

From: David Weintraub <qazwart_at_gmail.com>
Date: Sun, 10 Aug 2008 11:31:18 -0400

Merging is a bit more complex than that since Subversion does cherry picking.

Normally, in a merge, you diff the target, the source, and a base
which is usually the latest common ancestor between the source and
target, and the GNU diff3 command can usually handle these situations.
In your case, (assuming you're merging from trunk to your working
copy), the base is revision 5, the source is revision 11, and the
target is your working copy.

However, in Subversion, you could merge some revisions, and not
others. For example, I'm merging from branch "A" to branch "B", and
there is one revision on branch "A" that contains a fix that I don't
want on branch "B". Subversion allows me to skip that revision of the
file as part of my merge. Because of this, you can't merely use a
simple "base, source, target" difference comparison in order to do a
merge.

Making things even more complex is that Subversion never really did
the "source, target, base" merge, and there is a difference between
the way you specify the merge in Subversion 1.4 and earlier and
Subversion 1.5.

In most version control systems, you specify the source, and the
version control system found the base and assumed the target is your
working copy. In more primitive systems, you specified the base and
the source, and the target was your working copy.

In Subversion revisions 1.4 and earlier, you didn't specify the base.
Instead, you specified the revisions on the source you wanted to merge
into the target. In your example, assuming that you're merging from
trunk to branch:

$ svn co http://.../.../.../branch #Checks out the branch as your
working copy. This becomes your target

$ svn merge -r 6:11 http://.../.../.../trunk #Merges revisions 6 -
11 on the trunk to your working copy

Since revision #5 is the base of the merge, you don't specify that
because the changes in revision #5 are already in your target.
Instead, you specify the next revision (revision #6). This really
confused many developers because they were use to specifying the base.
Besides the change that created revision #6 might not even be in the
trunk. Heck, it could be in the branch. Most developers manually
copied in the changes from one branch to another.

Subversion 1.5 makes everything much simpler since it tracks the
changes for you. To merge from one branch to another:

$ svn co http://.../.../.../branch #Checks out the branch as your
working copy. This becomes your target
$ svn merge http://.../.../.../trunk #Merges trunk to branch. No
need to specify revisions.

So, how do you do cherry picking without Subversion? You'd have to get
your trunk revision, find all the changes that took place from the
base to the source, and subtract out the changes that you want to
exclude from the target. That will give you a new "source" that
excludes the changes you don't want.

Then, you can use that modified "source" in the diff3 command.

--
David Weintraub
qazwart_at_gmail.com
On Fri, Aug 8, 2008 at 12:11 PM, Flo <sensorflo_at_gmail.com> wrote:
> My final goal is that I can do the idea of 'cherry picking' also with
> the version control system I am forced to use at my workplace - vss. I
> have cygwin installed, so I have all the gnu tools like diff, diff3
> etc.
>
> As far as I understand, many svn diff/merge/update operations can also
> be done using these gnu tools. E.g. "svn update myfile" is the same as
> getting the base and the head revision of myfile and then do  "diff3
> myfile base head".
>
> Now I am asking myself what I have to do to mimic svn merge. Anyone?
>
> Anyway, I don't even understand if svn merge has 3 or 4 input files.
>
> trunk --- 5---...---10---11
>           |
> branch    \---...---15
>                     |
> working             X
>
> Say I want to merge the changeset 11 into my working copy which's base
> is 15. Now does svn merge also look at the common anchestor 5?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: users-help_at_subversion.tigris.org
Received on 2008-08-10 17:31:54 CEST

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.