Using IntelliJ with SVN and two braches how do I apply changes to both

Until now my code as just been on trunk, but Ive had to create a branch to work against a new as of yet unreleases webservice. But im still fixing bug on the trunk, having made a commit on trunk, how i apply those changes to the branch as well. I tried creating a patch from a commit on trunk, and then applying the patch on the branch, but it just seemed to be empty and didnt do anything

0
12 comments

Bump ..

0

I generally use Integrate Project from the Version Control menu. I deselect Use Ancestry when I do it. Basically you are comparing two branches then integrating or merging those differences into your working copy. If your working copy is the dev branch the two revisions you compare in the Integrate Project dialog are from the trunk. The newer trunk revision is source 1, the older trunk revision is source 2. It's good practice for the revision in source 2 to match the revision you copied to create your branch.

Grant

0

Hi Grant

I tried as you suggested but it complained about one file that was newly created on trunk and does not exist on branch saying there was a conflict, and no files seems to have been modified.

From your last comment ' It's good practice for the revision in source 2 to match the revision you copied to create your branch.' I dont know if this is right the way for me to do things because its impossible to do this good practise, I give a bit more information


trunk revison 100 create a new branch
branch do some coding and check in revisions 101,102,103,104
Now fix a bug in trunk and check in as revision 105
I now want the changes in revision 105 applied to branch so I use Integrate on branch selecting the 105 and 100 revisions (the last two revisions applied to trunk)
Assuming the previous step works agfter reviewing revison 105 on branch will now checkin as revision 106
Now fix another bug in trunk and check in as revision 107
I now want the changes in revision 105 applied to branch so I use  Integrate on branch selecting the 107 and 105 revisions (the last two  revisions applied to trunk)

But 105 is not the revision used to create branch that was 100 !

I thought I could use a revision as a patch but it doesnt seem so

0

It's difficult to give guidance on merging with Intellij. My personal experience is sometimes it works okay and sometimes not. It was a lot of trial and error in the beginning and there are still times I simply use command line instead of the Intellij integration. The more you merge back and forth between a branch and trunk the more headaches you are likely to experience. My recommended best practice is what works for us. We usually don't merge trunk changes into our branches. We merge branch changes to the trunk then copy the trunk again to create a new branch. Your situation might be different and require a modified process.

0

IMHO, it is much better to do merging from the command-line rather than a GUI tool. I have yet to find a GUI tool that doesn't make the merging process more, rather than less, confusing.

Merging with the command-line is easy and straight forward.

What version is your subversion repository? (info could affect any answer, this assumes Subversion 1.5+)

Since you have branched trunk to work on a new feature you have what would be known as a feature branch, to merge any bug fixes from trunk to the branch:

1) go to the branches' top-level source directory
2) Execute: svn merge http://yourserver.com/svn/path/to/trunk --dry-run
3) If everything looks fine in #2 remove the --dry-run to do the merge for real
4) resolve any conflicts (if any, I use intellij for this step with the diff viewer), then commit

Since you have a feature branch, when you are done with your feature, merge back into trunk with the --reintegrate option and then delete the branch.

http://svnbook.red-bean.com/en/1.5/svn-book.html#svn.branchmerge.commonpatterns.feature

0

Hi Michael
The trouble with your approach is that the merge merges everything that has chnaged in trunk into branch, doesnt ?
I would much prefer to be able to say just merge changes made in this particular revision to the branch, and as Im doing this often would prefer if I could do wihin Jetbrains itself.

0

So when you merge branch into trunk, does trunk get all the differences made in the branch, thats not what I want because the branch has code that canot be released yet, not because it is unfinished but because it relys on 3rd party components that are not yet released, whereas trunk contains code that can be released. I see if you create a new branch every time you dont have the problem I do but unfortunately that way of working is no good in this solution, I just have two parallel devlopements going on, with some chnages needing to be applied to both and some not.

0

You can specify which revisions to merge with the -r option.

I highly recommend that you read chapter 4 of the free online subversion book:

http://svnbook.red-bean.com/en/1.5/svn-book.html#svn.branchmerge

0

paultaylor wrote:

Hi Michael
The trouble with your approach is that the merge merges everything that has chnaged in trunk into branch, doesnt ?
I would much prefer to be able to say just merge changes made in this particular revision to the branch, and as Im doing this often would prefer if I could do wihin Jetbrains itself.


Try the Merge From option in the Version Control menu. That is probably the option you want but it does require you to configure the trunk and branch locations before attempting the merge. You can pick a specific revision when using Merge From. Then when you are ready to merge your changes from the branch back to trunk use Integrate Project.

Grant

0

Heh thanks Grant I was just trying this out as it appears to offer the option to pick revisions and provides a way to what Michael suggests from within Intellij.
Unfortunately there seems to be a problem
The branches/trunk are listed and I can select 'trunk'
Then I am given the choiuce betweeen Merge All and 'Select Revisions to Merge', I select the revision option and it says 'Merge start wasn't found'

0

I'll try tonight when I have some free time. I have not attempted to use Merge From in my own projects. I'll post my results to this thread after I give it a go. The SVN integration in Intellij is some of the best I have experienced in an IDE but it's not without its quirks.

0

I tested and it works fine. I made a trunk copy, checked it out and created a project in IntelliJ. I already had trunk checked out so I commited some deletes I had lying around. I then configured my trunk and branches directories in IntelliJ and clicked Merge From. I seleted trunk then the revision with the deletes. It merged the deletes into my branch and I followed it with a commit.

I remember having similar problems to you when I first started. It's all in the configuration. Once you get it right it works. My SVN server in the settings is defined as the root of our corporate repository tree. Something like the following...


https://<...>/svn/root

My working copy and project is at https://<...>/svn/root/project/branches/my-branch

The trunk location in Configure Branches is https://<...>/svn/root/project/trunk

The branch location in Configure Branches is https://<...>/svn/root/project/branches

When you pick Merge From you should get a dialog that shows you trunk and branches as options. Since you want to merge trunk changes to your branch pick trunk and the next dialog you should be able to pick the revision and merge it. That's basically what I did and it works without issue.

Grant

0

Please sign in to leave a comment.