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

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Mar 21 17:27:26 CDT 2014



On 03/21/2014 03:18 PM, Matt Mackall wrote:
> 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:

This is "Correct" in the sense that it is what the implementation of 
other smart set are already doing

>   >>> 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

I agree the current behavior (we are aligning to) sound bad.

I'll redo this series, moving code toward the raise Value error version.

-- 
Pierre-Yves


More information about the Mercurial-devel mailing list