17

We have decided to follow the process of creating a new SVN branch for every new feature that we add to our mobile app. The ultimate goal behind this is to preserve the history for every single code change (this doesn't happen when we manually copy project folders into SVN instead of creating & merging branches).

My problem is that so far I am unable to merge changes from one branch to another.

I have already referred the following posts without success:

Here is what I have tried so far:

I have two feature branches as can be seen below in Tortoise SVN:

enter image description here

I want to merge the changes in the branch Feature_A3 into branch Feature_A2. To do this, I am using the Merge from option in Android Studio's VCS from the A2 working copy:

enter image description here

It then asks me to select the branch to merge from (A3) or configure other branches:

enter image description here

I click on Configure Branches, just to show you the existing branch config:

enter image description here

As you can see, A2 is the Trunk and A3 is the Branch. Is this correct?

It then asks me what part of A3 I want to merge into A2. I select the /src directory (where the relevant changes are present):

enter image description here

It then generously gives me three different ways to perform the merge operation:

enter image description here

I select the third option as it directly gives me the changes I need to merge:

enter image description here

I click on Merge Selected and BAM!!! I get this error every time:

enter image description here

There is no clue as to what the "unresolved conflicts" or "skipped items" are. Why am I getting this error, and what should I do to merge the changes in A3 into A2 ??? Can someone please help ? All answers will be appreciated. Thanks ...

I have been following the official Intellij IDEA documentation below:

Please note that:

  • Currently I am using Subversion, not Git.

  • The directory structure of my local working copies is not exactly identical to that of the SVN repos. Could this be the cause of the error ?

THE ANSWER ...

Thanks to Peter Parker and especially Yoav Aharoni for their valuable feedback. As Yoav correctly pointed out, it was indeed the manner in which the branch locations folder was specified. It needs to be the folder containing the branches, not the branch folders themselves: And as Peter rightly said, checking "Include merged revisions" shows the merged history. I am now able to merge from within the IDE itself, and view the merged history in TortoiseSVN. NO command line! YAY!!!

However, one last problem is that I am unable to view the merged history in Android Studio (Intellij IDEA) as described in Viewing Merge Sources. Does anyone know how to achieve this in Android Studio?

Community
  • 1
  • 1
Yash Sampat
  • 30,051
  • 12
  • 94
  • 120
  • 2
    Did you try with cmd-line or TortoiseSVN? There Error Message could be more telling and maybe this IDE is missing some svn related features(which is not that uncommon). – Peter Parker Mar 26 '16 at 06:19
  • Yes, it seems to work with Tortoise SVN, but although the changes are merged, the history from the source branch is not reflected in the target branch after the merge, which was the goal to begin with ... How can I merge the changes AND have the history from the source branch be reflected in the target branch ? – Yash Sampat Mar 26 '16 at 08:40
  • 1
    have you checked "include merged revisions" in TSVNs dialog? – Peter Parker Mar 26 '16 at 12:38
  • 1
    Yes, let me try that ... BTW you can post your comments as an answer ... If it works, I shall mark it as the correct answer and award the bounty to you ... :) – Yash Sampat Mar 26 '16 at 12:45
  • How many people are making commits? – prog_24 Mar 31 '16 at 14:08
  • Well, I don't see how that matters at this stage ... all I'm trying to do is merge from one branch to another ... – Yash Sampat Mar 31 '16 at 14:13
  • @PeterParker: thank you for your help, it was instrumental in getting through this problem ... :) – Yash Sampat Apr 01 '16 at 13:55

2 Answers2

8

Phew, haven't used SVN in a while... :)

But from what I can remember Branch locations should be the folder containing your branches folders (and not each individual branch folder).

You see, typically a SVN repo follows a standard naming convention and folder structure:

trunk/
branches/
  Feature_A2/
  Feature_A3/
tags/
  v1.01/
  v1.02/

and so on...

trunk is where the main development takes place, and branches are for features, long-term or risky projects, or for different stages (such as QA and pre-prod).

So, as far as I remember, Android Studio expects you to set Branch locations to branches folder. In your case I think it should be http://192.168.0.64/svn/.../Android/Feature.

Also, your trunk is not Feature_A2 - Feature_A2 is just another branch.
Although I can't see the content, I think http://192.168.0.64/svn/.../Android/Development might be your trunk.

Which shouldn't bother you much, since you don't have to merge to your trunk, you can also merge between branches (e.g. merge Feature_A3 into Feature_A2).

So, to recap:

  1. Although not mandatory, I recommend renaming your folders to match the conventions (you can easily do it by right clicking in Tortoise SVN, but only AFTER all teammates commit, otherwise merge will be a HELL for them).
  2. Try setting Branch locations to http://192.168.0.64/svn/.../Android/Feature
  3. And Trunk to http://192.168.0.64/svn/.../Android/Development (only if it indeed contains sources, similar to Feature_A2/3)
  4. Consider "tagging" your releases in a tags folder (it's pretty much just copying the trunk/branch folder to tags, but you have a command for that).

    If you do so, you can also add tags folder to Branch locations, that way you'll be able to compare your current source with any previous release (which is handy).

P.S: "unresolved conflicts" error can also mean you have unresolved conflicts (duh :)). Conflicts are are usually created when both you and a teammate change the same lines in file (or if he deletes a file you changed) and you update to get his changes.

SVN won't let you merge until you manually resolve these conflicts/changes.

You can find conflicts in the Version Control tab at the bottom, they'll be mark in red.
(But I don't think that was the problem in your case)


Let me know if that works for you!

Yoav Aharoni
  • 2,672
  • 13
  • 18
  • 1
    Many thanks for your absolutely correct answer! Thanks to you, I am able to merge from the IDE rather than the command line, which is what I wanted. It was indeed the folder containing all the branches collectively ... :) – Yash Sampat Apr 01 '16 at 13:30
2

I'm not an SVN expert, but I think you will need to change you directory structure. I believe that even though it is just a convention, svn uses the directory structure for merging of branches. So your directory Structure should be:

SVN
   /Android
      /branches
         /production
         /featureA2
         /featureA3
      /tags 
      /trunk
  /IOS
      /branches
         /production
         /featureA2
         /featureA3
      /tags 
      /trunk

Even though the TortoiseSVN Repo-browser will allow you to move your directories around, a lot of meta-data is stored on each directory and is used to handle the merge process, so you may have to start your repo again. See the subversion best practices guide and strategories for repository layout for more details on how to setup your repos. All that said, I would hesitate to rely on Android Studio's svn integration to do heavy lifting like merging of branches as (although most things in JetBrains tooling is fantastic) it's handling of SVN leaves a lot to be desired.

Kris Erickson
  • 33,454
  • 26
  • 120
  • 175
  • 1
    This is not true. SVN does not rely on a specific directory structure. It takes help from meta data stored in a property called "mergeinfo" but merging works without this as well. – Peter Parker Mar 26 '16 at 06:18
  • @KrisErickson: thank you for taking the time to answer. I will look into this further and get back to you ... :) – Yash Sampat Mar 26 '16 at 13:58