( )⚙ D8925 revert: remove dangerous `parents` argument from `cmdutil.revert()`

This is an archive of the discontinued Mercurial Phabricator instance.

revert: remove dangerous `parents` argument from `cmdutil.revert()`
ClosedPublic

Authored by martinvonz on Aug 11 2020, 1:23 AM.

Details

Summary

As we found out the hard way (thanks to spectral@ for figuring it
out!), cmdutil.revert()'s parents argument must be
repo.dirstate.parents() or things may go wrong. We had an extension
that passed in the target commit as the first parent. The hg split
command from the evolve extension seems to have made the same mistake,
but I haven't looked carefully.

The problem is that cmdutil._performrevert() calls
dirstate.normal() on reverted files if the commit to revert to
equals the first parent. So if you pass in ctx=foo and
parents=(foo.node(), nullid), then dirstate.normal() will be
called for the revert files, even though they might not be clean in
the working copy.

There doesn't seem to be any reason, other than a tiny performance
benefit, to passing the parents around instead of looking them up
again in cmdutil._performrevert(), so that's what this patch does.

Diff Detail

Repository
rHG Mercurial
Branch
default
Lint
No Linters Available
Unit
No Unit Test Coverage

Event Timeline

martinvonz created this revision.Aug 11 2020, 1:23 AM
pulkit accepted this revision.Aug 11 2020, 5:41 AM
This revision is now accepted and ready to land.Aug 11 2020, 5:41 AM