[PATCH 4 of 4] revset: changed getset so that it can return a lazyset

Matt Mackall mpm at selenic.com
Mon Feb 10 17:22:48 CST 2014


On Mon, 2014-02-10 at 16:49 -0800, Lucas Moscovicz wrote:
> # HG changeset patch
> # User Lucas Moscovicz <lmoscovicz at fb.com>
> # Date 1390951154 28800
> #      Tue Jan 28 15:19:14 2014 -0800
> # Node ID 55a68ea5907fe7b3f45ea44e87818b03fa9553d7
> # Parent  ecb4171110b4f2a9df166ec4a3087ded6577f857
> revset: changed getset so that it can return a lazyset
> 
> Tested manually on getset if the return type is a lazyset to let it pass
> instead of converting it to a baseset. This is temporal until everything is
> implemented to work with lazysets and there is no need to convert it back to a
> baseset.

> diff --git a/mercurial/revset.py b/mercurial/revset.py
> --- a/mercurial/revset.py
> +++ b/mercurial/revset.py
> @@ -195,7 +195,10 @@
>  def getset(repo, subset, x):
>      if not x:
>          raise error.ParseError(_("missing argument"))
> -    return baseset(methods[x[0]](repo, subset, *x[1:]))
> +    s = methods[x[0]](repo, subset, *x[1:])
> +    if isinstance(s, lazyset):
> +        return s
> +    return baseset(s)

As I tried to explain earlier, this is the wrong approach. It is a
duck-typing failure because we have to look at the types rather than
treat everything as though it were the same.

How do we fix this? Easy: every function in methods must be changed to
always return a baseset-compatible type. Then this code can be changed
to:

+    return methods[x[0]](repo, subset, *x[1:])


I've queued the first three patches in this series, thanks.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list