rebasing only a single changeset
L. David Baron
dbaron at dbaron.org
Thu Nov 27 01:43:56 UTC 2008
On Wednesday 2008-11-26 19:15 -0600, Matt Mackall wrote:
> On Wed, 2008-11-26 at 10:27 -0500, Benjamin Smedberg wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > Mozilla is going to cut a long-lived release branch shortly. We will be
> > cherry-picking individual changes from the trunk to the release branch. I
> > originally thought that the rebase extension would be perfect for this task:
> >
> > hg rebase -s revtocherrypick -t releasebranch
> >
> > But I forgot that rebase will not rebase the single revision I'm interested
> > in: it will only rebase entire branches.
> >
> > The transplant extension could be used for this, but doesn't do 3-way
> > merging (and the rebase extension is in general better designed). How hard
> > would it be to add "rebase a single revision" to the rebase extension?
>
> Actually, it's not a good match for cherry-picking, because the typical
> change to cherry-pick will not be rooted at a branch point. This is a
> little confusing but consider this graph:
>
> a-b-c-d-e <= devel
> \
> f-g-h <= stable
>
> If we want to copy just e onto the stable branch, we can't simply merge
> e onto h (which is how rebase does things). Merge is about combining the
> state of the entire project at e with the entire project at h, but
> really we're just interested in the delta from d to e and not in changes
> c and d.
It seems to me that the basic operation of merging can be seen as a
function with two nodes as inputs, merge2(e, h) using the example
above, or as a function with three nodes as inputs, where
merge2(e, h) == merge3(e, h, b), since b is the closest common
ancestor of e and h. Given that, isn't the act of cherry-picking
just using this merge3 function with a different base -- in this
case, merge3(e, h, d) ? (And then, since we're rebasing, giving the
resulting changeset only one parent.)
To put it slightly differently, what I think we want is to use a
graph that's like the graph above, except has some of the arrows
reversed (and ignoring a, since it doesn't matter):
d-e
\
c-b-f-g-h
and then rebase e onto h.
-David
--
L. David Baron http://dbaron.org/
Mozilla Corporation http://www.mozilla.com/
More information about the Mercurial
mailing list