What do you think about cherry picking?

Shane Hathaway shane at hathawaymix.org
Thu Nov 29 22:48:52 MST 2007

Dave Smith wrote:
> My scenario is very similar to the one you describe, but backwards. I
> usually do a release, branch the code (in Subversion or CVS), and
> continue on with new development in the trunk, making only bug fixes
> (theoretically) in the branch. After branching, if a customer requests a
> change in the release, we fix it in the aforementioned release branch,
> which of course we usually want to merge into the trunk. For me the
> merge is almost always a manual process, except in the most trivial
> cases (which get more rare as the two code bases diverge over time).
> This seems like an extremely common scenario, and I've always been
> surprised at how hard it is to do. It ought to be trivial given the
> frequency of the task. Does your distributed source control system of
> choice make this easier?

Yes.  I've been doing this for a while with Mercurial.  Let's say I have
my source code in ~/devel and no release branch yet.  When I am ready to
make a stable branch (~/stable), I use:

  hg clone ~/devel ~/stable

Now I have two code bases with a common heritage.  When I commit a
change to ~/stable and want to pull that change into ~/devel, I type:

  cd ~/devel
  hg pull -u ~/stable

This may involve a merge operation, but Mercurial generally makes the
merging smooth and painless unless the code diverges too much.
Furthermore, Mercurial records the list of revisions pulled in, so
subsequent merges will not attempt to reapply them.  I can happily
continue coding in both branches.

Note that I chose to make the change in ~/stable first, allowing me to
use Mercurial's standard merge mechanisms.  If I had chosen to make the
change in ~/devel first, I would have to cherry-pick, which is not
nearly as simple.

CVS makes this process hard and error prone.  Subversion probably isn't
as bad as CVS in this regard, but ever since I started using Mercurial,
I've had no desire to dig deeper into Subversion.  Mercurial gets more
done with fewer commands.  I've heard git is similar.


More information about the PLUG mailing list