[PATCH] merge: add resolve --prep, which outputs conflicted comparison files

Durham Goode durham at fb.com
Fri Feb 24 18:42:34 EST 2017



On 2/24/17 3:25 PM, Jun Wu wrote:
> Excerpts from Durham Goode's message of 2017-02-24 15:18:40 -0800:
>> On 2/23/17 2:57 PM, Jun Wu wrote:
>>> Congratulations on your first patch to the list!
>>>
>>> But I think we have better ways to achieve the same goal that we may prefer
>>> them to this patch.
>>>
>>> 1) Better way to provide conflicted file contents - in-python merge tools
>>>
>>>   From a high-level, the patch tries to solve the problem:
>>>
>>>     - Get all paths and file contents involved in merge conflict resolution
>>>       in an efficient way.
>>>
>>>   We have "--list" and "--tool" already to fetch the data in a less efficient
>>>   way. I'm not a big fan of a new flag doing what we can do today.
>>>
>>>   I think a better to achieve the "efficient" goal is to make "--tool"
>>>   accept Python functions, just like what we do for hooks. If the signature
>>>   of the Python function accepts file contents directly, we can even avoid
>>>   writing temporary files - even more efficient than this patch.
>>
>> While that way may be more generic, and potentially more efficient in
>> some cases, it puts a larger burden of understanding on the consumer.
>> They would have to learn about Mercurial internals (or at least the api
>> for the hook), write a python script, and package that script into their
>> deployment.  Given that Mercurial already has knowledge of what data
>> merge tools need, I think it's reasonable to just have an interface that
>> prints that data for simple consumption.
>
> That shouldn't be an issue if we ship the Python merge function that
> generates the format they want - what they need is to just put a single line
> of config, like "merge-tool=somemod:jsonexport"

Maybe I don't understand your proposal.  The current merge-tools are 
invoked once per file.  Would this python merge-tool be invoked in some 
other way where it's given the full conflict state at the beginning then 
it can do what it wants?  So we'd special case python merge tools to be 
a little different?  We could just define a internal merge tool called 
'internal:json' or something and skip the whole extensibility thing.

Also, how does the merge tool communicate to the caller the json 
results? Write it to a file? Or does the merge tool have the ability to 
print to stdout?

>
>> If we want to get rid of the extra flag, we could just make this data
>> appear in the normal json output.  So 'hg resolve --list --all -T json'
>> would contain the same data as 'hg resolve --prep --all -T json'. It
>> changes the behavior of --list a bit, depending on if json is enabled or
>> not, but at least there's no new UI surface area.
>
> With the Python merge tool approach, there won't be an additional flag.
>


More information about the Mercurial-devel mailing list