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

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


��c@s�ddlZddlZddlZddlmZddlmZmZmZddl	m
Z
mZmZm
Z
mZddlmZmZmZmZdefd��YZdefd	��YZdS(
i�N(t_(tbinthextnullid(thgtutiltcontextt	bookmarksterror(tNoRepotcommittconverter_sourcetconverter_sinktmercurial_sinkcBs}eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�ZRS(
cCs�tj|||�|jddt�|_|jddt�|_|jddd�|_d|_
tjj
|�rttj|��dkryDtj|j|�|_|jj�s�ttd�|��nWq�tjk
r
}|j�t|jd��q�Xn�yq|jtd�|�tj|j|d	t�|_|jj�snttd�|��n|jj|�Wn4tjk
r�|j�ttd
�|��nXd|_d|_t|_ dS(Ntconvertshg.usebranchnamesshg.clonebranchess
hg.tagsbranchtdefaultis&%s is not a local Mercurial repositorys'initializing destination %s repository
tcreates)could not create hg repository %s as sink(!Rt__init__t
configbooltTruetbranchnamestFalset
clonebranchestconfigt
tagsbranchtNonet
lastbranchtostpathtisdirtlentlistdirRt
repositorytuitrepotlocalR	RRt	RepoErrort	tracebacktargststatustcreatedtappendtlocktwlocktfilemapmode(tselfR!Rterr((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pyRs8	-


		cCs8|jjd�|jj�|_|jj�|_dS(Ns"run hg sink pre-conversion action
(R!tdebugR"R+R*(R-((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pytbefore<scCsF|jjd�|jr)|jj�n|jrB|jj�ndS(Ns#run hg sink post-conversion action
(R!R/R*treleaseR+(R-((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pytafterAs
		cCs|jjd�S(Ntshamap(R"tjoin(R-((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pyt
revmapfileHscCs|jjd�S(Nt	authormap(R"R4(R-((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pyt
authorfileKscCs/|jjj�}g|D]}t|�^qS(N(R"t	changelogtheadsR(R-thtx((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pytgetheadsNsc	Cs/|js
dS||jk}||_|s4d}ng|D]*}|d|dr\|dp_df^q;}|r|ddp�d}tjj|j|�}|r|j�ytj|j|�|_	Wn/t
k
r�tj|j|dt�|_	nX|j�ni}x[|D]S}y|j	j
|d�Wqt
k
rg|j|dg�j|d�qXqW|r+|j�x�t|j��D]�\}}tjj|j|�}	tj|ji|	�}
|jjtd�||f�|j	j|
g|D]}|
j
|�^q�q�W|j�ndS(NRiiRspulling from %s into %s
(RRRRR4R2RR R!R"t	ExceptionRR0tlookupt
setdefaultR)tsortedt	iteritemstpeertnoteRtpull(R-tbrancht	pbranchest	setbranchtbtpbrancht
branchpathtmissingsR9tpbranchpathtprepoR:((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pyRGRs<			7

"


)
 3cCs�tj�}x�|j�D]s}|jdd�}t|�dkrIqn|j|j|d��}|sqqn|jd||df�qW|j�S(Nt iiis%s %s
(	t	cStringIOtStringIOt
splitlinestsplitRtgett	lookuprevtwritetgetvalue(R-tsourcetrevmaptdatatfptlinetstrevid((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pyt_rewritetagsxscs�t��������fd�}g}x*|D]"}	|	|kr4|j|	�q4q4W|}t|�}
�jr�|
dkr��jjjt|d��d}|d}nt|�dkr�|jt�nt|�dkr�jt�n|j	d�}
|j
}|jj�}�j
r>|jr>|j|d<n|jrW|j|d<nx�|r�|
}|j	d�}
tj�j||
f|�j�||j|j|�}�jj|�d}t�jjj��}
qZW�jr�|
dkr��jj}�jjjt|
��d}d|jk}|r�|j||j|��r��jjtd	���jjd
t�|Sn|
S(Ncst�|}�j||�\}}|dkrF�j��|�}ntj||d|kd|k�j|��S(Ns.hgtagstlR;(tgetfileR^Rt
memfilectxRS(R"tmemctxtftvRYtmode(tcopiestfilesRXR-RW(s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pyt
getfilectx�s
iiiREtconvert_revisions(octopus merge fixup)
tclosesfiltering out empty revision
tforce( tdictR)RR,R"R8treadRRtpoptdesctextratcopyRREtrevRRbtkeystauthortdatet	commitctxRttiptmanifesttcmptrevisionR!R'RtrollbackR(R-RgRftparentsR
RWRXRhtpltptnparentstm1nodetparenttp2ttextRptp1tctxtmantmnodetclosed((RfRgRXR-RWs4/sys/lib/python2.7/site-packages/hgext/convert/hg.pyt	putcommit�sN
#
			!#c	s�y |j|j}|j�}Wn tjk
rBd}t}nXy#t|dj�j	t
��}Wntk
rg}nXtg|D]}d|||f^q��}||kr�d
Sdj|���fd�}|j
jtd��dttjtj���}i|jd6}	tj|j|dfddg|d	||	�}
|jj|
�t|jjj��t|�fS(Ns.hgtagss%s %s
tcstj|�ttd�S(N(RRaRR(R"RbRc(RY(s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pyRh�ssupdating tags
s%s 0REsupdate tagssconvert-repo(NN(R"RtnodeRR$RRR@RYRQRR=R4R!R'RtintttimetmktimetgmtimeRRbRvRR8Rw(R-ttagst	parentctxt	tagparenttoldlinesttagtnewlinesRhRuRpR�((RYs4/sys/lib/python2.7/site-packages/hgext/convert/hg.pytputtags�s.
#

-	cCs
||_dS(N(R,(R-tactive((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pytsetfilemapmode�scCset|�sdS|jjtd��|jj}x"|D]}t||�||<q9W|j�dS(Nsupdating bookmarks
(RR!R'RR"t
_bookmarksRRU(R-tupdatedbookmarkt	destmarkstbookmark((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pytputbookmarks�s
cCsA||jkr4|jr4tjtd�|��n||jkS(Nserevision %s not found in destination repository (lookups with clonebranches=true are not implemented)(R"RRtAbortR(R-Rr((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pyt	hascommit�s
(t__name__t
__module__RR0R2R5R7R<RGR^R�R�R�R�R�(((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pyR
s							&		5			
tmercurial_sourcecBs�eZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�ZRS(cCs�tj||||�|jddt�|_t�|_|jddt�|_y7tj	|j
|�|_|jj�s�t
j�nWn4t
jk
r�|j�ttd�|��nXd|_d|_d|_d|_|jdd�}|dk	r�y|jj|�}Wn-t
jk
rGtjtd�|��nX|jjj|�}id|6}x9|jjj|g�D]}d||jjj|�<q�W|j|_ ntj!|_ dS(NRshg.ignoreerrorss
hg.saverevs&%s is not a local Mercurial repositoryshg.startrevs %s is not a valid start revisioni("RRRRtignoreerrorstsettignoredtsaverevRR R!R"R#RR$R%R	RRtlastrevtlastctxt
_changescachet	convertfpRR>RR�R8RrtdescendantsR�t__contains__tkeeptalways(R-R!RRrt	startnodetstartrevtchildren((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pyR�s8
				
cCs2|j|kr+|j||_||_n|jS(N(R�R"R�(R-Rr((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pyt	changectx
scCs8g|j�D]'}|r
|j|j��r
|^q
S(N(R|R�R�(R-R�R~((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pyR|scCs`|jr%|j|jj�g}n|jj�}g|D]!}|j|�r;t|�^q;S(N(RrR"R�R9R�R(R-R9R:((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pyR<s	cCsVy-|j|�|}|j�|j�fSWn"tjk
rQ}t|��nXdS(N(R�RYtflagsRtLookupErrortIOError(R-tnameRrtfctxR.((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pyR`s
cCsA|j|�}|j|�}|s{t|j��}|j|||�g|D]!}||jkrP||f^qPifS|jr�|jd|kr�|jd\}}}n2|jj|dj	�|j	��d \}}}|j||||�}	g|||D]!}
|
|jkr
|
|f^q
}t|�|	fS(Niii(
R�R|R@Rxt	getcopiesR�R�R"R'R�(R-RrR�R|RgRctmtatrRfR�tchanges((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pyt
getchanges$s22!cCsi}x|D]}||jkr(q
ny�|j|�j�\}}||jkse|j|�rkw
nt}x$|D]}	||	krxt}PqxqxW|s�w
n|||<Wq
tk
r�q
tjk
r}
|j	s�n|jj
|�|jjt
d�|
�q
Xq
W|S(Ns
ignoring: %s
(R�tfilectxtrenamedR�RRt	TypeErrorRR�R�taddR!twarnR(R-R�R|RgRfR�t
copysourcetcopynodetfoundR~te((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pyR�9s0


	"cCs�|j|�}g|j|�D]}|j�^q}|jrI|}nd}td|j�dtj|j	�d�d|j
�d|d|d|j�d|j�d	|j
��S(
NRtRus%Y-%m-%d %H:%M:%S %1%2RoRrR|RERptsortkey(R�R|RR�RR
tuserRtdatestrRutdescriptionRERpRr(R-RrR�R~R|tcrev((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pyt	getcommitTs(		cCspg|jj�D]}|ddkr|^q}tg|D]-\}}|j|�r<|t|�f^q<�S(NiRw(R"ttagslistRlR�R(R-ttR�R�R�((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pytgettagsas2cCs�|j|�}|j|�}|rU|dkrUd}g|j�j�gf}n5|p^d}|jj||j�|j��d }g|D].}g|D]}||jkr�|^q�^q�}|dkr�|f|_	n|d|d|dS(Niiii(
R�R|RRxRsR"R'R�R�R�(R-RrtiR�R|R�R_Rc((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pytgetchangedfilesfs);cCs[|jdkr0t|jjd�d�|_n|jjd||f�|jj�dS(NR3R�s%s %s
(R�RtopenR"R4RUtflush(R-Rrtdestrev((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pyt	convertedvs!cCs|jjd�dS(Ns$run hg source pre-conversion action
(R!R/(R-((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pyR0|scCs|jjd�dS(Ns%run hg source post-conversion action
(R!R/(R-((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pyR2scCstS(N(R(R-((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pythasnativeorder�scCstS(N(R(R-((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pythasnativeclose�scCs6yt|jj|��SWntjk
r1dSXdS(N(RR"R>RR$R(R-Rr((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pyRT�scCstj|j�S(N(Rt
listbookmarksR"(R-((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pytgetbookmarks�sN(R�R�RRR�R|R<R`R�R�R�R�R�R�R0R2R�R�RTR�(((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.pyR��s""							
								(RR�ROtmercurial.i18nRtmercurial.nodeRRRt	mercurialRRRRRtcommonR	R
RRR
R�(((s4/sys/lib/python2.7/site-packages/hgext/convert/hg.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.