This is an archive of the discontinued Mercurial Phabricator instance.

rebase: filter out descendants of divergence-causing commits earlier
ClosedPublic

Authored by martinvonz on Mar 22 2021, 1:36 PM.

Details

Summary

hg rebase treats obsolete commits differently depending what has
happened to the commit:

  1. Obsolete commit without non-obsolete successors: Skipped, and a note is printed ("it has no successor").
  2. Obsolete commit with a successor in the destination (ancestor of it): Skipped, and a note is printed ("already in destination").
  3. Obsolete commit with a successor in the rebase set: The commit and its descendants are skipped, and a note is printed ("not rebasing <commit> and its descendants as this would cause divergence"), unless allowdivergence config set.
  4. Obsolete commit with a successor elsewhere: Error ("this rebase will cause divergences"), unless allowdivergence config set.

Before this patch, we did all those checks up front, except for (3),
which was checked later. The later check consisted of two parts: 1)
filtering out of descendants, and 2) conditionally printing message if
the allowdivergence config was not set. This patch makes it so we do
the filtering early.

A consequence of filtering out divergence-causing commits earlier is
that we rebase commits in slightly different order, which has some
impact on tests.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

martinvonz created this revision.Mar 22 2021, 1:36 PM
martinvonz edited the summary of this revision. (Show Details)Mar 23 2021, 2:06 AM
martinvonz planned changes to this revision.Mar 24 2021, 12:37 AM

I may make some changes to this patch. I keep getting confused about the two different divergence cases. Despite have stared at this code for days, I still don't know which case is which (i.e. I'm not sure my description of cases (3) and (4) is correct).

I may make some changes to this patch. I keep getting confused about the two different divergence cases. Despite have stared at this code for days, I still don't know which case is which (i.e. I'm not sure my description of cases (3) and (4) is correct).

I think I actually got the description right. I've updated the series a bit and it's ready for review again.

This revision was not accepted when it landed; it landed in state Needs Review.
This revision was automatically updated to reflect the committed changes.