[PATCH V2] merge: add `internal:dumpjson` tool to `resolve`, which outputs conflict state

Phillip Cohen phillip at phillip.io
Wed Mar 22 15:32:29 EDT 2017


> It doesn't make sense to use the formatter to dump a single object. Perhaps
> formatter._jsonifyobj() can be a public utility function.


That's a good idea. If there are no objections I'll send that out,
either as the first change in the next version or a isolated change
(probably the former so I can depend on it here).

On Fri, Mar 17, 2017 at 7:08 AM, Yuya Nishihara <yuya at tcha.org> wrote:
> On Tue, 7 Mar 2017 11:40:59 -0800, Phil Cohen wrote:
>> # HG changeset patch
>> # User Phil Cohen <phillco at fb.com>
>> # Date 1488915535 28800
>> #      Tue Mar 07 11:38:55 2017 -0800
>> # Node ID bbce62e3790220f19e7b37160a2f8351b7461272
>> # Parent  91e86a6c61c0c6a3b554eefeba9060000311aa29
>> merge: add `internal:dumpjson` tool to `resolve`, which outputs conflict state
>
>> +    if opts.get('tool', '') == "internal:dumpjson":
>> +        fm = ui.formatter('resolve', {'template': 'json'})
>> +        ms = mergemod.mergestate.read(repo)
>> +        m = scmutil.match(repo[None], pats, opts)
>> +        wctx = repo[None]
>> +
>> +        paths = []
>> +        for f in ms:
>> +            if not m(f):
>> +                continue
>> +
>> +            val = ms.internaldump(f, wctx)
>> +            if val is not None:
>> +                paths.append(val)
>> +
>> +        fm.startitem()
>> +        fm.write('conflicts', '%s\n', paths)
>> +        fm.end()
>
> It doesn't make sense to use the formatter to dump a single object. Perhaps
> formatter._jsonifyobj() can be a public utility function.
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list