This is an archive of the discontinued Mercurial Phabricator instance.

fbamend: autorestack children for simple rebases
AcceptedPublic

Authored by marco.leogrande on Dec 27 2017, 8:23 PM.
Tags
None
Subscribers

Details

Reviewers
quark
Group Reviewers
Restricted Project
Summary

Today, if you run 'hg amend' while in the middle of a stack of
commits, it amends the commit and leaves the top of the stack
behind. Users then have to run 'hg amend --restack' or 'hg restack' to
bring the old top of the stack onto the new version of the commit.

Add heuristic code so that an automatic restack can be performed if
amending a commit did not change its manifest, nor did it leave behind
a dirty working copy. This optimization can be avoided by providing
the --no-rebase commandline option.

Fix the existing tests that relied on the previous behaviour (so their
original intent is kept), and add new ones to cover the new heuristic.

Diff Detail

Repository
rFBHGX Facebook Mercurial Extensions
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

Herald added a reviewer: Restricted Project. · View Herald TranscriptDec 27 2017, 8:23 PM
quark requested changes to this revision.Dec 27 2017, 9:03 PM
quark added a subscriber: quark.

This looks pretty good. I just have a small request about the user-facing message.

hgext3rd/fbamend/__init__.py
278–279

Since this is user-facing and not everyone knows what "manifest" is. It's more friendly to avoid the terminology. Power users may want to disable the feature (ex. if they want to amend multiple commits and then just use restack once to fix them all) but it's not obvious how. Maybe something like "(auto-rebasing descendants, use --no-rebase to disable this)"

Note "children" and "descendants" are different in hg. See hg help revset for details.

tests/test-fbamend-restack.t
873–875

hg debugbuilddag '+3' is a more efficient way to create multiple commits. You can use hg update 'tip^' in the next line to update to the second commit. That said, I'm fine with just using mkcommit.

899

debugbuilddag creates empty commits that requires explicit "add" if you changed "b". That's doable by using hg amend -A b here.

This revision now requires changes to proceed.Dec 27 2017, 9:03 PM
marco.leogrande marked 3 inline comments as done.Dec 27 2017, 9:29 PM
quark accepted this revision.Dec 27 2017, 11:33 PM

Great!

This revision is now accepted and ready to land.Dec 27 2017, 11:33 PM