[PATCH 2 of 2] keyword: handle resolve to either parent

Augie Fackler raf at durin42.com
Mon Dec 22 14:52:02 CST 2014


On Sun, Dec 21, 2014 at 11:52:14PM +0000, Christian Ebert wrote:
> # HG changeset patch
> # User Christian Ebert <blacktrash at gmx.net>
> # Date 1419166979 0
> #      Sun Dec 21 13:02:59 2014 +0000
> # Node ID e7163a330a46fb540e9a04b865cc72103c9c8718
> # Parent  a43065a3286da13b13c52405d080230e5cf32002
> keyword: handle resolve to either parent

Sure, queued.

>
> Merged files are considered modified at commit time even if only 1 parent
> differs. In this case we must use the change context of this parent for
> expansion.
>
> The issue went unnoticed for long because it is only apparent until the next
> update to the merge revision - except in test-keyword where it was always
> staring us in the face.
>
> diff --git a/hgext/keyword.py b/hgext/keyword.py
> --- a/hgext/keyword.py
> +++ b/hgext/keyword.py
> @@ -264,8 +264,17 @@ class kwtemplater(object):
>              if util.binary(data):
>                  continue
>              if expand:
> +                parents = ctx.parents()
>                  if lookup:
>                      ctx = self.linkctx(f, mf[f])
> +                elif self.restrict and len(parents) > 1:
> +                    # merge commit
> +                    # in case of conflict f is in modified state during
> +                    # merge, even if f does not differ from f in parent
> +                    for p in parents:
> +                        if f in p and not p[f].cmp(ctx[f]):
> +                            ctx = p[f].changectx()
> +                            break
>                  data, found = self.substitute(data, f, ctx, re_kw.subn)
>              elif self.restrict:
>                  found = re_kw.search(data)
> diff --git a/tests/test-keyword.t b/tests/test-keyword.t
> --- a/tests/test-keyword.t
> +++ b/tests/test-keyword.t
> @@ -1062,13 +1062,13 @@ conflict: keyword should stay outside co
>    foo
>    >>>>>>> other: 85d2d2d732a5  - test: simplemerge
>
> -resolve to local
> +resolve to local, m must contain hash of last change (local parent)
>
>    $ hg resolve -t internal:local -a
>    (no more unresolved files)
>    $ hg commit -m localresolve
>    $ cat m
> -  $Id: m 800511b3a22d Thu, 01 Jan 1970 00:00:00 +0000 test $
> +  $Id: m 88a80c8d172e Thu, 01 Jan 1970 00:00:00 +0000 test $
>    bar
>
>  Test restricted mode with transplant -b
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list