Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/site-packages/mercurial/dagutil.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


��Pc@s�ddlmZddlmZdefd��YZdefd��YZdefd��YZd	efd
��YZdeefd��YZ	d
S(i�(tnullrev(t_tbasedagcBs�eZdZd�Zd�Zd�Zd�Zd�Zd
d�Z	d
d�Z
d�Zd	�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.pytancestorset+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.pytexternalize@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.pytinternalizeKscCs5|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	RR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(RRtdiscardtAssertionError(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.pyR�scCs+|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(R1trevRtLookupErrort	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�scCs�|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|s�t�|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��|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'RRDR-(RRtsortedtvisittfinishedtcurR/((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyt	linearize�s 			
)N(R!R"R#RR5RR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_R5RR(((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyRJ�s				N(
tnodeRti18nRtobjectRR%R0RBRJ(((s5/sys/lib/python2.7/site-packages/mercurial/dagutil.pyt<module>	sJ$Z

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].