[PATCH STABLE] graft: support grafting across renames (issue4028)

Yuya Nishihara yuya at tcha.org
Tue Jul 26 11:07:10 EDT 2016


On Mon, 25 Jul 2016 13:16:32 -0500, Gábor Stefanik wrote:
> # HG changeset patch
> # User Gábor Stefanik <gabor.stefanik at nng.com>
> # Date 1469470573 -7200
> #      Mon Jul 25 20:16:13 2016 +0200
> # Branch stable
> # Node ID 395d3fa2ac89fad199c99cc137bf801502292325
> # Parent  9c2cc107547fd701a7604349632f2f590366f17c
> graft: support grafting across renames (issue4028)
>
> Graft performs a merge with a false common ancestor, which must be taken into
> account when tracking renames. Compute the real common ancestor in this case,
> and track renames between the real and false common ancestors in reverse.

I don't know the detail of the copy tracing, I can't tell if this strategy
is correct.

Many tests fails with this patch.

> --- a/mercurial/copies.py
> +++ b/mercurial/copies.py
> @@ -327,13 +327,22 @@
>          return {}, {}, {}, {}
>      repo.ui.debug("  searching for copies back to rev %d\n" % limit)
>  
> +    # graft gives us a false common ancestor, we need to find a real one
> +    true_ca = ca
> +    if not (ca.descendant(c1) and ca.descendant(c2)):
> +        true_ca = c1.ancestor(c2)

It appears that ca.descendant(c1) doesn't work if c1 is a workingctx. And
ctx.descendant() won't be an instant operation.

>      for f in u1:
> -        checkcopies(c1, f, m1, m2, ca, limit, diverge, copy1, fullcopy1)
> +        checkcopies(c1, f, m1, m2, ca, limit, diverge, copy1a, fullcopy1a)
> +        checkcopies(c1, f, m1, m2, true_ca, limit, diverge, copy1b, fullcopy1b)
> +        copy1 = dict((set(copy1a.items()) & set(copy1b.items())) |
> +            (set([(y, x) for (x, y) in copy1a.items()])-
> +             set([(y, x) for (x, y) in copy1b.items()])))

I'm not sure if we can invert a dest-src dict which is keyed by dest. Also,
it smells in that copy1 is built from (x, y) dict and (y, x) dict.

And I guess checkcopies() isn't fast. If ca == true_ca, 2nd checkcopies()
call is redundant.


More information about the Mercurial-devel mailing list