o ]LbH@sldZddlmZddlZddlmZddlmZmZm Z m Z m Z m Z ddlmZddlmZmZd d ZdS) z,setup for largefiles repositories: reposetup)absolute_importN)_)error extensions localrepomatchscmutilutil) timestamp) lfcommandslfutilcssdSGfdddj_tjg_jg_fdd}jd|dd} dd |d dd |ddS) NcseZdZdZdZfddZej       dfdd Zfd d Z      dfd d Z ddZ Z S)zreposetup..lfilesrepoTFcs^t||}|jr-dd}t|d|dd}t|d|d dd}t|d ||S) NcSs|}dd|DS)NcSg|] }t|p |qSr splitstandin.0frr7zLreposetup..lfilesrepo.__getitem__..files..r)orig filenamesrrrfiles5sz8reposetup..lfilesrepo.__getitem__..filesrcs&|}Gfddd|j|_|S)NceZdZfddZZS)zSreposetup..lfilesrepo.__getitem__..manifest..lfilesmanifestcs"t|j}||p|t|SN)super __contains__r standin)selffilenamer) __class__lfilesmanifestrrr?s  z`reposetup..lfilesrepo.__getitem__..manifest..lfilesmanifest.__contains__)__name__ __module__ __qualname__r __classcell__rr#r"rr#>r#r))rman1rr(rmanifest;sz;reposetup..lfilesrepo.__getitem__..manifestr,csz|dur||||}W|S|||}W|Stjy@|dur+|t|||}n|t||}|jfdd|_Y|Sw)Ncs dS)NrrolddatarrX zLreposetup..lfilesrepo.__getitem__..filectx..)r LookupErrorr rdata)rpathfileidfilelogresultrr.rfilectxJs  z:reposetup..lfilesrepo.__getitem__..filectxr8)NN)r __getitem__lfstatusr wrapfunction)r changeidctxrr,r8r" lfilesreporrr91s z)reposetup..lfilesrepo.__getitem__.Nc( sd|||}} } tj} js| ||||| | |Sd_||} | duo3dk} |dur.lfilesrepo.status..tostandinscs"t|}j}||vp||Sr)r rrArC)rrFrAr rr sfindirstates z:reposetup..lfilesrepo.status..sfindirstatecsg|]}|r|qSrrr)rJrrrz8reposetup..lfilesrepo.status..)subreposignoredcleanunknownxcsg|] }t|vr|qSr)r r)rlfile)ctx1rrrs ) ignoremissingcsg|] }|jvr|qSr)rArrIrrr#rcsg|]}|vr|qSrrr) lfdirstaterrr$rKcSg|] }dd|DqS)cSsg|] }t|s|qSr)r isstandin)rfnrrrr-rCreposetup..lfilesrepo.status...r)rfilelistrrrr, cSsg|] \}}t||qSr)sorted)rlist1list2rrrr9s cSrX)cSrrrrrrrr?rr[r)ritemsrrrr>r])0rstatusr:revmatchmodalwayswlockr LockErrorr nullcontextmanagerr openlfdirstatecopy_filesmodifiedaddedremoveddeletedrNrrB readasstandinhashfilewjoinlstatst_modest_sizer reliable_mtime_of set_cleanrA _checkexecflagsbool getexecutablewalkgetstandinmatcherrwvfs unlinkpathlistset differencezipwritecurrenttransactionr)(r node1node2rrMrNrO listsubrepos listignored listclean listunknownrctx2 parentworkingrfgotlockrrHmr7unsuresmtime_boundaryrlrmrnrowctxrQrmodesizemtime cache_datatocheck checkexecabslfilelfilesnormalsr:)r"r?repoui)rRrTr rJrGrrbes0                              8 z$reposetup..lfilesrepo.statuscs>t|j|g|Ri|}Gfddd|j|_|S)Ncr)z:reposetup..lfilesrepo.commitctx..lfilesctxcst|j}t|||Sr)r markcommittedr )r noder)r" lfilesctxrrrMs zHreposetup..lfilesrepo.commitctx..lfilesctx.markcommitted)r$r%r&rr'rrr)rrLr*r)r commitctxr")r r=argskwargsrr>rrrIsz'reposetup..lfilesrepo.commitctxc sr|duri}t|j}||jd} | ||}||||||||d} | WdS1s2wYdS)N)textuserdaterforceeditorextra)rcommitrf_lfcommithooks) r rrrrrrrr lfcommithookr7r>rrrWs"      $z$reposetup..lfilesrepo.commitc Ssg}g}g}|D]%}t|drtjtd|dd|j|r(||q||q|D]H}d}|j |d}|D]} |j |  |rR||d}nq>|sq|D]} |j |  |rp|| |sp|dd}qW|sx||q0||7}|S)a Adjust matched file list If we pass a directory to commit whose only committable files are largefiles, the core commit code aborts before finding the largefiles. So we do the following: For directories that only have largefiles as matches, we explicitly add the largefiles to the match list and remove the directory. In other cases, we leave the match list unmodified. /s file "%s" is a largefile standins#commit the largefile itself instead)hintFTr@) r rYrAbortrr~isdirrBrA normalize startswith) r rr actualfilesdirsregularsr matcheddirdmflfrrr _subdirlfsusD         z(reposetup..lfilesrepo._subdirlfs)r@NNFFFF)rNNNFFN) r$r%r&_largefilesenabledr:r9runfilteredmethodrbrrrr'rr?rrr)rr?'s04dr?csX|j}|dur |jj}|r*tfdd}t|j||t|j|j dSdS)z4Push largefiles for pushop before pushing revisions.Ncs |Sr)add)rZlfhashtouploadrrr0r1z8reposetup..prepushoutgoinghook..) lfrevsoutgoingmissingrr getlfilestouploadrr uploadlfilesremote)pushopraddfunc)rrrprepushoutgoinghooks z&reposetup..prepushoutgoinghook largefilesc[s|5d|jvr)tdd|jDr1|jdt|WddSWddSWddS1ss z9reposetup..checkrequireslfiles..)lock requirementsanystore datafilesrrwritereporequirements)rrrrrrcheckrequireslfiless   "z&reposetup..checkrequireslfilesshooksschangegroup.lfiless commit.lfiles) localr"r updatestandinsbymatchrrb_lfstatuswritersprepushoutgoinghooksr setconfig)rrrrrrr reposetup!s     r)__doc__ __future__rrjmercurial.i18nr mercurialrrrrrdrr mercurial.dirstateutilsr r r rrrrrs