o ]Lb_.@s^ddlmZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddl mZddlmZmZmZm Z mZmZmZddlmZejZd Zd Zd d Zd gddgddgdgddgdZddZddZ dddZ!ddZ"Gddde#Z$Gdd d e#Z%Gd!d"d"e#Z&e&e$d#d$d%d$d&d$d'd$e%d(Z' )  *  +d.d,d-Z(dS)/)absolute_importN)_nullrev)open)error formattermatchpycompatscmutilutilvfs) stringutiliicCs|rt|}n,t|tstdtj|}|}t |gD]}| |r3|dt | }nq!tjt |}t|}| dsK|d7}|drV|dd}|dsetj|sed|vrlttd|S) zWchoose prefix to use for names in archive. make sure prefix is safe for consumers.s dest must be string if no prefixN/s./s../s/../s*archive prefix contains illegal components)r normpath isinstancebytes ValueErrorospathbasenamelowerextsgetendswithlen localpathpconvert startswithisabsrAbortr)destkindprefixrsfxlpfxr(4/usr/lib/python3/dist-packages/mercurial/archival.py tidyprefix)s(        r*s.tars.tbz2s.tar.bz2s.tgzs.tar.gzs.zips.txzs.tar.xz)tartbz2tgzziptxzcs6ttD]\}}tfdd|Dr|SqdS)Nc3s|]}|VqdSN)r).0extr#r(r) Pszguesskind..)r iteritemsrany)r#r$ extensionsr(r3r) guesskindNs r8cCs|D]}||S|tSr0r)reporevr(r(r)_rootctxUs r;sy repo: {root} node: {ifcontains(rev, revset("wdir()"), "{p1node}{dirty}", "{node}")} branch: {branch|utf8} {ifeq(latesttagdistance, 0, join(latesttag % "tag: {tag}", "\n"), separate("\n", join(latesttag % "latesttag: {tag}", "\n"), "latesttagdistance: {latesttagdistance}", "changessincelatesttag: {changessincelatesttag}"))} cCs|}d|jddti}t}t|j|d|}||j|d|j t | d| durEd}|j d d r?d }|j |d ||S) z!build content of .hg_archival.txtstemplates experimentalsarchivemetatemplatesarchivectx)rootNT)missing+)dirty)r9uiconfig_defaultmetatemplater stringior startitemcontextdatar;hexr:rBendgetvalue)r=r9optsoutfmrBr(r(r) buildmetadatams"    rPc@sJeZdZdZejr ejZn GdddejZd ddZ ddZ d d Z d S) taritzawrite archive to tar file or stream. can write uncompressed, or compress with gzip or bzip2.c@seZdZddZddZdS)ztarit.GzipFileWithTimecOsNd}d|vr |d}|durt|_n||_tjj|g|Ri|dS)Nmtime)poptime timestampgzipGzipFile__init__)selfargskwrUr(r(r)rXs  ztarit.GzipFileWithTime.__init__cCs|jd|jd|j}|r|dr|dd}d}|r#tj}|jt|t|jt |j |jd|jd|rN|j|ddSdS) Nss.gzr) fileobjwritenamerrVFNAMEr bytechrwrite32uintrU)rYfnameflagsr(r(r)_write_gzip_headers"      z)tarit.GzipFileWithTime._write_gzip_headerN)__name__ __module__ __qualname__rXrjr(r(r(r)GzipFileWithTimes rnr?csL_d_dfdd }t|tr|d|d_dS|d|d_dS) Nr?c sdkr1|dd}|st||d}j|t|dtj|d}|_tj |t||Sz t|t||WStj yS}zt t |d}~ww)Ngzrrb)rR)rrnr sysstrzlibZ_BEST_COMPRESSIONratarfileTarFiletaropenCompressionErrorrr"r forcebytestr)modercra gzfileobjer$rRrYr(r)rvs0   ztarit.__init__..taropensw:)rcsw|)ra)r?N)rRrarrz)rYr#rRr$rvr(r|r)rXs  ztarit.__init__cCspt|}t|}|j|_t||_|r(tj|_d|_ t||_ d}d|_n||_ t |}|j ||dS)Nr)r fsdecodertTarInforRrsizeSYMTYPEtyperylinknamerFr}addfile)rYrcryislinkrIir(r(r)rs    z tarit.addfilecCs"|j|jr|jdSdSr0)r}closerarYr(r(r)dones z tarit.doneN)r?) rkrlrm__doc__r ispy3rVrWrnrXrrr(r(r(r)rQs # rQc@s*eZdZdZd ddZddZddZd S) zipitz]write archive to zip file or stream. can write uncompressed, or compressed with deflate.TcCs^t|tr t|}t|d|rtjptj|_d}||kr |}||_ t |dd|_ dS)Nwi) rrr rzipfileZipFile ZIP_DEFLATED ZIP_STOREDr}rRrTgmtime date_time)rYr#rRcompressepochr(r(r)rXs  zzipit.__init__c Csvtt||j}|jj|_d|_t }|rd}t }||Bd>|_ |j t ddddt|j7_ |j||dS)Nr~s0 rcCr)Nrorrr(r(r)r1rcCr)Nsxzrrr(r(r)r2rcCr)NF)rrr(r(r)r3r)filesr+r,r-r/suzipr.Tr?Fc s|dkrtjsttd|dkrrttdnt||fdd} |tvr8ttd||t|||pGd|sPt }j d d rhd } || rh| | d d fddt  |} t| } | r| tt| fgj jtdtd| d} | d| D]}|}| |d|vrdpd d|v|j| j|dq| |rtjD]}|}t||}|d}| |||7} q| dkrttd | S)a create archive of repo as it was at node. dest can be name of directory, name of archive file, or file object to write archive to. kind is type of archive to create. decode tells whether to put files through decode filters from hgrc. match is a matcher to filter names of files to write to archive. prefix is name of path to put before every archive member. mtime is the modified time, in seconds, or None to use the changeset time. subrepos tells whether to include subrepos. r/s,xz compression is only available in Python 3rs*cannot give prefix when archiving to filescs.|}r ||}||||dSr0) wwritedatar)rcryrgetdatarI)archiverdecoder%r9r(r)rb_s zarchive..writesunknown archive type '%s'rsuis archivemetas.hg_archival.txtiFcstSr0)rPr(r<r(r)rqszarchive..s archiving)unittotalxil)itemrs"no files match the archive pattern)!r rrr"rr* archiversdater matchallrC configboollistmanifestwalkrsort prefetchfilesr: matchfiles makeprogressupdaterirI incrementcompletesortedsubstate workingsubmatchmod subdirmatcherarchiver)r9r#noder$rr r%rRsubreposrbrcfilesrprogressrffsubpathsubsubmatch subprefixr()rr=rr%r9r)r8sX    $   r)TNr?NF)) __future__rrVrrrtrTrrri18nrrrr rrr r rr r rrutilsrrFrrr*rr8r;rErPobjectrQrrrrr(r(r(r)s\    $    ^/