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

Yuya Nishihara yuya at tcha.org
Fri Mar 17 10:08:47 EDT 2017


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.


More information about the Mercurial-devel mailing list