Mercurial > hg
comparison hgext/histedit.py @ 45375:8c466bcb0879
revert: remove dangerous `parents` argument from `cmdutil.revert()`
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.
Differential Revision: https://phab.mercurial-scm.org/D8925
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 10 Aug 2020 21:46:47 -0700 |
parents | 4a503c1b664a |
children | 47d10ade5bc4 |
comparison
equal
deleted
inserted
replaced
45374:bd56597b2254 | 45375:8c466bcb0879 |
---|---|
633 return commitfunc | 633 return commitfunc |
634 | 634 |
635 | 635 |
636 def applychanges(ui, repo, ctx, opts): | 636 def applychanges(ui, repo, ctx, opts): |
637 """Merge changeset from ctx (only) in the current working directory""" | 637 """Merge changeset from ctx (only) in the current working directory""" |
638 wcpar = repo.dirstate.p1() | 638 if ctx.p1().node() == repo.dirstate.p1(): |
639 if ctx.p1().node() == wcpar: | |
640 # edits are "in place" we do not need to make any merge, | 639 # edits are "in place" we do not need to make any merge, |
641 # just applies changes on parent for editing | 640 # just applies changes on parent for editing |
642 ui.pushbuffer() | 641 ui.pushbuffer() |
643 cmdutil.revert(ui, repo, ctx, (wcpar, node.nullid), all=True) | 642 cmdutil.revert(ui, repo, ctx, all=True) |
644 stats = mergemod.updateresult(0, 0, 0, 0) | 643 stats = mergemod.updateresult(0, 0, 0, 0) |
645 ui.popbuffer() | 644 ui.popbuffer() |
646 else: | 645 else: |
647 try: | 646 try: |
648 # ui.forcemerge is an internal variable, do not document | 647 # ui.forcemerge is an internal variable, do not document |