�ڧOc@s}ddlmZddlmZddlmZmZmZmZddl Z ddl
Z
d�Zdefd��YZdS(i�(tutil(t_(tcommittconverter_sourcet checktooltNoRepoNccsGy/x(tr-tj|�}|s%Pn|VqWWntk
rBnXdS(s,Yield the dictionary objects generated by p4N(tTruetmarshaltloadtEOFError(tftd((s4/sys/lib/python2.7/site-packages/hgext/convert/p4.pytloaditers
t p4_sourcecBs\eZd d�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z
d�ZRS(
cCs�tt|�j||d|�d|krT|jd�rTttd�|��ntddt�i|_i|_ i|_
i|_i|_i|_
i|_d|_i|_tjd�|_tjd �|_tjd
�|_|j||�dS(Ntrevt/s//s%%s does not look like a P4 repositorytp4taborttlatin_1sE([a-z]+)?(text|binary|symlink|apple|resource|unicode|utf\d+)(\+\w+)?$sA\$(Id|Header|Date|DateTime|Change|File|Revision|Author):[^$\n]*\$s\$(Id|Header):[^$
]*\$(tsuperR
t__init__t
startswithRRRtFalset p4changestheadst changesettfilesttagst
lastbranchtparenttencodingt depotnametretcompiletre_typetre_keywordstre_keywords_oldt_parse(tselftuitpathR((s4/sys/lib/python2.7/site-packages/hgext/convert/p4.pyRs& cCskdtj|�}tj|dd�}x<t|�D].}|jdd�}|r5t|j|<q5q5WdS(sRead changes affecting the pathsp4 -G changes -s submitted %stmodetrbtchangeN(Rt
shellquotetpopenRtgettNoneRR(R&R(tcmdtstdoutRtc((s4/sys/lib/python2.7/site-packages/hgext/convert/p4.pyt_parse_view6scCsD|jtd��d|krn|j|�|jd�r^|jd�r^id|d 6}qKidd6}n�dtj|�}tjtj |dd ��}i}x�|D]�}|jd
�r�||j
�\}}|j|�|jd�r|jd�r|d }|d }n|d}||jd�d
}|||<q�q�W|jj
�|_|jjdt�|j
�} | jdtdt�|jjdddd�}
g|jD]P}|
s�t|�t|
�kr�|jst|�t|j�kr�|^q�|_|jtd��d'}x�jD]�d|
}tj |dd �}tj|�}|j|d�}|j
dd
�d}d|dt|�d
d!f}|jtj|d�d�|r�g}ng}t|d�df}td|j|d�dtj|d �d!|d|d"dd#i|
d$6�}g}d}x�d%||krd&||kr|d%|}d'}x9| D]1}|j|�r�|||t|�}Pq�q�W|r�j||d&|f�||j|<n|d
7}qXW||j|
<||j|
<|
}q3W|r@|g|_nd'S((s4Prepare list of P4 filenames and revisions to importsreading p4 views
Rs//s/...ti�sp4 -G client -o %sR)R*tViews...iitkeytreversetconvertsp4.startrevtdefaultiscollecting p4 changelists
sp4 -G describe -s %stdescs
s%s %sR+i�iPttimetauthortusertdates%Y-%m-%d %H:%M:%S %1%2tparentstbranchtextraRsdepotFile%dsrev%dN( tstatusRR3RtendswithRR,RRR-tsplittfindRtkeystsorttinttlenRR'tconfigRR/trecodetreprtellipsisRtdatestrtappendRRRR(R&R'R(tviewsR0t
clientspectclienttsviewtcviewt viewordertstartrevtxtlastidR+R1RR:t shortdescttR?R>R2Rtitoldnametfilenametv((s4/sys/lib/python2.7/site-packages/hgext/convert/p4.pyR%?s~
4
!#
cCs|jS(N(R(R&((s4/sys/lib/python2.7/site-packages/hgext/convert/p4.pytgetheads�sc
Cs�dtjd|j||f�}tj|dd�}d}d}d}x3t|�D]%}|d} |jd�}
| dkr�t|d |
��qX| d
krX|jj |d�}|r}d}|j
d�p�d|j
d
�p�}d|krd}n|j
d�dkr"d}nd|kr:|j}qUd|krU|j}qUq}qX| dksp| dkrX||
7}qXqXW|dkr�tdd��n|r�|j
d|�}n|dkr�jd�r�d }n||fS(Nsp4 -G print %ss%s#%sR)R*R4tcodetdataterrortgenerictstatttypeiiRWitsymlinktltkotkttexttbinaryisbad stats$\1$s
i�(RR,RR-R/RR.tIOErrorR"tmatchtgroupR$R#tsubRC(
R&tnameRR0R1R)tcontentstkeywordsRR`Ratp4typetflags((s4/sys/lib/python2.7/site-packages/hgext/convert/p4.pytgetfile�sB!
(
cCs|j|ifS(N(R(R&R((s4/sys/lib/python2.7/site-packages/hgext/convert/p4.pyt
getchanges�scCs|j|S(N(R(R&R((s4/sys/lib/python2.7/site-packages/hgext/convert/p4.pyt getcommit�scCs|jS(N(R(R&((s4/sys/lib/python2.7/site-packages/hgext/convert/p4.pytgettags�scCs(tg|j|D]}|d^q�S(Ni(tsortedR(R&RR[RW((s4/sys/lib/python2.7/site-packages/hgext/convert/p4.pytgetchangedfiles�sN(t__name__t
__module__R/RR3R%R_RuRvRwRxRz(((s4/sys/lib/python2.7/site-packages/hgext/convert/p4.pyR
s T + (
t mercurialRtmercurial.i18nRtcommonRRRRRR RR
(((s4/sys/lib/python2.7/site-packages/hgext/convert/p4.pyt<module>s"
|