So far we've learned about elementary branches for maintaining changes apart from a primary development branch and development branches for coordinating asynchronous work on a single project (see Elementary Branches – Maintaining Private Changes and Development Branches – The star-merge Style of Cooperation).
In this chapter, we'll briefly describe a third kind of branch that's useful when a project consists of multiple "forks" – multiple, equally primary branches.
Let's suppose, somewhat abstractly, that Alice and Bob's mainline has grown quite large:
mainline -------- base-0 patch-1 .... patch-23 patch-24 patch-25 ... patch-42
At some point, perhaps because some controversy has emerged over
choices made in the
mainline, a new developer, Derick, declares
a fork and starts his own branch:
mainline derick -------- ------ base-0 ------> base-0 patch-1 ' .... ' patch-23 ----' patch-24 patch-25 ... patch-42
We already know that Derick can use
replay to keep
current with the mainline, but what he doesn't want to? What if
Derick wants the changes in
patch-42, but none of the
patch-23 changes from the
Derick can apply specific changes from the
mainline by specifying the
exact revision he wants, rather than just specifying a version:
% cd ~/wd % tla get hello-world--derick--0.1 derick % cd derick % tla replay -A firstname.lastname@example.org \ hello-world--mainline--0.1--patch-23 % tla replay -A email@example.com \ hello-world--mainline--0.1--patch-42 % tla missing -A firstname.lastname@example.org \ hello-world--mainline--0.1 patch-24 patch-25 ... patch-41 % tla logs -A email@example.com \ hello-world--mainline--0.1 base-0 patch-1 ... patch-22 patch-23 patch-42
Cherrypicking changes in this manner isn't necessarily easy or even
practical. It depends, for example, on the
mainline changes being
"clean changesets" (see Using commit Well – The Idea of a Clean Changeset in Exploring Changesets).
Nevertheless, for some projects, especially those characterized by lots of "forks", this technique can be useful.
Learning Note: Multiple revisions may be replayed with a single
command, simply by giving all of them on the command line at once. The
replay command also has a
--list option which can useful for
cherrypicking many changes at once. If you find yourself replaying
specific revisions often, you should take a look at the
tla replay --help.