ó œt•Pc@s‡ddlZddlZddlmZddlmZmZmZmZddlm Z ddl m Z dee fd„ƒYZ dS(iÿÿÿÿN(tutil(tNoRepotcommittconverter_sourcet checktool(t commandline(t_tmonotone_sourcecBs°eZddd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d„Z d „Z d „Z d „Zd „Zd „Zd„Zd„Zd„Zd„ZRS(c Cs|tj||||ƒtj||dƒ||_||_t|_||_tt dƒ|ƒ}t jj t jj |dƒƒsây,t |dƒ}|jdƒ}|jƒWntk rÉd}nX|dkrâ|‚qând}d }|} d } d } tj|d |ƒ|_tj|d |d| ƒ|_tj|d|d| ƒ|_tj|d|d| d| ƒ|_tj|d|d|ƒ|_tj|d|ƒ|_tj|d|d| ƒ|_tj| |d|d| ƒ|_|d | |d|} tj| d|dƒ|_d|_d|_d|_d|_ t!ddtƒdS(Ntmtns+%s does not look like a monotone repositoryt_MTNtrbitsSQLite format 3s\s*s\s+"((?:\\"|[^"])*)"\s*s\s+\[(\w+)\]\s*s (?:.|\n)+tdirtfiletcontenttadd_filetpatchtfromttotrenametdeletettagtrevisiontnametvaluetattrs "mtn:execute"s"true"tabort("Rt__init__RtuitpathtFalset automatestdiotrevRRtostexiststjoinR treadtclosetIOErrortretcompiletdir_retfile_ret add_file_retpatch_ret rename_ret delete_rettag_retcert_retattr_execute_retNonet manifest_revtmanifesttfilestdirsR( tselfRRR tnorepotftheadertspaceRRRtlinesR((s:/sys/lib/python2.7/site-packages/hgext/convert/monotone.pyRsV      !    $"      cOs-|jr|j||ŽS|j||ŽSdS(N(Rt mtnrunstdiot mtnrunsingle(R7targstkwargs((s:/sys/lib/python2.7/site-packages/hgext/convert/monotone.pytmtnrunGs cOs |j|d<|jd||ŽS(Ntdtautomate(Rtrun0(R7R?R@((s:/sys/lib/python2.7/site-packages/hgext/convert/monotone.pyR>Ms cOsg}x]|jƒD]O\}}|jdt|ƒ|fƒ|r|jdt|ƒ|fƒqqW|rŒ|jddƒ|jdƒn|jdƒx(|D] }|dt|ƒ|f7}q W|jdƒdj|ƒ}|jjd|ƒ|jj|ƒ|jj ƒ|j |ƒS(Ns%s:%sitotetlR smtn: sending '%s' ( t iteritemstappendtlentinsertR#Rtdebugt mtnwritefptwritetflushtmtnstdioreadcommandoutput(R7R?R@tcommandtktvtarg((s:/sys/lib/python2.7/site-packages/hgext/convert/monotone.pyR=Qs"$    cCsÉd}d}xJ|dkrX|jjdƒ}|sKtjtdƒƒ‚n||7}qW|d }|jjdƒ}|dkrtjtdƒ|ƒ‚n|jjdƒ}|dkrÓtjtdƒƒ‚nd}d}xJ|dkr+|jjdƒ}|stjtd ƒƒ‚n||7}qâWyt|d ƒ}Wn*tk rltjtd ƒ|ƒ‚nX|jj|ƒ}t|ƒ|kr¹tjtd ƒt|ƒ|fƒ‚n||||fS( NR t:is%bad mtn packet - no end of commandnbriÿÿÿÿtmewptls#bad mtn packet - bad stream type %ss'bad mtn packet - no divider before sizes&bad mtn packet - no end of packet sizes#bad mtn packet - bad packet size %ss9bad mtn packet - unable to read full packet read %s of %s( R2t mtnreadfpR$RtAbortRtlongt TypeErrorRJ(R7R$t commandnbrtstreamt lengthstrtlength((s:/sys/lib/python2.7/site-packages/hgext/convert/monotone.pytmtnstdioreadpackeths>    cCsg}xøtr|jƒ\}}}}|jjd|||fƒ|dkr‚|dkr~tjtdƒ||fƒ‚nPq |dkr¾|jjtdƒ|jƒ|jj|ƒq |dkrá|jjd|ƒq |d kr |j |ƒq q Wd j |ƒS( Nsmtn: read packet %s:%s:%s RGt0smtn command '%s' returned %stews %s error: tpsmtn: tmR ( tTrueR_RRLRRXRtwarnRQRIR#(R7RQtretvalR[R\R^toutput((s:/sys/lib/python2.7/site-packages/hgext/convert/monotone.pyRPŽs$       cCs|j|krdS|jd|ƒjdƒ|_||_i|_i|_x³|jD]¨}|jj|ƒ}|rÍd}|jdƒ}|jdƒ}|j j|ƒr·|d7}n||f|j|tauthortdatet changelogtbranchtcertss key ["\[]s\"t"s\\s\t.is UTC(RAR'RjR0Rktgroupstreplace(R7R RutcertlistRFRcRR((s:/sys/lib/python2.7/site-packages/hgext/convert/monotone.pyt mtngetcertsÆs cCs*|js|jdƒjƒS|jgSdS(Ntleaves(R RAt splitlines(R7((s:/sys/lib/python2.7/site-packages/hgext/convert/monotone.pytgetheadsÝs cCs|jd|ƒjdƒ}i}i}g}i}xI|D]A}|jj|ƒ}|r|||jdƒ<|||jdƒ= 12.0 - mtn >= 0.46 is needed) (R>tfloatR‘RRXRRdRRRLt_run2RRMRWtreadline(R7tversiont versionstrR$((s:/sys/lib/python2.7/site-packages/hgext/convert/monotone.pytbeforeAs,        cCs<|jr8|jjƒd|_|jjƒd|_ndS(N(RRMR%R2RW(R7((s:/sys/lib/python2.7/site-packages/hgext/convert/monotone.pytafteras     N(t__name__t __module__R2RRAR>R=R_RPRnRoRpR{R~RŽR”RœRžR¡R©Rª(((s:/sys/lib/python2.7/site-packages/hgext/convert/monotone.pyRs$7    &       8    ( R!R't mercurialRtcommonRRRRRtmercurial.i18nRR(((s:/sys/lib/python2.7/site-packages/hgext/convert/monotone.pyt s "