ó œçƒQc@sdZddlZddlZddlZddlZddlmZmZmZ m Z m Z ddl m Z dZedZdZdd „Zd „Zd „Zd „Zd „Zdejfd„ƒYZed„Zd„Zddd„Zd„Zd„Zd„Zed„Z d„Z!d„Z"d„Z#gid„Z$d„Z%d„Z&d„Z'd„Z(d„Z)dd „Z*d!„Z+d"„Z,d#„Z-d$„Z.d%„Z/d&„Z0d'„Z1d(„Z2d)„Z3d*„Z4d+e5fd,„ƒYZ6d-„Z7d.„Z8dS(/sGlargefiles utility code: must not import other modules in this package.iÿÿÿÿN(tdirstatethttpconnectiontmatchtutiltscmutil(t_s.hglft/t largefilesi cCsœ|}| r.|r.|jtdd|ƒ}n|rtyt|ƒ}Wqttk rptjtdƒ|ƒ‚qtXn|dkr˜tjtdƒƒ‚n|S(Ntminsizetdefaults)largefiles: size must be number (not %s) s-minimum size for largefiles must be specified(tconfigtlongnametfloatt ValueErrorRtAbortRtNone(tuit assumelfilestoptR tlfsize((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyt getminsizes   cCsªtjtjj|ƒƒytj||ƒWnvtk r¥tj|ƒ}x-tjt |dƒƒD]}|j |ƒqeW|j ƒtj |tj |ƒjƒnXdS(Ntrb(RtmakedirstostpathtdirnametoslinktOSErrortatomictempfilet filechunkitertopentwritetclosetchmodtstattst_mode(tsrctdesttdsttchunk((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pytlink(s  cCsa|jtddƒ}|r3tjj||ƒ}n*tjdkrtjdtjdƒƒ}|r]tjj|t|ƒ}q]nÜtj ƒdkrÌtjdƒ}|r]tjj|ddt|ƒ}q]n‘tjd krAtjd ƒ}|r tjj|t|ƒ}q]tjdƒ}|r]tjj|d t|ƒ}q]nt j t d ƒtjƒ‚|S( Nt usercachetntt LOCALAPPDATAtAPPDATAtDarwintHOMEtLibrarytCachestposixtXDG_CACHE_HOMEs.cachesunknown operating system: %s ( t configpathR RRRtjointnametgetenvtplatformtsystemRRR(RthashRtappdatathome((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyt usercachepath4s*!cCs%t||ƒ}|o$tjj|ƒS(N(R<RRtexists(RR9R((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyt inusercacheNscCs’t||ƒr6|jjtdƒ|ƒt||ƒSt|j|ƒrŽ|jjtdƒ|ƒt||ƒ}tt|j|ƒ|ƒ|SdS(Nsfound %s in store sfound %s in system cache ( tinstoreRtnoteRt storepathR>R(R<R(trepoR9R((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pytfindfileRs tlargefilesdirstatecBsPeZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z RS(cCstt|ƒjt|ƒƒS(N(tsuperRDt __getitem__tunixpath(tselftkey((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyRF^scCstt|ƒjt|ƒƒS(N(RERDtnormalRG(RHtf((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyRJ`scCstt|ƒjt|ƒƒS(N(RERDtremoveRG(RHRK((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyRLbscCstt|ƒjt|ƒƒS(N(RERDtaddRG(RHRK((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyRMdscCstt|ƒjt|ƒƒS(N(RERDtdropRG(RHRK((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyRNfscCstt|ƒjt|ƒƒS(N(RERDtforgetRG(RHRK((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyROhscCstt|ƒjt|ƒƒS(N(RERDt normallookupRG(RHRK((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyRPjscCstS(N(tFalse(RH((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyt_ignorels( t__name__t __module__RFRJRLRMRNRORPRR(((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyRD]s       c CsÃ|jtƒ}tj|ƒ}t|||j|jjƒ}|r¿tj j tj j|dƒƒ r¿t j |ƒt |ƒ}x?|jj|gttƒD]}t|ƒ}|j|ƒq™Wn|S(sŠ Return a dirstate object that tracks largefiles: i.e. its root is the repo root, but it is saved in .hg/largefiles/dirstate. R(R4R RtopenerRDtrootRt _validateRRR=RRtgetstandinmatchertwalkRQt splitstandinRP( RRBtcreatet lfstoredirRUt lfdirstatetmatchertstandintlfile((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pytopenlfdirstateos(  " cCstj|j|jƒƒ}|j|gtttƒ}|\}}}}} } } } x˜|D]} y||t| ƒ}Wntk r’d}nX| sÁ|j ƒj ƒt |j | ƒƒkrÑ|j | ƒq[| j | ƒ|j| ƒq[W|||| | | | fS(N(tmatch_talwaysRVtgetcwdtstatusRQR_t LookupErrorRtdatatstripthashfiletwjointappendRJ(R]RBtrevRtstunsuretmodifiedtaddedtremovedtmissingtunknowntignoredtcleanR`tfctx((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pytlfdirstatestatus„s   . cCsd|dkrt|ƒ}ng||j|ƒD]1}|dk sT|j|dkr/t|ƒ^q/S(sNreturn a list of largefiles in the working copy or the specified changesett?N(RRXRYRRZ(RBRlR^RK((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyt listlfiles”s  cCstjjt||ƒƒS(N(RRR=RA(RBR9((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyR? scCs|jtjjt|ƒƒS(N(R4RRR (RBR9((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyRA£scCs^t||ƒ}|dkrtStjtjj|j|ƒƒƒt j ||j|ƒƒt S(s.Copy the specified largefile from the repo or system cache to filename in the repository. Return true on success or false if the file was not found in either cache (which should not happened: this is meant to be called only after ensuring that the needed largefile exists in the cache).N( RCRRQRRRRRRjtshutiltcopytTrue(RBR9tfilenameR((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyt copyfromcache¦s  "cCsBt|||ƒ}t||ƒr%dSt||j|ƒ|ƒdS(N(t readstandinR?tcopytostoreabsoluteRj(RBRltfiletuploadedR9((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyt copytostoreµscCsh||}xW|jƒD]I}t|ƒr||jƒkrt|ƒ}t||jƒ|ƒqqWdS(s4Copy all largefiles in a given revision to the storeN(tfilest isstandintmanifestRZRƒtnode(RBR‡tctxR}trealfile((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pytcopyalltostore»s   cCsÝt|j|ƒr7tt|j|ƒt||ƒƒn¢t|dtƒsÙtjt j j t||ƒƒƒtj t||ƒd|j jƒ}x-tjt|dƒƒD]}|j|ƒq¨W|jƒt||ƒndS(Nt _isconvertingt createmodeR(R>RR(R<RAtgetattrRQRRRRRRtstoreRŒRRRR tlinktousercache(RBRR9R&R'((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyR€Ås%" cCs5t|j|ƒ}|r1tt||ƒ|ƒndS(N(R<RR(RA(RBR9R((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyRÑscCsr|jtƒ}|r@g|D]}tjj||ƒ^q}n |g}tj|d||ƒ}d„|_|S(s@Return a match object that applies pats to the standin directorycSsdS(N(R(RKtmsg((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pytàsN( Rjt shortnameRRR4RRRtbad(RBtpatstoptst standindirtpatR((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyRXÖs+  cs=t|ˆjƒƒ}|j‰‡‡fd†}||_|S(s©Return a matcher that accepts standins corresponding to the files accepted by rmatcher. Pass the list of files in the matcher as the paths specified by the user.csˆ|ƒoˆjt|ƒƒS(N(tmatchfnRZ(RK(R…trmatcher(s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pytcomposedmatchfnés(RXR„R˜(RBR™tsmatcherRš((R…R™s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pytcomposestandinmatcherãs   cCsttj|ƒS(sLReturn the repo-relative path to the standin for the specified big file.(tshortnameslashRtpconvert(R}((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyR_ïs cCs |jtƒS(ssReturn true if filename is a big file standin. filename must be in Mercurial's internal form (slash-separated).(t startswithR(R}((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyR…ûscCsMtj|ƒjddƒ}t|ƒdkrE|dtkrE|dSdSdS(NRiii(RRžtsplittlenR’R(R}tbits((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyRZs"cCsY|jt|ƒƒ}tjj|ƒrUt|ƒ}t|ƒ}t||||ƒndS(N(RjRZRRR=Rit getexecutablet writestandin(RBR_RR9t executable((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyt updatestandin s   cCs||t|ƒjƒjƒS(scread hex hash from standin for filename at given node, or working directory if no node is given(R_RgRh(RBR}R‡((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyRscCs'|j||d|rdpdƒdS(s#write hash to /s txtN(twwrite(RBR_R9R¥((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyR¤scCsDtjdƒ}x(|D] }|j|ƒ|j|ƒqW|jƒS(s‡Read bytes from instream (iterable) and write them to outfile, computing the SHA-1 hash of the data along the way. Return the hash.R¨(Rtsha1tupdateRt hexdigest(tinstreamtoutfilethasherRg((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyt copyandhashs   cCst|j|ƒƒS(N(RiRj(RBR((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyt hashrepofile#scCsrtjj|ƒsdStjdƒ}t|dƒ}x'tj|dƒD]}|j|ƒqGW|jƒ|j ƒS(NR¨Ri€ii( RRR=RRªRRR«R R¬(RR¯tfdRg((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyRi&s cCs7tj|ƒj}|tj@o6|tj@o6|tj@S(N(RR"R#tS_IXUSRtS_IXGRPtS_IXOTH(R}tmode((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyR£0s  cGs<d„}|||ƒ}x|D]}|||ƒ}qW|S(NcSs@|jdƒs|d7}n|jdƒr8|d}n||S(NRi(tendswithRŸ(tlefttright((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyR47s   ((tfirsttsecondtargR4turlta((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyturljoin6s   cCs=tjƒ}x$tj|ƒD]}|j|ƒqW|jƒS(sUhexsha1 returns the hex-encoded sha1 sum of the data in the file-like object data(RRªRR«R¬(RgthR'((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pythexsha1Cs cCstj||dƒS(NR(Rt httpsendfile(RR}((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyRÂKscCstjtjj|ƒƒS(s@Return a version of path normalized for use with the lfdirstate.(RRžRRtnormpath(R((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyRGNscCsQd|jkr5tjd„|jjƒDƒƒr5tStjt|j|tƒƒS(NRcss|]}t|dkVqdS(iN(R(t.0RK((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pys Ts( t requirementsRtanyRŽt datafilesR|RaRRQ(RB((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyt islfilesrepoRs"tstoreprotonotcapablecBseZd„ZRS(cCs ||_dS(N(t storetypes(RHRÊ((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyt__init__Zs(RSRTRË(((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyRÉYscCsˆg}t|ƒ}xo|jj|gttƒD]R}t|ƒ}yt||ƒ}Wntk rld}nX|j||fƒq.W|S(N( RXRRYRQRZRtIOErrorRRk(RBtstandinsR^R_R`R9((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pytgetstandinsstate]s "   cCsZt|ƒjt|ƒƒ}g}x2|D]*}|d|kr(|j|dƒq(q(W|S(Ni(tsettsymmetric_differenceRk(t oldstandinst newstandinstchangedstandinstfilelistRK((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pytgetlfilestoupdateis  (9t__doc__RR7RzR"t mercurialRRRRbRRtmercurial.i18nRR’RR RR(R<R>RCRDR|RaRwRRyR?RAR~RQRƒRŠR€RRXRœR_R…RZR¦RR¤R°R±RiR£R¿RÁRÂRGRÈt ExceptionRÉRÎRÕ(((s;/sys/lib/python2.7/site-packages/hgext/largefiles/lfutil.pyt sZ    (