Appying a fix to both stable and development branches

Asked by Andrew Johnson

I'm migrating a project over from CVS, and am still learning to use Bazaar. The project has multiple active branches, and it is common for us to want to apply the same set of changes to more than one branch. I doubt that we're unique in that requirement, but I can't see anything in the Bazaar documentation that describes how to achieve this easily.

With CVS we did it by committing the changes on one branch and using 'cvs update -j <oldrev> -j <newrev> <file>' to apply those same changes to each file on the other branch. Of course it's not really that easy since you have to extract the old and new revision numbers individually for each file, but I wrote a Perl script which automates most of that. We gave up duplicating the log messages for the second commit, but I really don't like that since we now have lots of commits on our development CVS branch which just say something like "sync to stable branch."

I'm hoping this is something that Bazaar can help us do much better in the future, but I can't quite see how. I'd like to be able to create a task branch from from my stable series branch, develop and commit the fixes to that task branch, merge the task branch back into the stable series branch, then also merge the same changes into the development series branch (after making modifications to account for the differences between our stable and development series).

I'm told that darcs makes this kind of thing very easy to do, can someone explain the best way to achieve it using Bazaar?

Question information

Language:
English Edit question
Status:
Solved
For:
Bazaar Edit question
Assignee:
No assignee Edit question
Solved by:
John A Meinel
Solved:
Last query:
Last reply:
Revision history for this message
Best John A Meinel (jameinel) said :
#1

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andrew Johnson wrote:
> New question #94416 on Bazaar:
> https://answers.launchpad.net/bzr/+question/94416
>
> I'm migrating a project over from CVS, and am still learning to use Bazaar. The project has multiple active branches, and it is common for us to want to apply the same set of changes to more than one branch. I doubt that we're unique in that requirement, but I can't see anything in the Bazaar documentation that describes how to achieve this easily.
>
> With CVS we did it by committing the changes on one branch and using 'cvs update -j <oldrev> -j <newrev> <file>' to apply those same changes to each file on the other branch. Of course it's not really that easy since you have to extract the old and new revision numbers individually for each file, but I wrote a Perl script which automates most of that. We gave up duplicating the log messages for the second commit, but I really don't like that since we now have lots of commits on our development CVS branch which just say something like "sync to stable branch."
>
> I'm hoping this is something that Bazaar can help us do much better in the future, but I can't quite see how. I'd like to be able to create a task branch from from my stable series branch, develop and commit the fixes to that task branch, merge the task branch back into the stable series branch, then also merge the same changes into the development series branch (after making modifications to account for the differences between our stable and development series).
>
> I'm told that darcs makes this kind of thing very easy to do, can someone explain the best way to achieve it using Bazaar?
>
>

There are 2 ways to do it in bzr, cherrypicking and 'daggy' fixes.

1) Cherrypicking. Basically the same thing you did with cvs, except you
supply the revisions to be cherrypicked, and bzr figures out all the
files for you.

 bzr branch trunk a
 bzr branch trunk b
 bzr branch trunk c

 cd b
 bzr commit -m "feature b"
 bzr commit -m "shared feature"

 # I want that merged to a & c
 cd ../a
 # If you have a single revision to cherrypick, we offer
 bzr merge -c -1 ../b
 # Otherwise, supply a range, negative numbers start from the most
 # recent, with -1 being tip
 bzr merge -r 100..102 ../b
 # or
 bzr merge -r -4..-1 ../b

 bzr commit -m "cherrypicked the shared-feature change"

2) Daggy fixes. Basically, you make use of ancestry by committing shared
   features to an old revision which is an ancestor of all the branches
   you want to merge it to.

 bzr branch base integration1
 bzr branch base integration2
 ...
 # Hack and commit new (unrelated) code to integration1 and 2
 # Now I know I have a new feature, and I want to land it in both
 # branches
 bzr branch base feature-x # possibly with -r XXX to create an old base
 cd feature-x
 # hack commit, etc.
 cd ../integration1
 bzr merge ../feature-x
 bzr commit
 cd ../integration2
 bzr merge ../feature-x
 bzr commit

For more info on daggy fixes, you can read about it here:
http://www.monotone.ca/wiki/DaggyFixes/

(This wasn't written by us, but it holds true for about 90% of all DVCS.)

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksqkTEACgkQJdeBCYSNAAOLmgCgp5Jbc5/DnnYTRk+DtQy0Sk4Y
WqcAnjZhD9mzyb1l2pA3QIuuRzp7LN/T
=WXba
-----END PGP SIGNATURE-----

Revision history for this message
Andrew Johnson (anj) said :
#2

Thanks John A Meinel, that solved my question.