[Insight-developers] The wonders of cherry picking

Bill Lorensen bill.lorensen at gmail.com
Wed Jul 13 23:37:50 EDT 2011


Folks,

If you are a frequent gerrit reviewer then please read on.

First, I need to thank Brad L for suggesting that I start cherry
picking from gerrit rather than cloning. My first reaction to his
suggestion was "I don't want to learn another new git thing..." Sorry
Brad, I was wrong, you were right.

Cherry-picking applies the changes from a gerrit topic to your current branch.

Here was the old way I did gerrit reviews.

To review topic foo I would
1) git checkout master
2) git pullall
3) make (now my master is up-to-date)
4) copy/paste the gerrit clone line for topic foo
5) git rebase master (to see if there would be conflicts with the
current head of master)
6) make (many files may be rebuilt)
7) ctest
8) git checkout master
9) make (many files may be rebuilt to bring my build back to master)

If topic foo's git parent happened to be an older version of ITK, the
clone of  foo would touch many files that had nothing to do with the
topic and result in many files being rebuilt.

With cherry picking I now:
1) git checkout master
2) git pullall
3) make
4) git checkout -b foo (yes, you need to do this)
5) copy/paste the cherry-pick line from gerrit (you may discover
conflicts here and resolve them)
6) make (only the files that changed in the topic will be rebuilt)
7) ctest
8) git checkout master
9) make (only the files that were affected by the topic will be rebuilt)

For example, let's say you are reviewing a topic that changed a few
files in Filtering/ImageIntensity. And that this topic was created 2
weeks ago. If you clone it, you will be taken back two weeks and many
files will need to be recompiled. If you cherry-pick, only programs
that use those few files will be recompiled. And, if you cloned, and
when you go back to master, you  will need to recompile all programs
that rely on files changed in the past two week. If you cherry-picked,
only programs dependent on those few topic files will be recompiled.

Luis and I experienced the joy of cherry picking during our recent
gerrit-athon. It permitted us to review many topics without massive
rebuilds for each topic.

Pick some cherries next time you do a gerrit review,

Bill


More information about the Insight-developers mailing list