�
�c@sddkZd�ZdS(i�Nc s'||jo|Snh�||g}h�x�o�|d}||�}|�|<|pd�|<|i�q0xN|D]F}||jp
||jo|Sn|�jo|i|�q}q}W|d|joAtg}|D]}|�|q��d�|<|i�q0q0W��fd���fd�}||�} ||�}
| i�}|
i�}y�x�|d|djoJx+|dD]}
|
|djo|
Sq�q�W|
i�}| i�}qu|d|djo|
i�}qu| i�}quWntj
odSnXdS(s�
return the least common ancestor of nodes a and b or None if there
is no such ancestor.
pfunc must return a list of parent vertices
i�iic3s��||fg}t�}xy|oqti|�\}}||joK|i|�||fVx0�|D] }ti|�||f�qkWqqWdS(N(tsettheapqtheappoptaddtheappush(tvertexthtseentdtntp(tdepthtparentcache(s%/sys/lib/python/mercurial/ancestor.pyt ancestors+s
c3s�dt�}}xd�|�D]V\}}||jo0|o||fVn|t|f�}}q|i|�qW||fVdS(N(tNoneRR(Rtsgtstgtv(R
(s%/sys/lib/python/mercurial/ancestor.pytgenerations6s
N(tpoptappendtmintnextt
StopIterationR(tatbtpfunctvisitRtplR
t_[1]RtxtytgxtgyR((RRR
s%/sys/lib/python/mercurial/ancestor.pytancestor
sR
3(RR#(((s%/sys/lib/python/mercurial/ancestor.pys<module>s
|