This is an archive of the discontinued Mercurial Phabricator instance.

debugmergestate: make templated
ClosedPublic

Authored by martinvonz on Feb 13 2020, 1:37 AM.

Details

Summary

Our IntelliJ team wants to be able to read the merge state in order to
help the user resolve merge conflicts. They had so far been reading
file contents from p1() and p2() and their merge base. That is not
ideal for several reasons (merge base is not necessarily the "graft
base", renames are not handled, commands like hg update -m is not
handled). It will get especially bad as of my D7827. This patch makes
the output s a templated. I haven't bothered to make it complete
(e.g. merge driver states are not handled), but it's probably good
enough as a start.

I've done a web search for "debugmergestate" and I can't find any
indication that any tools currently rely on its output. If it turns
out that we get bug reports for it once this is released, I won't
object to backing this patch out on the stable branch (and then
perhaps replace it by a separate command, or put it behind a new
flag).

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.Feb 13 2020, 1:37 AM

Why can't we add templater support to debugmergestate instead?

Why can't we add templater support to debugmergestate instead?

Sorry, I should have explained that in the commit message. The reason I didn't was because the current command seems to try to make the output be true to the on-disk format. Maybe that's not something we care much about, so I can just rewrite it by defining a default template. I'll try that.

martinvonz retitled this revision from debugcommands: add templated command for reading the merge state for e.g. IDEs to debugmergestate: make templated.Feb 13 2020, 4:48 PM
martinvonz edited the summary of this revision. (Show Details)
martinvonz updated this revision to Diff 20202.
pulkit added a subscriber: pulkit.Feb 13 2020, 5:43 PM

Will be nice to add some release notes either in BC section or in features section stating debugmergestate now supports templates and can be used by scripts/editors.

Will be nice to add some release notes either in BC section or in features section stating debugmergestate now supports templates and can be used by scripts/editors.

Ah, good point, will do.
martinvonz updated this revision to Diff 20203.Feb 13 2020, 5:48 PM

Will be nice to add some release notes either in BC section or in features section stating debugmergestate now supports templates and can be used by scripts/editors.

Ah, good point, will do.

I did both :)

pulkit accepted this revision.Feb 13 2020, 6:45 PM
This revision is now accepted and ready to land.Feb 13 2020, 6:45 PM
This revision was automatically updated to reflect the committed changes.

I was worried that the new version might be crashing in some cases (I specifically worried about indexes out of range in the state list). To test that, I added hg debugmergestate before every hg resolve call in the test suite. That showed two different bugs. Feel free to de-queue this patch or I'll send updates later (maybe tomorrow). Sorry that I didn't think to test that before the patch got accepted.

I was worried that the new version might be crashing in some cases (I specifically worried about indexes out of range in the state list). To test that, I added hg debugmergestate before every hg resolve call in the test suite. That showed two different bugs. Feel free to de-queue this patch or I'll send updates later (maybe tomorrow). Sorry that I didn't think to test that before the patch got accepted.

I'll just de-queue the patch myself. I'll send a replacement for this one later.