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

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


��c@s�ddlZddlZddlmZmZddlmZmZddlm	Z	ddl
mZmZm
Z
mZdefd��YZde
fd	��YZdS(
i�N(tutiltconfig(thextnullid(t_(tNoRepotcommittconverter_sourcet	checktoolt	submodulecBs#eZd�Zd�Zd�ZRS(cCs||_||_||_dS(N(tpathtnodeturl(tselfR
RR((s5/sys/lib/python2.7/site-packages/hgext/convert/git.pyt__init__s		cCsd|j|jfS(Ns%s = [git]%s(R
R(R
((s5/sys/lib/python2.7/site-packages/hgext/convert/git.pythgsubscCsd|j|jfS(Ns%s %s(RR
(R
((s5/sys/lib/python2.7/site-packages/hgext/convert/git.pyt
hgsubstates(t__name__t
__module__RRR(((s5/sys/lib/python2.7/site-packages/hgext/convert/git.pyR	s		tconvert_gitcBs�eZejed�r'dd�Zndd�Zd�Zd�Zdd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zd�Zd
�Zd�Zd�Zd�ZRS(tunsetenvcCs�tjjd�}|jtjd<z[|tjkrPtj|�\}}}|S|tjkrl|j	|�Stj
|d�SWd|dkr�tjd=n
|tjd<XdS(NtGIT_DIRtrb(tostenvirontgetR
t
subprocesstPIPERtpopen3tSTDOUTtpopen_with_stderrtpopentNone(R
tsterrt
prevgitdirtstdintstdouttstderr((s5/sys/lib/python2.7/site-packages/hgext/convert/git.pytgitopen!s

cCsu|tjkr8tjd|j|f�\}}}|S|tjkrT|j|�Stjd|j|fd�SdS(Ns
GIT_DIR=%s %sR(RRRRR
RRR(R
R!R"tsintsotse((s5/sys/lib/python2.7/site-packages/hgext/convert/git.pyR'2s%
cCsRtj|dtdddtjdtjdtjdtjdtd	d�}|j	S(
Ntshelltbufsizei�t	close_fdsR$R%R&tuniversal_newlinestenv(
RtPopentTrueRtclosefdsRRtFalseR R%(R
R!tp((s5/sys/lib/python2.7/site-packages/hgext/convert/git.pyR;s					cCs+|j|�}|j�}||j�fS(N(R'treadtclose(R
R!tfhtdata((s5/sys/lib/python2.7/site-packages/hgext/convert/git.pytgitreadEscCs�tt|�j||d|�tjj|d�rB|d7}ntjj|d�sqttd�|��nt	dd�||_g|_
dS(Ntrevs/.gits/objectss&%s does not look like a Git repositorytgit(tsuperRRRR
tisdirtexistsRRRt
submodules(R
tuiR
R:((s5/sys/lib/python2.7/site-packages/hgext/convert/git.pyRJs

	cCsx|js-|jd�\}}|j�}n)|jd|j�\}}|d g}|rttjtd���n|S(Ns"git rev-parse --branches --remotessgit rev-parse --verify %si�scannot retrieve git heads(R:R9t
splitlinesRtAbortR(R
theadstret((s5/sys/lib/python2.7/site-packages/hgext/convert/git.pytgetheadsWs	
cCsf|tt�krt�n|jd||f�\}}|rbtjtd�||f��n|S(Nsgit cat-file %s %sscannot read %r object at %s(RRtIOErrorR9RRBR(R
R:ttypeR8RD((s5/sys/lib/python2.7/site-packages/hgext/convert/git.pytcatfilebs	"cCs�|dkrCdjg|j�D]}|j�^q�}d}nh|dkr�djg|j�D]}|j�^qb�}d}n%|j|d�}|j||f}||fS(Ns.hgsubs
ts.hgsubstatetblob(tjoint
submoditerRRRHt	modecache(R
tnameR:tmR8tmode((s5/sys/lib/python2.7/site-packages/hgext/convert/git.pytgetfilejs.	.	ccsJtt�}x7t|jdd��D]}|j|kr%|Vq%q%WdS(NtkeycSs|jS(N(R
(R4((s5/sys/lib/python2.7/site-packages/hgext/convert/git.pyt<lambda>xs(RRtsortedR?R(R
tnullRO((s5/sys/lib/python2.7/site-packages/hgext/convert/git.pyRLvscCs�g|_tj�}|jd|jdd��x]|j�D]O}||}d|kr>d|kr>|jjt|dd|d��q>q>WdS(s�Parse the formatted .gitmodules file, example file format:
        [submodule "sub"]

        	path = sub

        	url = git://giturl

        s.gitmoduless	RIRR
N(R?RtparsetreplacetsectionstappendR	(R
tcontenttctsecR!((s5/sys/lib/python2.7/site-packages/hgext/convert/git.pytparsegitmodules|s	
cCs�|jd|df�\}}|rAtjtd�|��n|j|�xN|jD]C}|jd||jf�\}}|r�qXn|j�|_qXWdS(Nsgit show %s:%ss.gitmoduless(cannot read submodules config file in %ssgit rev-parse %s:%s(	R9RRBRR]R?R
tstripR(R
tversiontmodulesRDROR((s5/sys/lib/python2.7/site-packages/hgext/convert/git.pytretrievegitmodules�s

"c
Cs�i|_|jd|�}g}t�}d}t}x+|j�jd�D]}|sz|jd�snqMn|}qMn|}||kr[|j|�|j�}|d}	|ddk}
|ddk}|dkr�}|j
d�q[|ddks|dd
krt	}q[|
r&dp5|r2dp5d
|j||	f<|j
||	f�nd}qMW|j�r�tj
td�|��n|r�|j|�|j
d�n|ifS(Ns git diff-tree -z --root -m -r %stt:iit100755t120000s.gitmoduless.hgsubRIt160000is:160000txtlscannot read changes in %ss.hgsubstate(s.hgsubRI(s.hgsubstateRI(RMR'tsetR R3R5tsplitt
startswithtaddR1RYR6RRBRRa(R
R_R7tchangestseententryt	subexistsRhtfthR4R!((s5/sys/lib/python2.7/site-packages/hgext/convert/git.pyt
getchanges�sB		

 	+

cCs2|j|d�}|jd�}||d}|j|�}|| j�}g}d}}x |dD]}	|	jdd�\}
}|
dkr�j�}|d\}
}dj|d �}|dd	kr�dd
!}n|j|�}n|
dkra|j�}|d\}
}dj|d �}|dd	krO|dd
!}n|j|�}n|
dkri|j|�qiqiW|r�||kr�|d
|7}n|dd!d|dd!|d}}}t|�t|�dt|�}|
dt	|�}t
d|d|d|d|d|�}|S(NRs

iit tauthori�it<i�t	committertparents
committer: %s
i�i�t1itparentstdatetdescR:(RHtfindtrecodeRAR RjRKRYtinttstrR(R
R_R[tendtmessageRhRzRuRwtetntvR4ttmttzttzsttzhttzmR{((s5/sys/lib/python2.7/site-packages/hgext/convert/git.pyt	getcommit�sB
*%	cCsTi}i}|jd|jdtj�}d}x�|D]�}|j�}|jd�sh|jd�r�tjtd�|j��n|j	dd�\}}|j|�s�q8n|||t|�<q8W|j�r�jtd�|j��nxV|D]N}|j
d�r(||||d	 <q�d|kr>q�||||<q�S(
Nsgit ls-remote --tags "%s"R"s
refs/tags/serror:sfatal:scannot read tags from %sis^{}i�(R'R
RRR^RkRRBRRjR tlenR6tendswith(R
ttagstalltagsR7tprefixtlineRttag((s5/sys/lib/python2.7/site-packages/hgext/convert/git.pytgettags�s,

cCs�g}|dkrq|jd|�}x�|D]>}d|krDq,n|d jd�\}}|j|�q,WnB|jd|||df�}g|D]}|jd�^q�}|j�r�tjtd�|��n|S(Nsgit diff-tree --root -m -r %ss	i�s1git diff-tree --name-only --root -r %s "%s^%s" --is
scannot read changes in %s(	R R'RjRYtrstripR6RRBR(R
R_tiRmR7RhRORq((s5/sys/lib/python2.7/site-packages/hgext/convert/git.pytgetchangedfiles�s
	"c
Cs�i}d}t|�}idd6dd6}x�|D]�}y�|j||dtj�}xe|D]]}|j�}|jdd�\}}	|	j|�s�q_nd||	|f}	|||	<q_WWq3tk
r�q3Xq3W|S(	Nsrefs/heads/sgit ls-remote --heads originsremote/sgit show-refRIR"is%s%s(	R�R'RRR^RjR Rkt	Exception(
R
t	bookmarksR�t	prefixlentgitcmdtreftypeR7R�R:RN((s5/sys/lib/python2.7/site-packages/hgext/convert/git.pytgetbookmarkss$




N(RRRtsafehasattrRR R'RR9RRERHRQRLR]RaRsR�R�R�R�(((s5/sys/lib/python2.7/site-packages/hgext/convert/git.pyRs"		
	
							&	#		(RRt	mercurialRRtmercurial.nodeRRtmercurial.i18nRtcommonRRRRtobjectR	R(((s5/sys/lib/python2.7/site-packages/hgext/convert/git.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.