[PATCH 1 of 5] revset: have `min` and `max` method of smartset works when empty

Matt Mackall mpm at selenic.com
Fri Mar 21 17:18:54 CDT 2014


On Fri, 2014-03-21 at 11:28 -0700, pierre-yves.david at ens-lyon.org wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at fb.com>
> # Date 1395367234 25200
> #      Thu Mar 20 19:00:34 2014 -0700
> # Node ID ad232d545933fc511feaeceb85ba43c4cb1d5415
> # Parent  170d6d591a7dbc09bfe1b509dfd8f39991e653a9
> revset: have `min` and `max` method of smartset works when empty
> 
> When empty `baseset` and `lazyset` had crashing `min` and `max` methods. They
> now return None when empty. Same as the other smart set do.

Why is this correct? I would think we would want it to behave like the
empty list it was replacing:

 >>> min([])
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
 ValueError: min() arg is an empty sequence

Instead, we'll get some surprise like this:

 repo[revs.min()] -> working context lolwut

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list