Where I currently work we have a new branch of svn for each release cycle, so I need to work on multiple branches of the same project. This has caused me problems because sometimes I edit the file in the wrong branch and commit against the wrong branch which I want to avoid.
Currently I create a new module for each branch and remove the other module branch from the project to avoid the above problem. Can I avoid having to delete and add the module when I switch branches.
I have tried: Using contexts - I saved a context, swapped the module then saved another context but when I switch between the contexts they are the same it doesn't switch the module.
A nice solution would be to put each module on a sparate changelist
Forgot to mention this question has been posted here http://stackoverflow.com/questions/13572548/managing-multiple-branches-in-one-project-intellij#comment18610238_13572548 without a satisfactory answer.
Is this possible or should I raise a feature request?
The recommend solution has always been to create a project for each branch. But since that was the answer in the StackOverflow post you referenced, and for which you said the answer was not satisfactory, I suspect it is not what you are looking for
As an FYI, that is the solution I have used for years. It does take maybe 10 to 15 minutes to create the project for the branch and copy over shared settings in the .idea directory to the branch project. But once it is done, it is done. For me it works well. When I need to fix a bug on a branch I open the 'branch' project (closing the mainline project.) when done, I switch back to the mainline project. That way I am always focused on one task and one branch. On a few occasions I will have both open at the same time. But that can result in accidentally making a change in the wrong branch. That's a reason why I like two different projects. Personally I would not want multiple branches in the same (IDEA) project. Personally, I always like to create a brand new project from scratch for each branch. That way I always can go back to old branches. But I have seen some people simply have two or three projects. For example "mainline", "in-testing", "released". The they can simply check out the appropriate VCS branch code for each project. When a new VCS branch is released, the "released" project is update to use the appropriate VCS branch. Etc.
If you really really really want to do this, you can tyy the following. I've never tried it, so it may not work. Conceptually, I think it would work... Create a single project and then create module groups where each groups is a branch. (You can reference this old post I made that talks about module groups. In that post the person wanted multiple projects (i.e. work efforts) in one project (i.e IDEA project). But the concept is the same.) You would then have to define a scope (File > Settings > IDE Settings > Scope) for each module group so when you do searches and such, you can limit to the scope (i..e. branch) you are working on. IMHO, that is where it is easy to make a mistake. You forget to change the scope, you do a search, make a change, and commit - D'oh...wrong branch. An example scope definition is:
That includes just the src and test files. You could also add the library files if you want to have them available. You would also need to define a build form each branch/module-group.
As I mentioned to the OP in the thread I referenced above, if you use module-groups in that way, you are swimming up stream. I know that people like different work methodologies. And it is hard to change them. But IMHO you would be best to use the recommended solution. "Use the Force Luke"
As for opening a feature request... that is obviously an option. In the past when this feature has been request I think the response from JetBrains was that it was not practical because the entire framework of IDEA would have to change. A "project" being a single entity of work is a core concept in the architecture and so many things are based on or assume that concept. But it can't hurt to ask
I hope that helps.