[PATCH 1 of 2 evolve-ext-V4] evolve: make prune respect allowunsable

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Jun 18 12:35:30 CDT 2015



On 06/18/2015 10:30 AM, Pierre-Yves David wrote:
>
>
> On 06/17/2015 01:39 PM, Laurent Charignon wrote:
>> # HG changeset patch
>> # User Laurent Charignon <lcharignon at fb.com>
>> # Date 1432759785 25200
>> #      Wed May 27 13:49:45 2015 -0700
>> # Node ID adb791429c95d8ca9df9fa427b97afae14ebfc6e
>> # Parent  c02cdb97ebfa29c0df40417db9e36f31f2977b4b
>> evolve: make prune respect allowunsable
>>
>> Before this patch, the prune command was performing the same way
>> regardless
>> of the value of experimental.evolution.
>> With this patch if the configuration does not allow unstability, prune
>> won't
>> create instability.
>>
>> diff --git a/hgext/evolve.py b/hgext/evolve.py
>> --- a/hgext/evolve.py
>> +++ b/hgext/evolve.py
>> @@ -1928,6 +1928,10 @@ def cmdprune(ui, repo, *revs, **opts):
>>           if not precs:
>>               raise util.Abort('nothing to prune')
>>
>> +        if not obsolete.isenabled(repo, obsolete.allowunstableopt):
>> +            if len(repo.revs("(%ld::) - %ld", revs, revs)) != 0:
>> +                raise util.Abort(_("cannot prune in the middle of a
>> stack"))
>
> Do not use `if len(x) !=0` just use `if x:`. In addition to be more
> concises, this is also more efficient, smartset (stuff returned by
> revsets) can have a faster __nonzero__ method than __len__ since you do
> not have to compute the whole result to know it is not empty (while you
> need the whole result for the len).
>
> I've fixed it and pushed to the evolve repo.

Actually I've not, because the tests fails...

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list