Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

version control: moving a bug fix/code enhancement around feature development

I have a workflow question related to Mercurial (possibly applicable to other DVCS).

The repo is set up using the typical default/stable setup.

You're tasked with building a new feature and expect it to take some time (month+). While working on this feature, you come across a bug that you think should be fixed and applied to production sooner than later. Or perhaps, you notice some code that could be documented better.

My assumption is that you make the fix in default and then switch over to stable and make the fix again (by hand or by applying a patch). Is that correct or should you immediately switch to stable, do the change there and then merge stable into default?

Using a patch seems to make more sense to me. You can make a commit specifically for the bug fix and apply that patch at your convenience. I mean if the bug isn't too nasty, there is no need for urgency and breaking your flow. Right?

So, how do you handle this situation?

Thanks

like image 486
jbarreiros Avatar asked Jan 13 '11 17:01

jbarreiros


People also ask

What do you mean by bug fixes?

A bug fix is a change to a system or product designed to handle a programming bug/glitch. Many different types of programming bugs that create errors with system implementation may require specific bug fixes that are successfully resolved by a development or other IT team.


1 Answers

You can go back to the branch point (revision B), fix the bug there (revision X) and then merge the fix into both branches (M1 and M2):

-----B--o----o---M1----o---> stable
     |          /
     |---------X   bugfix
     |          \
     \--o---o----M2----o-----> feature

This way you can get your fix in each branch with normal hg merge operations; no patching, transplanting or MQ'ing required.

Taking the same idea a step further: you could instead go back to the revision that introduced the bug in the first place. By using this as the base for the fix, you'll be sure that you can merge your fix into any branch that contains the bug.

like image 79
Wim Coenen Avatar answered Oct 14 '22 19:10

Wim Coenen