Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move bugfixes across branches in DVCS?

If we discover bug in some branche we fix it (check New release on picture). But also we interesting in moving this fix to Old release and Main development branch:

a-->b-->c              (Old release)
|    
A-->B-->C-->D           (Main release)
    |
    1-->2-->bugfix-->4  (New release)

svn remember in svn:merge properties (from svn 1.6, 2009) which revision merged to which branches. So next time if you merge region of revisions previously merged revisions was skipped from merge patch.

How deal with modern DVCS?

I need make plain patch and apply it to each branches or there are exist some help from DVCS?

Note: I can not just merge New branche to Main as previous changesets move also to Main branche.

Rebase also not possible as New release come to many developers.

I interesting in answer for named braches schema and for multirepository schema.

PS. Andy suggest find common parent to all branches for which bug have affect, update to it, apply fix to the bug and move fix to affected branches.

By updating to old changeset and making changes you create new branch. I recommend create named branch (name it as bugID), so later you can easy back to it.

There are problem on finding common parent to all branches in which we have interest to fix bug.

First solution (that suggest Andy) is using $ hg/git/bzr blame and carefully check output for all affected files. This involve first fix bug on some newest changeset before you find with blame what changeset introduce a bug. Then you need rebase fix (patch) to common parent changeset.

Another solution is using $ hg/git/bzr bisect (you can also manually perform updates to find first revision in which bug introduced). This can be expansive but more true solution as allow populate bugfix to any branches in which bug present.

I think it is better first find first BAD changeset and then fix a bug, instead of first fix a bug and then find first BAD changeset (except case when you already know how fix bug). Also having a diff that introduce can help in understanding why it occur.

PPS. With bugs it is clear which branch effected to allow merge changes to any effected branch.

Interesting question come if ask how backport feature from development branch to release branch. As you can see you must commit feature changesets starting with changeset that before release branch. But when you develop feature you can don't know where you need backport feature. With svn:merge VCS remember for you all backports. How about DVCS?

like image 679
gavenkoa Avatar asked Jul 15 '11 15:07

gavenkoa


1 Answers

You could:

  1. Find common parent. Thanks to Novelocrat for this step.
    git merge-base branch1 branch2 branch3 ...

  2. Checkout the common parent
    git checkout A

  3. create new branch to fix bugs on
    git checkout -b bugFix

  4. Make bug fixes and commit them to bugFix branch

  5. Checkout branch that needs the bug fix
    git checkout branchToApplyFixTo

  6. Merge the bugFix into the branch
    git merge bugFix

like image 161
Andy Avatar answered Oct 24 '22 06:10

Andy