[PATCH 2 of 2] revset: new predicates to find key merge revisions

Yuya Nishihara yuya at tcha.org
Mon Mar 7 09:59:10 EST 2016


On Fri, 4 Mar 2016 12:12:05 -0800, Simon Farnsworth wrote:
> # HG changeset patch
> # User Simon Farnsworth <simonfar at fb.com>
> # Date 1457121724 0
> #      Fri Mar 04 20:02:04 2016 +0000
> # Node ID 18378f0a3eeac6331fc24c1525c7e4dccba27251
> # Parent  37fe1f9d08245f7540cb6137c312ae30dbcde688
> revset: new predicates to find key merge revisions

> + at predicate('conflict(type,[pattern])')
> +def conflict(repo, subset, x):
> +    """The type revision for any merge conflict matching pattern.
> +    See :hg:`help patterns` for information about file patterns.
> +
> +    type should be one of "ancestor", "other" or "local", for the three-way
> +    merge ancestor, the "other" tree, or the "local" tree.
> +
> +    The pattern without explicit kind like ``glob:`` is expected to be
> +    relative to the current directory and match against a file exactly
> +    for efficiency. If pattern is omitted, all conflicts are included.
> +    """
> +    # i18n: "conflict" is a keyword
> +    l = getargs(x, 1, 2, _('conflict takes one or two arguments'))
> +    t = getstring(l[0], _("conflict requires a type"))
> +    if t not in ["ancestor", "other", "local"]:
> +        msg = _('conflict file types are "ancestor", "other" or "local"')

It appears we use the term "base", "other", and "local" in "help merge-tools".

> +    s = set()
> +    for f in files:
> +        if t == "ancestor":
> +            s.add(ms.ancestorchangectx(f).rev())
> +        elif t == "local":
> +            s.add(ms.localfilectx(f).introrev())
> +        elif t == "other":
> +            s.add(ms.otherfilectx(f).introrev())

Nit: "other" and "ancestor" raised exception with V1 mergestate.


More information about the Mercurial-devel mailing list