Qc@sHddlZddlZddlZddlZddlZddlZddlmZddl m Z ej Z dZ dZ defdYZdedZd efd YZd Zd efd YZdefdYZdefdYZdefdYZdefdYZdZdZdS(iN(tutil(t_cCs"d}tj|}||S(NcSs?tj|}g|D]}|jd^q}dj|S(Nit(tbase64t encodestringt splitlinestjoin(tstlinestl((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyt encodeargs#(tpickletdumps(targsR R((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyt encodeargss cCstj|}tj|S(N(Rt decodestringR tloads(R((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyt decodeargsst MissingToolcBseZRS((t__name__t __module__(((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyRscCsM|p |}tj|sI|r*tjp-t}|td|ndS(Nscannot find required "%s" tool(RtfindexetAbortRR(texetnametaborttexc((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyt checktools tNoRepocBseZRS((RR(((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyR%stSKIPtcommitcBseZddiddZRS(c CsX|p d|_|pd|_||_||_||_||_||_||_dS(Ntunknowns0 0(tauthortdatetdesctparentstbranchtrevtextratsortkey( tselfR R!R"R#R$R%R&R'((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyt__init__+s     N(RRtNoneR)(((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyR*stconverter_sourcecBseZdZdddZdZdZdZdZdZ dZ dZ d Z dd Z d Zd Zd ZdZdZdZRS(sConversion source interfacecCs(||_||_||_d|_dS(smInitialize conversion source (or raise NoRepo("message") exception if path is not a valid repository)sutf-8N(tuitpathR%tencoding(R(R,R-R%((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyR)9s   cCsdS(N((R(((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pytbeforeBscCsdS(N((R(((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pytafterEscCsdS(s*set the map of already-converted revisionsN((R(trevmap((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyt setrevmapHscCs tdS(s(Return a list of this repository's headsN(tNotImplementedError(R(((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pytgetheadsLscCs tdS(sReturn a pair (data, mode) where data is the file content as a string and mode one of '', 'x' or 'l'. rev is the identifier returned by a previous call to getchanges(). Raise IOError to indicate that name was deleted in rev. N(R3(R(RR%((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pytgetfilePscCs tdS(s#Returns a tuple of (files, copies). files is a sorted list of (filename, id) tuples for all files changed between version and its first parent returned by getcommit(). id is the source revision id of the file. copies is a dictionary of dest: source N(R3(R(tversion((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyt getchangesXs cCs tdS(s$Return the commit object for versionN(R3(R(R6((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyt getcommitcscCs tdS(sdReturn the tags as a dictionary of name: revision Tag names must be UTF-8 strings. N(R3(R(((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pytgettagsgscCs|s|jpd}nt|tr4|jdSy|j|jdSWnUtk ry|jdjdSWqtk r|j|djdSXnXdS(Nsutf-8slatin-1treplace(R.t isinstancetunicodetencodetdecodet UnicodeError(R(RR.((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pytrecodens   cCs tdS(sJReturn the files changed by rev compared to parent[i]. i is an index selecting one of the parents of rev. The return value should be the list of files that are different in rev and this parent. If rev has no parents, i is None. This function is only needed to support --filemap N(R3(R(R%ti((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pytgetchangedfiles|s cCsdS(s5Notify the source that a revision has been converted.N((R(R%tsinkrev((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyt convertedscCstS(sReturn true if this source has a meaningful, native revision order. For instance, Mercurial revisions are store sequentially while there is no such global ordering with Darcs. (tFalse(R(((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pythasnativeorderscCstS(s@Return true if this source has ability to close branch. (RE(R(((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pythasnativeclosescCsdS(sIf rev is a meaningful revision reference in source, return the referenced identifier in the same format used by getcommit(). return None otherwise. N(R*(R(R%((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyt lookuprevscCsiS(spReturn the bookmarks as a dictionary of name: revision Bookmark names are to be UTF-8 strings. ((R(((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyt getbookmarkssN(RRt__doc__R*R)R/R0R2R4R5R7R8R9R@RBRDRFRGRHRI(((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyR+6s"            tconverter_sinkcBszeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d ZRS( s"Conversion sink (target) interfacecCs||_||_g|_dS(sInitialize conversion sink (or raise NoRepo("message") exception if path is not a valid repository) created is a list of paths to remove if a fatal error occurs laterN(R,R-tcreated(R(R,R-((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyR)s  cCs tdS(s(Return a list of this repository's headsN(R3(R(((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyR4scCs tdS(sPath to a file that will contain lines source_rev_id sink_rev_id mapping equivalent revision identifiers for each system.N(R3(R(((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyt revmapfilescCsdS(sPath to a file that will contain lines srcauthor=dstauthor mapping equivalent authors identifiers for each system.N(R*(R(((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyt authorfilescCs tdS(sCreate a revision with all changed files listed in 'files' and having listed parents. 'commit' is a commit object containing at a minimum the author, date, and message for this changeset. 'files' is a list of (path, version) tuples, 'copies' is a dictionary mapping destinations to sources, 'source' is the source repository, and 'revmap' is a mapfile of source revisions to converted revisions. Only getfile() and lookuprev() should be called on 'source'. Note that the sink repository is not told to update itself to a particular revision (or even what that revision would be) before it receives the file data. N(R3(R(tfilestcopiesR#RtsourceR1((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyt putcommitscCs tdS(sPut tags into sink. tags: {tagname: sink_rev_id, ...} where tagname is an UTF-8 string. Return a pair (tag_revision, tag_parent_revision), or (None, None) if nothing was changed. N(R3(R(ttags((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pytputtagsscCsdS(sSet the current branch name. Called before the first putcommit on the branch. branch: branch name for subsequent commits pbranches: (converted parent revision, parent branch) tuplesN((R(R$t pbranches((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyt setbranchscCsdS(s;Tell the destination that we're using a filemap Some converter_sources (svn in particular) can claim that a file was changed in a revision, even if there was no change. This method tells the destination that we're using a filemap and that it should filter empty revisions. N((R(tactive((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pytsetfilemapmodescCsdS(N((R(((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyR/scCsdS(N((R(((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyR0scCsdS(sPut bookmarks into sink. bookmarks: {bookmarkname: sink_rev_id, ...} where bookmarkname is an UTF-8 string. N((R(t bookmarks((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyt putbookmarksscCs tdS(s$Return True if the sink contains revN(R3(R(R%((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyt hascommits(RRRJR)R4RMRNRRRTRVRXR/R0RZR[(((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyRKs        t commandlinecBseZdZdZdZdZdZdZdZdZ dZ d d Z d Z d Z ed ZdZdZRS(cCs||_||_dS(N(R,tcommand(R(R,R]((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyR)s cCsdS(N((R(((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pytprerunscCsdS(N((R(((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pytpostrunscOs"|j|gt|}x|jD]\}}t|dkrX|jd|n|jd|jddy>t|dkr|jd|n|dcd|7t (R]tlistt iteritemstlentappendR:t TypeErrorRt shellquoteR,t debugflagtostdevnullR(R(tcmdR tkwargstcmdlinetktvtarg((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyt_cmdline s  " cOsd}|j||||S(Nc Ss1tj|dtdddtjdtj}|S(Ntshelltbufsizeit close_fdststdout(t subprocesstPopentTrueRtclosefdstPIPE(Rntp((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pytpopen s  (t_dorun(R(RlR RmR}((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyt_runs cOs|jtj|||S(N(R~Rtpopen2(R(RlR Rm((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyt_run2'scOsV|j|||}|jjd|f|jz||SWd|jXdS(Ns running: %s (RrR,tdebugR^R_(R(topenfuncRlR RmRn((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyR~*s  cOsB|j|||}|jd}|jj|||jfS(Ni(Rt communicateR,Rt returncode(R(RlR RmR|toutput((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pytrun3scOsT|j|||}|jj}|j|jjdj|||jfS(NR(RRvt readlinestwaitR,RRR(R(RlR RmR|R((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pytrunlines9s  RcCsr|rn|r<|jjtd|j|jj|ntj|d}tjd|j|fndS(Ns %s error: is%s %s(R,twarnRR]Rt explainexitR(R(tstatusRtmsg((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyt checkexit@s cOs/|j|||\}}|j|||S(N(RR(R(RlR RmRR((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pytrun0HscOs8|j|||\}}|j|dj||S(NR(RRR(R(RlR RmRR((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyt runlines0MscCs?d}ytjd}Wnttfk r2nX|ddS(Nit SC_ARG_MAXii(RjtsysconftAttributeErrort ValueError(R(targmax((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyRRs  c ost|j|||}|j|}d}g}xn|D]f} t| d} || |ksst|dkr|j| || 7}q;|V| g}| }q;W|r|VndS(Nii(ReRrRRf( R(targlistRlR Rmtcmdlentlimittbytestfltfntb((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyt_limit_arglistds  "    cOsDx=|j||||D]#}|j|t|||qWdS(N(RRRc(R(RRlR RmR ((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pytxargsus(RRR)R^R_RrRRR~RRRRRt propertycacheRRR(((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyR\s            tmapfilecBs,eZdZdZdZdZRS(cCsEtt|j||_||_d|_g|_|jdS(N( tsuperRR)R,R-R*tfptordert_read(R(R,R-((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyR)zs     cCs-|js dSyt|jd}Wn,tk rQ}|jtjkrMndSXxt|D]\}}|jdj}|sq_ny|jdd\}}Wn7t k rt j t d|j|dfnX||kr|j j|ntt|j||q_W|jdS(NtriRbis/syntax error in %s(%d): key/value pair expected(R-topentIOErrorterrnotENOENTt enumerateRtrstriptrsplitRRRRRRfRRt __setitem__tclose(R(RterrRAtlinetkeytvalue((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyRs,    cCs|jdkrfyt|jd|_Wqftk rb}tjtd|j|jfqfXn|jj d||f|jj t t |j ||dS(Ntascould not open map file %r: %ss%s %s (RR*RR-RRRRtstrerrortwritetflushRRR(R(RRR((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyRs cCs&|jr"|jjd|_ndS(N(RRR*(R(((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyRs  (RRR)RRR(((s8/sys/lib/python2.7/site-packages/hgext/convert/common.pyRys   c Cs<|s iSi}yt|d}xt|D]\}}|jdj}|s]q/ny4|jdd\}}|jddj}Wn4tk rtjt d||dfnXg}x*|D]"}||kr|j |qqW|||s"<    qYy2