views:

1021

answers:

11

Hi. We have a client (who has a client, who has a client) who is driving us mad with change requests to a code base (in PHP). Our first response was to just work in a main trunk in SVN, but the client often comes back and requests that a certain change needs to get pushed to the live servers ASAP. On the other hand, other changes get reduced in priority suddenly, which originally came grouped with other changes (seemingly).

We are thinking of using a branch for every change request. Is this mad? What other solutions might work?

Thanks!

Edit: This is a really hard question to choose the correct answer for. Thanks to everybody for your great answers.

Edit: I know that the best answer I chose was not particularly popular. I too wanted to find a technical solution to this problem. But now I think that if the client wants software with features that can be deployed in a modular fashion... this problem should not be solved in our use of the version control system. It would have to be designed into the software.

Edit: Now it's almost a month later and my coworker/client has convinced me that multiple branches is the way to go. This is not just due to the client's insanity, but also based on our need to be able to determine if a feature is "ready to go" or "needs more work" or whatever. I don't have the SVN with me, but we merge using the advice from the SVN Cookbook: you merge the branch from the revision it was branched to the head revision.

Also, using this system, we merge all branches at some point and that becomes the new QA and then live build. Then we branch from that.

Last Edit (Perhaps): Months later, this system is still working out for us. We create branches for every ticket and rarely have problems. On the other hand, we do try to keep things separate as far as what people are working on...

Two Years Later: We use GIT now, and now this system is actually quite reasonable.

+10  A: 

What about creating a branch for your client's live version, a branch for your new development and a branch for your ongoing changes.

Work in the new development branch when you're not being inundated with tasks.

Work in the ongoing changes branch when you're fixing all that fun stuff they keep driving you crazy with. When you've got a fix, merge it to the "live" branch and to the "new development" branch.

That way your client's distribution is in its own world, your new development continues on (and can be merged whenever you need it) and your maintenance is also captured.

We work in a new development branch, then each time we decide to make a patch, we branch the trunk and then send that patch off for Q/A. If it goes back and forth a while, we work in that branch to fix those issues merging back to the trunk where necessary to ensure everything is in sync. If something came back long after the fact which needed to be addressed in a previous version, we can always fix it back in that branch, then again, just merge it into the trunk.

Mat Nadrofsky
I like that answer a lot. I'm curious to see what other peope come up with. Thanks!
Yar
Right on. Glad to help. Always good to get a host of responses and figure out what works best for you!
Mat Nadrofsky
Refinement/Reminder: Tags make remembering revision numbers a moot point, so Tag each merge to the main development branch. Tag releases, too.Also, with this structure, you could leave the "live" version on the trunk - `trunk` is just a convention, after all.
Ken Gentle
@ Ken: Very true. I should have mentioned that!
Mat Nadrofsky
+4  A: 

A branch for every change request sounds like overkill and maybe some trouble later.

try to group the change requests into logical areas so that you can see that a particular set of changes has a logically related effect on the application. Create branches for these.

I think that the real answer to the question though is to fix the client. You need to make it clear via a contract that these arbitrary change request is going to cost them money and it might slow them down. If this keeps up, your svn repository will be the least troubling aspect of the project.

Vincent Ramdhanie
It does cost them money and slow them down. Why would I want to fix them? For my own sanity? That's why I have technology, and when that isn't enough, I also have Zen meditation.
Yar
I take that back. Now I think you may be right: if you want to build a modular software system, you don't do it from your version control system. Thanks for your answer.
Yar
Though I'm leaving this as best answer (what does that mean?), we've actually gone to using branches for all changes and the results have been quite nice.
Yar
I think the number of branches may be a per project or per team decision really and not something that can be broadly stated. In our team I have found that too many branches may actually cause more problems...so we try to limit it. But I am not surprised that you are finding many branches working fine for you.
Vincent Ramdhanie
+3  A: 

Branch per change request, with the corresponding increase in cost to the client for the additional management, is a fine approach for this problem.

It will cost you more, in terms of time, resources available to be working on other features, etc, but with a lot of unrelated changes, or project features that get stalled or canceled, it is probably one of the better approaches.

This is really SCM system agnostic - but Subversion can certainly do what is needed.

Ken Gentle
That's what we thought too, but I think some of the other answers that are coming up are more interesting, especially the structure proposed by Mat Nadrofsky. I agree that the particular SCM doesn't matter much.
Yar
And now, much later, I think you're right... but this is subjective, I suppose.
Yar
+15  A: 

Perhaps Subversion here is not the best tool for the job. Although creating all these branches is cheap in SVN, re-merging them can become time-consuming and painfull.

If you have a look at GIT instead of SVN, you will find a version control system which is more powerfull at merging in general. Added to that, it has the specific feature of "cherry picking". That is, single commits can be easily "picked" from one development tree and added to another (the live branch). Also, it is easy and convenient in GIT to merge several commits into one single one (you can even add to a specific commit from another tree).

So building up single-feature commits and then cherry-picking them could be the solution for you.

ypnos
interesting. we'll have to check GIT out. In fact the term cherry-picking already came up in our discussions before posting the question here. THANKS!
Yar
Also Subversion supports cherry-picking: http://svnbook.red-bean.com/en/1.5/svn.branchmerge.advanced.html#svn.branchmerge.cherrypickingI can't compare SVN cherrypicking implementation with the GIT one because I'm not a GIT user :)
Davide Gualano
Yeah, hope it didn't sound like Cherry Picking can not be done in SVN. I haven't tried GIT yet, so I don't know its advantages.
Yar
git is just very powerful at merging, which is a key feature for its decentralized model. Pushing with git normally "just works" whereas merging branches in SVN was always a little bit complicated, and often painfull, to me.
ypnos
Cool, thanks for the dialog, Ypnos.
Yar
by the way, months later this turns to be very true. We're using GIT on 50% of the projects and VERY happy with it.
Yar
Glad to hear this! Thank you for the feedback!
ypnos
+2  A: 

Branch per tested, working change.
Tag per version release.
Develop in trunk.
Repeat.

:)

adam
Aren't tags really branches?
Yar
Under subversion at least, they're basically the same under the hood - the main difference is in how they're viewed (a snapshot at a particular time vs. an branch of development)
Tim Whitcomb
Thanks, both Tim and Adam.
Yar
A: 

When doing lot of rapid changes in the "live" branch of a project, you need to have a solid code review process to reduce the chance of breaking it. The code review must be done before doing the check-in; and keep away the core development from that branch.

Once the change is approved, you can check-in the change (and/or merge from you working branch) and create a new "tag" once it's done.

Max
+1  A: 

At my workplace we have the following system:

  • Stable branch: This is where tested and verified stable code goes.
  • Maintainance branch: This is where fixing bugs in stable is done. When things are verified to work it is merged down to stable branch.
  • Project specific branches: Each sub-project in our product has one branch. At a specified time during the year all the projects to be included in this year's release are merged into the "Release branch". This is so all the merging and stuff isn't done a week before release.
  • Release branch: This is where all the messy development of the current release is happening after the sub-projects have been merged. Merged with stable after release is done.
Nailer
Thanks. Interesting system. How many developers are you, if you don't mind the question...?
Yar
About 80 worldwide including product specialists and domain experts. About half are developers.
Nailer
Excellent, thanks for your response. If only SO had a way of telling me that you had responded...
Yar
+2  A: 

Have a branch for every RELEASE. Combine as many changes into a single release as make sense - having more branches is generally good, you can combine them easily in most cases, breaking them apart is a little more tricky.

Having a branch for every release means you also have a branch for what's currently on production (or what's just ABOUT to be released when releases are pending after the merge but before the actual deployment).

That's what we do anyway.

MarkR
+6  A: 

The scenario explained by the thread opener is an example of the feature branches pattern: http://svnbook.red-bean.com/en/1.5/svn.branchmerge.commonpatterns.html#svn.branchmerge.commonpatterns.feature

They are very usefule when you have to keep the main development line (the trunk) stable and you have to develop lots of features that potentially could break the main line.

The downside is that you have to keep the various branches in sync with the trunk: while a branch for feature A is in development, a branch for feature B can have reached a stable status and get closed and merged in the trunk: in this situation, you have to merge the changes introduced by the B branch from the trunk to the A branch. So, it's a good habit to merge often the branches with the trunk to avoid the problematic situation of a unique big merge at the end of the branch life with lots of conflicts to track down and resolve.

Davide Gualano
Thanks Davide, you're the first person to hit on what I suspected. Merging (with SVN and perhaps with everything else) is not pleasant and not easy.
Yar
Sometimes merging is a headache, but sometimes it's not: it strongly depends on the sizes of the changes and on what parts of the code are affected by the changes. Usually Subversion can hadle the changes automatically and in the correct way, but it's not always that easy.
Davide Gualano
I would add to this answer to never develop in trunk. This assures trunk is always stable.
antispam
A: 

When estimated hours are more than 8, use a branch.

Ludwig Wensauer
Why 8? Though I do like quantitative rules.
Yar
Is 8 really ONE_WORKING_DAY? Maybe we should make a global constant?
Yar
+1  A: 

With git, I do make a branch for every little change, and I love it!

hasen j