[PATCH stable] revset: fix O(n**2) behaviour of bisect() (issue3381)

Patrick Mézard patrick at mezard.eu
Thu Apr 19 10:47:14 CDT 2012


Le 19/04/12 17:41, Kevin Bullock a écrit :
> On Apr 18, 2012, at 11:28 PM, Bryan O'Sullivan wrote:
> 
>> # HG changeset patch
>> # User Bryan O'Sullivan <bryano at fb.com <mailto:bryano at fb.com>>
>> # Date 1334809655 25200
>> # Node ID 2057572031e922253988d9315f9ee04df37b829d
>> # Parent  55982f62651f1974fcd91197f1c4801cc98a48f2
>> revset: fix O(n**2) behaviour of bisect() (issue3381)
>>
>> diff -r 55982f62651f -r 2057572031e9 mercurial/revset.py
>> --- a/mercurial/revset.pyWed Apr 18 01:20:16 2012 +0300
>> +++ b/mercurial/revset.pyWed Apr 18 21:27:35 2012 -0700
>> @@ -291,7 +291,8 @@
>>     - ``ignored``            : csets ignored due to DAG topology
>>     """
>>     status = getstring(x, _("bisect requires a string")).lower()
>> -    return [r for r in subset if r in hbisect.get(repo, status)]
> 
> Wouldn't just flipping the list comprehension clauses fix it?
> 
>     return [r for r in hbisect.get(repo, status) if r in subset]

revset functions should preserve the input "subset" order, when possible.

--
Patrick Mézard


More information about the Mercurial-devel mailing list