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

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


��c@sddlmZmZmZmZddlmZddlmZddl	m
Z
ddlmZm
Z
ddlmZmZddlmZddlmZdd	lmZdd
lmZddlZddlZddlZddlZddlmZmZmZdd
lm Z da!d�Z"dedfde
dfdedfdedfdedfdedfdedfdedfdedfg	Z#de
fdefgZ$d�Z%d�Z&de'fd��YZ(de'fd ��YZ)e*e*d!�Z+dS("i�(tNoRepotMissingTooltSKIPREVtmapfile(tconvert_cvs(tdarcs_source(tconvert_git(tmercurial_sourcetmercurial_sink(t
svn_sourcetsvn_sink(tmonotone_source(tgnuarch_source(t
bzr_source(t	p4_sourceN(thgtutiltencoding(t_tasciicCs<t|t�r|jtd�S|jd�jtd�SdS(Ntreplacesutf-8(t
isinstancetunicodetencodet
orig_encodingtdecode(ts((s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pytrecodestcvst
branchsorttgittsvnRt
sourcesorttdarcstmtntgnuarchtbzrtp4c
Csg}|rK|gtD]}|d^qkrKtjtd�|��nxmtD]e\}}}y-|sw||kr�||||�|fSWqRttfk
r�}	|j|	�qRXqRW|js�"|D]}	|jd|	�q�Wntjtd�|��dS(Nis"%s: invalid source repository types%s
s%%s: missing or unsupported repository(	tsource_convertersRtAbortRRRtappendtquiettwrite(
tuitpathttypetrevt
exceptionsRtnametsourcetsortmodetinst((s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pyt
convertsource1s)	
cCs�|rE|gtD]}|d^qkrEtjtd�|��nx�tD]�\}}y$|sn||kr{|||�SWqLtk
r�}|jtd�|�qLtk
r�}tjd|��qLXqLWtjtd�|��dS(Nis'%s: invalid destination repository typesconvert: %s
s%s
s%s: unknown repository type(tsink_convertersRR'RRtnoteR(R+R,R-RR0tsinkR3((s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pytconvertsink@s)tprogresssourcecBs,eZd�Zd�Zd�Zd�ZRS(cCs(||_||_||_d|_dS(Ni(R+R1t	filecountt	retrieved(tselfR+R1R:((s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pyt__init__Ns			cCsM|jd7_|jjtd�|jd|d|j�|jj||�S(Nis
getting filestitemttotal(R;R+tprogressRR:R1tgetfile(R<tfileR.((s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pyRATscCs|jj|�S(N(R1t	lookuprev(R<R.((s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pyRCZscCs|jjtd�d�dS(Ns
getting files(R+R@RtNone(R<((s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pytclose]s(t__name__t
__module__R=RARCRE(((s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pyR9Ms			t	convertercBsbeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�ZRS(
cCs�||_||_||_||_i|_i|_d|_t||�|_	|jj�}|r�t
jj|�r�|j
|�n|jd�r�|j
|jd��|jj�|_ntj|jd��|_t||jd��|_dS(Nt	authormapt	splicemapt	branchmap(R1tdestR+toptstcommitcachetauthorsRDt
authorfileRtmaptosR,texistst
readauthormaptgettcommontparsesplicemapRJRK(R<R+R1RLt
revmapfileRMRP((s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pyR=as 							cCs�|}t�}i}x�|r�|jd�}||ks||jkrNqn|j|�|jjtd�t|�dtd��|j|�}g||<x/|j	D]$}||j
|�|j
|�q�WqW|jjtd�d�|S(s`Return a mapping that identifies the uncommitted parents of every
        uncommitted changeset.itscanningtunitt	revisionsN(tsettpopRQtaddR+R@RtlentcachecommittparentsR(RD(R<theadstvisittknownRatntcommittp((s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pytwalktree|s 		
+
cCs�x�|�D]�}||krc|jj|jj||��s
|jjtd�|�q
q
ng}xn||D]b}|jj|jj||��r�qtn||kr�tj	td�|��n|j
|�qtW|||<q
WdS(s�A splicemap redefines child/parent relationships. Check the
        map contains valid revision identifiers and merge the new
        links in the source graph.
        s8splice map revision %s is not being converted, ignoring
sunknown splice map parent: %sN(tsortedRLt	hascommitRQRUR+twarnRRR'R((R<RaRJtctpcRg((s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pytmergesplicemap�s!!cs �fd�}�fd�}�fd�}�fd�}�fd�}|dkrc|�}na|dkr{|�}nI|dkr�|�}n1|d	kr�|�}ntjtd
�|��|��\}	}
g}i}x|
r�|
�}
|
j|
�|j|
�x�|	j|
g�D]�}||krig�|D]}|�jkrA|^qA||<ny||j|
�Wn<tk
r�tjtd�t|�t|
�f��nX||s$|
j	d|�d||<q$q$Wq�t|�t��krtjtd
���n|S(snReturn an ordering such that every uncommitted changeset is
        preceded by all its uncommitted ancestors.cs�t|�}t�}i}g}x�|r�|jd�}||krKq$n|j|�|j|g�t}xP||D]D}|�jkr�|j|�t}n|j|g�j|�qyW|s$|j|�q$q$W||fS(sReturn a (children, roots) tuple where 'children' maps parent
            revision identifiers to children ones, and 'roots' is the list of
            revisions without parents. 'parents' must be a mapping of revision
            identifier to its parents ones.
            i(	RiR\R]R^t
setdefaulttFalseRQR(tTrue(RaRctseentchildrentrootsRet	hasparentRg(R<(s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pytmapchildren�s&		

	csdg���fd�}|S(sIf the previously converted revision has a child in the
            eligible revisions list, pick it. Return the list head
            otherwise. Branch sort attempts to minimize branch
            switching, which is harmful for Mercurial backend
            compression.
            csG|d}x,|D]$}�d�|kr|}PqqW|�d<|S(Ni((tnodestnextRe(Ratprev(s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pytpicknext�s


N(RD(Rz(Ra(Rys9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pytmakebranchsorter�s	cs"�fd���fd�}|S(sSource specific sort.cs�j|jS(N(RNtsortkey(Re(R<(s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pyt<lambda>�scst|d��dS(Ntkeyi(Ri(Rw(tkeyfn(s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pyRz�s((Rz(R<(Rs9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pytmakesourcesorter�scs"�fd���fd�}|S(sClose order sort.cs$d�j|jk�j|jfS(NRE(RNtextraR|(Re(R<(s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pyR}�scst|d��dS(NR~i(Ri(Rw(R(s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pyRz�s((Rz(R<(Rs9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pytmakeclosesorter�scs+i���fd���fd�}|S(sSort revisions by date.cs4|�kr,tj�j|j��|<n�|S(N(Rt	parsedateRNtdate(Re(tdatesR<(s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pytgetdate�s cs-tg|D]}�|�|f^q
�dS(Ni(tmin(RwRe(R�(s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pyRz�s((Rz(R<(R�R�s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pytmakedatesorter�sRtdatesortR t	closesortsunknown sort mode: %ss cycle detected between %s and %sisnot all revisions were sortedN(RR'RtremoveR(RURQt
ValueErrorRtinsertRDR_(R<RaR2RvR{R�R�R�RzRstactivesRtpendingsReRlRg((RaR<s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pyttoposort�sF!
	

3
 
cCs{|j}|rw|jjtd�|�t|d�}x/|jD]$}|jd||j|f�qBW|j�ndS(Nswriting author map file %s
sw+s%s=%s
(RPR+tstatusRtopenROR*RE(R<RPtofiletauthor((s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pytwriteauthormap"s	"cCsTt|d�}x4|D],}|j�}|s|jd�rDqny|jdd�\}}Wn@tk
r�td�}|jj|||j�f�qnX|j�}|j�}|j	j
|�d|fkrtd�}|jj|||f�||j	|<qntd�}|jj
|||j	||f�qW|j�dS(Ntrt#t=is,ignoring bad line in author map file %s: %s
smapping author %s to %s
s5overriding mapping for author %s, was %s, will be %s
(R�tstript
startswithtsplitR�RR+RktrstripRORURDtdebugR�RE(R<RPtafiletlinet	srcauthort	dstauthortmsgtm((s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pyRT+s*

 
(cCs_|jj|�}|jj|j|j�|_|jj|j|j�|_||j|<|S(N(R1t	getcommitRORUR�RKtbranchRN(R<R.Rf((s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pyR`Gs

cCs�|j|}|jj|�}t|t�ra|tkrCt}n
|j|}||j|<dS|\}}g}|jr�xW|jD]I}||jkr�|j|�n|j	|j||j|j
f�q�Wn|jj|j
|�yY|j
|}	|jjtd�|	|f�g|	D]}
|jj|
|
�^q#}	Wn.tk
rug|D]}|d^q\}	nXt|j|jt|��}|jj|||	|||j�}
|j�|jj||
�|
|j|<dS(Nsspliced in %s as parents of %s
i(RNR1t
getchangesRt
basestringRRQRaR`R(R�RLt	setbranchRJR+R�RRUtKeyErrorR9R_t	putcommitREt	converted(R<R.RftchangesRLtfilestcopiest	pbranchesRyRaRgtbR1tnewnode((s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pytcopyNs<
	

	
,
!
c	Cs4z"|jj�|jj�|jj|j�|jjtd��|jj�}|j	|�}|j
||j�|jjtd��|j||�}t
|�}d}|jjtd��x�t|�D]�\}}|d8}|j|j}d|kr|j�d}n|jjd|t|�f�|jjtd�t|��|jjtd	�|d
td�dt
|��|j|�q�W|jjtd	�d�|jj�}	i}
xG|	D]?}|	|}|jj|t�tkr�|j||
|<q�q�W|r�|
r�|jj|
�\}
}|
r�|r�g|jj�D]}|d|krS|^qS}|r�|
|j|dd<q�q�n|jj�}i}xG|D]?}||}|jj|t�tkr�|j|||<q�q�W|r|r|jj|�n|j�Wd|j�XdS(
Nsscanning source...
ssorting...
sconverting...
is
is%d %s
ssource: %s
t
convertingRZR[R?( R1tbeforeRLt	setrevmapRQR+R�RtgetheadsRhRnRJR�R_RDt	enumerateRNtdesct
splitlinesRR6R@R�tgettagsRURtputtagst	iteritemstgetbookmarkstputbookmarksR�tcleanup(R<R2RbRatttnumRltiR�ttagstctagstktvtnrevt
tagsparenttettagsparentst	bookmarkst
cbookmarks((s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pytconvertps^


  $




cCs3z|jj�Wd|jj�X|jj�dS(N(RLtafterR1RQRE(R<((s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pyR��s(RFRGR=RhRnR�R�RTR`R�R�R�(((s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pyRH`s				z					"	=c
Ksftjadt_|jd�s7|jd�|d<n|sjtj|�d}|jtd�|�nt|||jd��}y1t|||jd�|jd��\}}Wn8t	k
r�x!|j
D]}tj|t
�q�W�nXd}	g|	D]}
|j|
�r�^q�t|�d
krItjtd���n|rY|dp\|}|dkr�|j�r�tjtd���n|dkr�|j�r�tjtd���n|jd�}|r�j|||�}|jt
�n|s=y|j�}Wq=t	k
r9tjj|d�}q=Xnt|||||�}
|
j|�dS(NsUTF-8RIROs-hgsassuming destination %s
t	dest_typetsource_typeR.RR�R R�is!more than one sort mode specifiedis1--sourcesort is not supported by this data sources0--closesort is not supported by this data sourcetfilemapRQ(s
branchsortsdatesorts
sourcesorts	closesort(RRRURtdefaultdestR�RR8R4t	ExceptiontcreatedtshutiltrmtreeRqR_RR'thasnativeorderthasnativecloseR�tfilemap_sourcetsetfilemapmodeRXRRR,tjoinRHR�(R+tsrcRLRXRMtdestctsrcctdefaultsortR,t	sortmodesR�R2tfmapRl((s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pyR��sF		
(
(,RVRRRRRRR!RRRRRRt
subversionR	R
tmonotoneRR#RR$R
R%RR�RRR�t	mercurialRRtmercurial.i18nRRRR&R5R4R8tobjectR9RHRDR�(((s9/sys/lib/python2.7/site-packages/hgext/convert/convcmd.pyt<module>s@"				


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.