ó žēƒQc@s]ddlZddlZddlmZd„Zd„Zd„Zdefd„ƒYZdS(i’’’’N(tnullrevcs‘t|tƒst|ƒ}nt|kr1tƒSt|ƒdkrG|S‡fd†}‡fd†}||ƒ}t|ƒdkr‡|S||ƒS(s· Returns the common ancestors of a and b that are furthest from a root (as measured by longest path). pfunc must return a list of parent vertices for a given vertex. ics%dt|ƒ>d}dgt|ƒd}x(t|ƒD]\}}d|>||}tƒ}t|ƒ}}t|ƒd} x‘| dkr |r | } | d8} || sĀqn|| } | |kr=|d8}| |kr=|j| ƒ| |O} | |kr:|d8}|dkr7t| gƒSq:q=n| |krĮxш| ƒD]d} || } | tkrxqVn| dkr›| || <|d7}qV| | krV|| c| O}|||ˆ| ƒD]0} | tkrqn|| }|| }}|| krÆ| d|| <|| kr2|| cd7<| }|| <|r¬||cd8<||dkr©||=q©q¬q2q| |dkr|| B}||krŪqn||| <|j|dƒ||cd7<||cd8<||dkr2||=q2qqW|| cd8<|| dkr”|| =q”q”Wt|ƒdkrzgSd‰x|D]}ˆ|O‰q‡Wt‡fd†|DƒƒS(Niic3s%|]\}}ˆ|@r|VqdS(N((t.0R R (tk(s6/sys/lib/python2.7/site-packages/mercurial/ancestor.pys }s(RRtsortedtappendRRt setdefaultR(RR tcounttdepthRtmappingR R tbRRtdvRRtdptnspR(R(Rs6/sys/lib/python2.7/site-packages/mercurial/ancestor.pytdeepestGsh       !            (t isinstanceRRR(Rt orignodesRR"R ((Rs6/sys/lib/python2.7/site-packages/mercurial/ancestor.pyt ancestors s .8 c s<||kr|St||gƒ\}}i‰||g}i‰x÷|r9|d}g||ƒD]}|tkr`|^q`}|ˆ|<|s„dˆ|<|jƒqCxF|D]>}||ksŹ||krĪ|S|ˆkr¬|j|ƒq¬q¬W|d|krCtg|D]}ˆ|^qƒdˆ|<|jƒqCqCW‡‡fd†‰‡fd†}||ƒ}||ƒ} |jƒ} | jƒ} y˜x‘tr!| d| dkrļx&| dD]} | | dkr¶| Sq¶W| jƒ} |jƒ} q‘| d| dkr| jƒ} q‘|jƒ} q‘WWntk r7dSXdS(s: Returns the common ancestor of a and b that is furthest from a root (as measured by longest path) or None if no ancestor is found. If there are multiple common ancestors at the same distance, the first one found is returned. pfunc must return a list of parent vertices for a given vertex i’’’’iic3s˜ˆ||fg}tƒ}xu|r“tj|ƒ\}}||kr|j|ƒ||fVx/ˆ|D] }tj|ˆ||fƒqiWqqWdS(N(RtheapqtheappopRtheappush(tvertexthRtdR R(Rt parentcache(s6/sys/lib/python2.7/site-packages/mercurial/ancestor.pyR%¬s     c3s‚dtƒ}}x`ˆ|ƒD]R\}}||krb|rI||fVn|t|fƒ}}q|j|ƒqW||fVdS(N(tNoneRR(R)tsgtstgR(R%(s6/sys/lib/python2.7/site-packages/mercurial/ancestor.pyt generations·s N( RRtpopRtmintnexttTruet StopIterationR-( taRRtvisitR)RtplR1txtytgxtgyR((R%RR,s6/sys/lib/python2.7/site-packages/mercurial/ancestor.pytgenericancestor…sP    +     +        c CsÜt|ƒ}t|ƒ}|s"gS|s8|jtƒntt|ƒt|ƒƒ}|j|ƒ}|j|ƒ|j|ƒg}xIt|tdƒD]5}|s„Pn||kr|j|ƒx;||ƒD]-} |j| ƒ|j| ƒ|j| ƒqĖWq•n||kr*|j |ƒ|} |} n||kr•|} |} nq•| j|ƒxr||ƒD]d} | tkrwqb| | ks| |kr¹|j| ƒ|j| ƒ|j| ƒqb| j| ƒqbWq•W|j ƒ|S(s\Return all the ancestors of revs that are not ancestors of bases. This may include elements from revs. Equivalent to the revset (::revs - ::bases). Revs are returned in revision number order, which is a topological order. revs and bases should both be iterables. pfunc must return a list of parent revs for a given revs. i’’’’( RRRRt intersectiontdifference_updatetxrangetremovetdiscardRtreverse( trevstbasesRt revsvisitt basesvisittstartt bothvisittmissingtcurrRt thisvisitt othervisit((s6/sys/lib/python2.7/site-packages/mercurial/ancestor.pytmissingancestorsŲsP                  t lazyancestorscBs)eZded„Zd„Zd„ZRS(icCs||j|_||_||_||_g|D] }| ^q.|_tj|jƒ|rlt|ƒ|_ n tƒ|_ dS(sÖCreate a new object generating ancestors for the given revs. Does not generate revs lower than stoprev. This is computed lazily starting from revs. The object supports iteration and membership. cl should be a changelog and revs should be an iterable. inclusive is a boolean that indicates whether revs should be included. Revs lower than stoprev will not be generated. Result does not include the null revision.N( t parentrevst _parentrevst _initrevst_stoprevt _inclusivet_containsvisitR&theapifyRt _containsseen(tselftclREtstoprevt inclusivetrev((s6/sys/lib/python2.7/site-packages/mercurial/ancestor.pyt__init__*s    ccsŹtƒ}|j}|jrAx|D] }|Vq"W|j|ƒn|j}|j}tj|ƒ}xa|rÅxT||jƒƒD]@}||kr~||kr~|j |ƒ|j |ƒ|Vq~q~WqeWdS(seGenerate the ancestors of _initrevs in reverse topological order. If inclusive is False, yield a sequence of revision numbers starting with the parents of each revision in revs, i.e., each revision is *not* considered an ancestor of itself. Results are in breadth-first order: parents of each rev in revs, then parents of those, etc. If inclusive is True, yield all the revs first (ignoring stoprev), then yield all the ancestors of revs as when inclusive is False. If an element in revs is an ancestor of a different rev it is not yielded again.N( RRSRUtupdateRRRTtutiltdequetpopleftRR(RYRRER]RQR[R8tparent((s6/sys/lib/python2.7/site-packages/mercurial/ancestor.pyt__iter__Hs          c Csį|j}||krtS|j}|j}|j}tj}tj}t}xŽ|rÜ|d |krÜ| rÜxi|||ƒ ƒD]T} | |ks| |kr„qn||| ƒ|j | ƒ| |krt}qqWqOW|S(s5Test whether target is an ancestor of self._initrevs.i( RXR5RRRVRTR&R'R(tFalseR( RYttargetRRQR8R[R'R(t targetseenRc((s6/sys/lib/python2.7/site-packages/mercurial/ancestor.pyt __contains__fs$       !  (t__name__t __module__ReR^RdRh(((s6/sys/lib/python2.7/site-packages/mercurial/ancestor.pyRP)s ( R&R`tnodeRR%R>ROtobjectRP(((s6/sys/lib/python2.7/site-packages/mercurial/ancestor.pyts  z S Q