Pergunta

I recently came across an MSDN article about branching and merging and SCM: Branching and Merging Primer - Chris Birmele.

In the article they say 'big bang merge' is a merging antipattern:

Big Bang Merge — deferring branch merging to the end of the development effort and attempting to merge all branches simultaneously.

I realized that this is very similar to what my company is doing with all of the development branches that are produced.

I work at a very small company with one person acting as the final review + trunk merge authority. We have 5 developers (including me), each of us will be assigned a separate task/bug/project and we will each branch off the current trunk (subversion) and then perform the development work in our branch, test the results, write documentation if necessary, perform a peer review and feedback loop with the other developers, and then submit the branch for review + merge on our project management software.

My boss, the sole authority on the trunk repository, will actually defer all of the reviews of branches until a single point in time where he will perform reviews on as much as he can, some branches will be thrown back for enhancements/fixes, some branches will merge right into trunk, some branches will be thrown back because of conflicts, etc.

It's not uncommon for us to have 10-20 active branches sitting in the final review queue to be merged into trunk.

We also frequently have to resolve conflicts in the final review and merge stage because two branches were created off the same trunk but modified the same piece of code. Usually we avoid this by just rebranching off trunk and re-applying our changes and resolving the conflicts then submitting the new branch for review (poor mans rebase).

Some direct questions I have are:

  • Are we exhibiting the very anti-pattern that was described as the 'big bang merge'?
  • Are some of the problems we're seeing a result of this merge process?
  • How can we improve this merge process without increasing the bottleneck on my boss?

Edit: I doubt my boss will loosen his grip on the trunk repository, or allow other devs to merge to trunk. Not sure what his reasons for that are but I don't really plan on bringing the topic up because it's been brought up before and shot down rather quickly. I think they just don't trust us, which doesn't make sense because everything is tracked anyway.

Any other insight into this situation would be appreciated.

Foi útil?

Solução

Some suggestions:

  • There is nothing wrong in having a lot of feature or bugfix branches as long as the changes done in each branch are small enough you can still handle the resulting merge conflicts in an effective manner. That should be your criterion if your way of working is ok, not some MSDN article.

  • Whenever a branch is merged into trunk, the trunk should be merged into all open development branches ASAP. This would allow all people in the team to resolve merge conflicts in parallel in their own branch and so take some burden from the gatekeeper of the trunk.

  • This would work way better if the gatekeeper would not wait until 10 branches are "ready for merging into trunk" - resolving merge conflicts from the last trunk integrations always needs some time for the team, so it is probably better to work in interwoven time intervals - one integration by the gatekeeper, one re-merge by the team, next integration by the gatekeeper, next re-merge by the team, and so on.

  • To keep branches small, it might help to split larger features into several smaller tasks and develop each of those tasks in a branch of its own. If the feature is not production ready until all subtasks are implemented, hide it from production behind a feature toggle until all subtasks are completed.

  • Sooner or later you will encounter refactoring tasks which affect many files in the code base - these have a high risk of causing a lot merge conflicts with many branches. Those can be handled best by communicating them clearly in the team, and make sure to handle them exactly as I wrote above: by integrating them first into all dev branches before reintegration, and by splitting them up into smaller sub-refactorings.

  • For your current team size, having a single gatekeeper may still work. But if your team will grow in size, there is no way around having a second gatekeeper (or more). Note I am not suggesting to allow everyone to merge into trunk, but that does not mean only your boss is capable of doing this. There are probably one or two senior devs who could be candidates for doing the gatekeeper's job, too. And even for your current team's size, a second gatekeeper could make it easier for your team to integrate to the trunk more often and earlier, or when your boss is not available.

Outras dicas

Are we exhibiting the very anti-pattern that was described as the 'big bang merge'?

Sounds like it.

Are some of the problems we're seeing a result of this merge process?

Definitely

How can we improve this merge process without increasing the bottleneck on my boss?

At my company, every dev has the ability to merge. We assign a Merge Request to another dev, go through the review/feedback/update cycle until both parties are satisfied. Then the reviewer merges the code.

10-20 branches waiting to get merged is a sign that your process is flawed. If we had that many, all dev work would stop until it was cleared up.

This is essentially how a lot of open source projects work, including most notably the Linux kernel, which has a lot more branches in flight than you do at any given time. The typical way to avoid big bang merges in these projects is to create another branch (or multiple branches) for continuous integration. This is the branch you use to make sure your changes work together with your colleagues, and it gets periodically rebased onto the trunk when the gatekeeper gets around to doing reviews.

Optionally, you can use this branch to combine several of your own pull requests into one big cohesive request for your boss to review. Linus Torvalds typically gets pull requests that have been integrated two or more levels deep, and can have a size on the order of, for example, a complete new filesystem driver.

I agree with both Doc Brown but I also see another antipattern:

My boss, the sole authority on the trunk repository, will actually defer all of the reviews of branches until a single point in time where he will perform reviews on as much as he can, some branches will be thrown back for enhancements/fixes, some branches will merge right into trunk, some branches will be thrown back because of conflicts, etc.

In my humble there are some management antipatterns:

  1. He/she is the single choke point constraining the velocity of the team. Your bus factor is 1. The theory of constraints say that you should put your effort in improving the slowest part of chain.
  2. Your manager is making your feedback cycle slower and reducing the agility of your team. Can you release every week?
  3. Merges complexity grow exponentially with the amount of code. It is better to make 10 merges with 100 lines than 1 of 1000 lines. That is just one of the reasons why you should do it ASAP
  4. If you detect a failure in the trunk you will do it latter in time. Which of the several branches was the problematic one
  5. Decissions should be made by those who have more knoledge about them. Who knows more in this case? I bet that the developers that made the code.
  6. You can't fix a bug in production if your manager is on holydays.
  7. You are redoing work and throwing back branches. This is a waste of time. The time it is waiting to reach production is also waste.

Recomendations:

  • Your manager needs to delegate responsability to the team. You need to show that the team is mature, professional. Make clear that they can trust in the team
  • Implement some review method. May be you need the aproval of two other team members.
  • May be using SVN is making it harder. Give Git a try and see if it helps you. Even more. If you use GitHub you can use the Pull Request mechanism so that a merge requires certain votes.
  • Read and share information about agile practices, continous integration and DevOps.

When you do feature work in separate branches, you can't easily do any integration testing until one of the branches is merged to trunk and pulled into the other feature branches. In my experience, this is the main problem with the Big Bang Merge anti-pattern. Ideally, you would do feature work, test it in the feature branch, merge it into trunk, and at that point you are done with the feature. If it hasn't been merged, you have to revisit it each time something else is merged into trunk before it. The pain of this anti-pattern is that you have a lot of integration-type bugs showing up at the end of the development cycle.

So you have 20 branches. Branch 1 is just merged. Then the developer of branch 2 has to merge branch 1 into their branch to be able to merge into main without conflict, then merges. Then the developer of branch 3 has to merge branch 1 and branch 2 into their branch to be able to merge into main without conflict, then merges.

Exercise for the reader: Write a program that prints my complete post :-)

This is madness. You will be spending an incredible amount of time merging.

Given the way you are working and that your boss is a responsible control freak, branching itself seems to be the problem. Rather than creating a branch for every feature, have each developer commit his feature in parts, directly into the trunk. This puts the burden of integration on the developer in multiple smaller steps (win-win). Gate keeper can keep up with tracking smaller changes over a longer period earlier in the development cycle and still be the master reviewer.

Branching itself is something you do not want to do unless you have a very good reason to do it or you have no other option. You are small enough to keep things in sync more tightly, which will be easier and safer.

Licenciado em: CC-BY-SA com atribuição
scroll top