ó €ˆtPc@s•ddlmZddlmZdefd„ƒYZdefd„ƒYZdefd„ƒYZd efd „ƒYZd eefd „ƒYZ d S(iÿÿÿÿ(tnullrev(t_tbasedagcBsƒeZdZd„Zd„Zd„Zd„Zd„Zd d„Z d d„Z d„Z d „Z d „Z d „Zed „ZRS(sðgeneric interface for DAGs terms: "ix" (short for index) identifies a nodes internally, "id" identifies one externally. All params are ixs unless explicitly suffixed otherwise. Pluralized params are lists or sets. cCs d|_dS(N(tNonet_inverse(tself((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyt__init__scCs t‚dS(sset of all node idxsN(tNotImplementedError(R((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pytnodesetscCs t‚dS(slist of head ixsN(R(R((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pytheadsscCs t‚dS(slist of parents ixs of ixN(R(Rtix((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pytparents#scCs t‚dS(s1inverse DAG, where parents becomes children, etc.N(R(R((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pytinverse'scCs t‚dS(sV set of all ancestors of starts (incl), but stop walk at stops (excl) N(R(Rtstartststops((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyt ancestorset+scCs|jƒj||ƒS(sX set of all descendants of starts (incl), but stop walk at stops (excl) (R R(RR R((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyt descendantset1scCs t‚dS(sé subset of connected list of ixs so that no node has a descendant in it By "connected list" we mean that if an ancestor and a descendant are in the list, then so is at least one path connecting them. N(R(Rtixs((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pytheadsetofconnecteds7scCs |j|ƒS(s4return a list of (or set if given a set) of node ids(t _externalize(RR ((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyt externalize@scCs2|j|ƒ}t|tƒr(t|ƒSt|ƒS(s4return a list of (or set if given a set) of node ids(t_externalizeallt isinstancetsettlist(RRtids((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pytexternalizeallDs cCs |j|ƒS(s4return a list of (or set if given a set) of node ixs(t _internalize(Rtid((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyt internalizeKscCs5|j||ƒ}t|tƒr+t|ƒSt|ƒS(s4return a list of (or set if given a set) of node ids(t_internalizeallRRR(RRt filterunknownR((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pytinternalizeallOs N(t__name__t __module__t__doc__RRR R R RRRRRRRtFalseR (((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyR s           t genericdagcBs#eZdZdd„Zd„ZRS(s generic implementations for DAGscCs‹|rt|ƒptƒ}tƒ}t|ƒ}xT|r†|jƒ}||kr3||kr3|j|ƒ|j|j|ƒƒq3q3W|S(N(RRtpoptaddtextendR (RR Rtseentpendingtn((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyRZs     cCs^t|ƒ}|s|Sx5|D]-}x$|j|ƒD]}|j|ƒq3WqW|sZt‚|S(N(RR tdiscardtAssertionError(RRthdsR+tp((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyRes   N(R!R"R#RRR(((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyR%Ws trevlogbaseddagcBsMeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z RS(s!generic dag interface to a revlogcCs,tj|ƒ||_d|_||_dS(N(RRt_revlogRt_headst_nodeset(RtrevlogR((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyRss   cCs|jS(N(R3(R((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyRyscCs(|jdkr!|jƒ|_n|jS(N(R2Rt _getheads(R((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyR |scCs|jj|dS(Ni(R1tindex(RR ((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyRscCs+|jj}g|D]}||d^qS(Ni(R1R6(RRtidxti((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyRƒs cCsC|jj|ƒ}|tkr?t||jjtdƒƒ‚n|S(Ntnullid(R1trevRt LookupErrort indexfileR(RRR ((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyR‡s !cCs]|j}|rMgt|jj|ƒD]$}|dk r%|tkr%|^q%St|j|ƒS(N(R1tmaptnodemaptgetRRR(RRRtrltr((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyRŒs  "( R!R"R#RRR RRRR(((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyR0ps      t revlogdagcBsPeZdZd„Zd„Zd„Zd„Zdd„Zd„Z d„Z RS( sdag interface to a revlogcCs)tj||ttt|ƒƒƒƒdS(N(R0RRtxrangetlen(RR4((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyR—scCs,g|jjƒD]}|tkr|^qS(N(R1theadrevsR(RRA((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyR5šscCsz|j}|j}||}|d}|tkrY|d}|tkrO|gS||gS|d}|tkrv|gSgS(Nii(R1R6R(RR trlogR7trevdatatprevtprev2((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyR s          cCs(|jdkr!t|ƒ|_n|jS(N(RRtinverserevlogdag(R((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyR ¬sc CsÎ|j}|j}|r$t|ƒp*tƒ}tƒ}t|ƒ}x…|rÉ|jƒ}||krE||krE|j|ƒ||}x=ddgD],} || } | tkr“|j| ƒq“q“WqEqEW|S(Nii(R1R6RRR&R'Rtappend( RR RRFR7R)R*R:RGR8RH((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyR±s          c Cs“|s tƒS|j}|j}t|ƒ}xU|D]M}||}x:ddgD],}||}|tkrO|j|ƒqOqOWq2W|st‚|S(Nii(RR1R6RR,R-( RRRFR7RER:RGR8RH((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyRÂs        cCsg}t|j|ƒƒ}|jdtƒtƒ}x©|rß|jƒ}|dkrŒ| d}||krÜ|j|ƒ|j|ƒqÜq7|j| dƒ|g|j|ƒD]$}||kr±||kr±|^q±7}q7Wt |ƒt |ƒksþt ‚|S(s­linearize and topologically sort a list of revisions The linearization process tries to create long runs of revs where a child rev comes immediately after its first parent. This is done by visiting the heads of the given revs in inverse topological order, and for each visited rev, visiting its second parent, then its first parent, then adding the rev itself to the output list. treverseii( RRtsorttTrueRR&RKR'R RDR-(RRtsortedtvisittfinishedtcurR/((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyt linearizeÑs        )N( R!R"R#RR5R R RRRRS(((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyRB”s      RJcBs;eZdZd„Zd„Zd„Zd„Zd„ZRS(s:inverse of an existing revlog dag; see revlogdag.inverse()cCsNtj||j|jƒ||_i|_g|_t|jƒd|_dS(Ni( R0RR1R3t_origt _childrent_rootsRDt _walkfrom(Rtorig((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyRñs    c CsÄ|j}|j}|j}|jj}x||kr¶||}t}xJ|d|dgD]4}|tkr[|j|gƒj|ƒt }q[q[W|r©|j|ƒn|d8}q*W||_dS(Niii( RWRURVR1R6RNRt setdefaultRKR$( RtwalktoR:tcstrootsR7tdatatisrootRH((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyt_walktoøs       cCs|jtƒ|jS(N(R_RRV(R((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyR5 s cCsB|dkrgS||jkr/|j|ƒn|jj|gƒS(N(RRWR_RUR?(RR ((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyR s  cCs|jS(N(RT(R((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyR s(R!R"R#RR_R5R R (((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyRJîs     N( tnodeRti18nRtobjectRR%R0RBRJ(((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyt s J$Z