views:

44

answers:

2

Hi, I'm using svn for the first time, to maintain a custom version of Wordpress. I'm using the subclipse plugin in eclipse. The time has come to merge the changes in the latest release of Wordpress with my customised code base. I have tried creating a branch and adding the new Wordpress release there, then performing a merge. No changes were made however. Could someone walk me through the setup of project like this? I fear I am missing something basic. Thanks.

A: 

This is assuming you merge from branch (containing the latest version of Wordpress) to trunk (your customized codebase).

  1. (Make sure that you have committed everything you need into branch.)

  2. Team --> Switch to another branch/tag/revision... your working copy to trunk (the target of your merge operation), and resolve any conflicts that come up at this point.

  3. Team --> Merge opens a dialog where you will be performing the merge operation. Change the "From" URL to reference branch (the source of your merge operation, i.e. what you want to merge into your working copy). "From Revision" should point to the revision in branch where you want your merge operation to "start" from - typically the revision that was last merged in from branch to trunk (or most likely the head revision in your case, if you really want to merge just that latest changes in branch).

  4. Set "To Revision" to point to the latest revision in branch (= the head revision).

  5. At this point you are ready to perform the merge - Dry run command lets you preview what will happen during the merge, and Merge will perform the actual merge.

  6. Once the merge operation has been completed, you need to make sure that all changes that were performed against your working copy are ok, and resolve all conflicts.

  7. When you're done with resolving conflicts and reviewing the changes, commit the changes to trunk in a single commit operation. For your own convenience, it is strongly recommended that you add a commit message where you specifically state what this commit is for ( = merging revisions from X to Y from branch to trunk, what was the purpose, etc.).

Hope this helps.

Tommi
This is really useful Tommi. I'll try it and report back...
Lemmy
Great to hear that. And if this answer happens to solve your problem, please mark it as the correct answer - that's the way this site works. Thanks.
Tommi
A: 

Converting wordpress project to vendor branch procedure

If you are using svn for the first time I suppose you have not started with a clean wordpress copy, branched from there and edited the branched version, have you? ;)

If that is so you might have a problem at your hands.


Background

Unlike "regular diffs" SVN merge does not compare right-side code/folders with left-side code/folders. While svn merge might fall back to a diff-like mechanism if it does not find a history, I would not recommend relying on that as it can be quite prone to unneccessary conflicts.

SVN Merge is used to reproduce changes that have been recorded in the SVN history. It is like telling a painter "Hey you know how this picture looked before you added that tree on the hill? That Tree was great! Look here i've copied the same base picture but now it's with a sunset. Can you paint the same tree again but on this picture with the sunset?" The painter might be able to reproduce the tree because he knows how he had done it. He might even have a draft somewhere.

The picture, that is wordpress. The painter, its svn with you commanding it. The tree thats your modifications. The picture now sunset-themed is the newer wordpress version.

What most likely you did is copy wordpress vanilla into your svn, modify it, work with it.

To stick with the picture example, the history would contain commands like "copy whole picture, add tree, add leaves".

Now you bring a new version of wordpress, a new picture so to say and put it besides your older modified version. The Problem is, you human and smart know its quite much the same picture and even though the newer verison is different you just have to copy the tree, SVN does not have that knowledge. For SVN your wordpress 1.7 folder (modified) is completly distinct from wordpress 1.8. They share no history because nothing in SVNs log indicate it. SVN is a bureaucratic snob isn't it? ;)

Now what people do to allow svn to maintain that historic connection between wordpress 1.7, your modified 1.7 and the new 1.8 is they use branching right at the beginning of their works.

So you would start off with a clean 1.7 wordpress in a "vanilla-wordpress" folder, store it in svn and branch it to, say, "my-modified-wp". There you hack away until you feel like updating wordpress from upstream. People then download the latest wordpress copy overwrite their vanilla wordpress and merge the resulting changeset.

In the picture example commands would be these:

"Buy original picture
copy original picture as my picture
draw tree on my picture
draw sunset on original picture (someone else did that for you, aka update)
*reproduce* sunset on my picture too"

You can cleanly reproduce the sunset because you know how the picture looked before the sunset was applied.

Your problem though is that you did not start that way off but edited on your downloaded wordpress right away. So your newer copy of wordpress can not be easily associated with your modified version.


One way to establish history relations

download the **exact** wordpress version you started your project with
Put it into /vendor/wordpress/current
invoke "svn copy http://svnserver.tld/repositorypath/vendor/wordpress/current http://svnserver.tld/repositorypath/vendor/wordpress/1.7.1" to tag the import.
invoke "svn copy http://svnserver.tld/repositorypath/vendor/wordpress/current http://svnserver.tld/repositorypath/branches/my-new-modified-wordpress" or whatever your project/WP-edition is called.

Now comes the trick part Scroll back the svn log of your "old-modified-wordpress". The one that you did not branch. You have to find the first revision AFTER your initial import of the old wordpress. Once you found that revision you take its number and use it in the second of these two commands:

change into a local checkout of "/branches/my-new-modified-wordpress"
issue "svn merge -r **4**:HEAD http://svnserver.tld/repositorypath/my-**old**-modified-wordpress". If 4 was the first revision during which you made own modifications.

You are telling svn the following: "Take all changes in my old branch between revision 4 and NOW and reproduce them on my new branch."

If all works out you should have two identical branches. the old-modified and the new-modified with the slight difference that the new-modified has a solid history with your "/vendor/wordpress/current" branch.

This ancestry allows you to contunously do the following:

Download the wordpress version you wish to upgrade too and **overwrite** /vendor/wordpress/current
invoke "svn copy http://svnserver.tld/repositorypath/vendor/wordpress/current http://svnserver.tld/repositorypath/vendor/wordpress/1.9.3" to tag the new version.
change into local checkout /branches/my-new-modified-wordpress
issue "svn merge http://svnserver.tld/repositorypath/vendor/wordpress/current"
profit

This procedure I describe with less storystelling at the link allready. But before it can work you have to establish the ancestry relation between the branches.

http://stackoverflow.com/questions/3754459/subversion-svnexternals-file-override/3785904#3785904

I know it has been alot to read :). If you plan do soem drawing, think of "change commands" not states and you'll be fine.

C

Christoph Strasen
Thanks Cristoph for your clear explanation. You summed up my situation well. That's useful in itself as I will now know how to set up future projects. I will have a shot at sorting out my current project using your instructions but your overview was particularly useful.
Lemmy