[PATCH] adjustlinkrev: search ancestors from oldest to newest

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Jan 14 19:41:16 CST 2015



On 01/14/2015 04:02 PM, Martin von Zweigbergk wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz at google.com>
> # Date 1421273570 28800
> #      Wed Jan 14 14:12:50 2015 -0800
> # Node ID 5b82ace74f36afe0ec6d44d17489b844724cd708
> # Parent  b2358bc1407c19007b0e7852262f61d5fe7a8f83
> adjustlinkrev: search ancestors from oldest to newest
>
> When searching for the oldest ancestor that introduced a file's node
> id, we search in the order we get from changelog.ancestors(), which is
> in descending order (newest to oldest). For file modifications, it is
> safe to search backwards like this, but for when the file has been
> temporarily removed, the same nodeid can appear twice. Make sure we
> search from oldest to newest so we get the right result in this case
> too.

The recent linkrev change aims at getting the situation better. The code 
still struggle with multiple introduction of the same content. Take the 
oldest over the newest is kind of arbitrary and does not significantly 
improves the situation.

What we needs now to real tracking of all file revision introduction 
somewhere on disk, such adjustement is probably not a win.

(this is a gentle rejection of this patch unless you can make a better 
case for it)

> diff -r b2358bc1407c -r 5b82ace74f36 mercurial/context.py
> --- a/mercurial/context.py	Tue Jan 13 15:08:55 2015 -0500
> +++ b/mercurial/context.py	Wed Jan 14 14:12:50 2015 -0800
> @@ -23,7 +23,7 @@
>   _newnode = '!' * 21
>
>   def _adjustlinkrev(repo, path, filelog, fnode, srcrev, inclusive=False):
> -    """return the first ancestor of <srcrev> introducting <fnode>
> +    """return the oldest ancestor of <srcrev> introducting <fnode>
>
>       If the linkrev of the file revision does not point to an ancestor of
>       srcrev, we'll walk down the ancestors until we find one introducing this
> @@ -42,7 +42,8 @@
>       fr = filelog.rev(fnode)
>       lkr = filelog.linkrev(fr)
>       # check if this linkrev is an ancestor of srcrev
> -    anc = cl.ancestors([srcrev], lkr, inclusive=inclusive)
> +    anc = list(cl.ancestors([srcrev], lkr, inclusive=inclusive))
> +    anc.reverse()

Turning a smart object into a lis: meh.

>       if lkr not in anc:

And making a membership testing in that list: nope, nope, nope.


-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list