ó î8¥Qc@sÞdZddlZddlZddlZddlmZmZmZm Z m Z m Z m Z m Z mZddlmZddlmZddlZddlZd„Zd„Zd„Zd „Zd „Zd „Zd „Zd „Zd„Zd„Zeed„Z d„Z!dd„Z#dd„Z$de%d„Z&d„Z'dd„Z(iedddedƒdfddeedƒfgedƒfd 6e(d!d"ged#ƒfgej)ed$ƒfd%6Z*ej+d&7_+dS('s=High-level command function for lfconvert, plus the cmdtable.iÿÿÿÿN( tutiltmatchthgtnodetcontextterrortcmdutiltscmutiltcommands(t_(treleasec sÍ|drt}n*t}tj|t|jdƒddƒ}tj|ƒshtj t dƒ|ƒ‚ntj|ƒs“tj t dƒ|ƒ‚ntj ||ƒ‰|j t dƒ|ƒtj ||dtƒ}t}d} } z®|j ƒ} |jƒ} ‡fd†ˆjjdˆjƒƒdDƒ} itjtj6} |rtƒ} tƒ}|s}|jtjd dgƒ}n|r¤tjˆjd t|ƒƒ}nd}i}xh| D]`}|jt d ƒ|jƒd t d ƒdˆdjƒƒtˆ||| | ||||ƒ q·W|jt d ƒdƒtjj |j!tj"ƒƒrkt#j$|j!tj"ƒƒnx‚|j%ƒD]t}tjj&|j!|ƒƒr²tj'|j!|ƒƒny&tj(tjj)|j!|ƒƒƒWqxt*k rëqxXqxW| r‹|j+j,dƒ|j-ƒq‹nux\| D]T}|jt d ƒ|jƒd t d ƒdˆdjƒƒt.|ˆ||| ƒqW|jt d ƒdƒt}Wd|j/j0ƒt1| | ƒ|sÈt#j$|jƒnXdS(sMconvert a normal repository to a largefiles repository Convert repository SOURCE to a new repository DEST, identical to SOURCE except that certain files will be converted as largefiles: specifically, any file that matches any PATTERN *or* whose size is above the minimum size threshold is converted as a largefile. The size used to determine whether or not to track a file as a largefile is the size of the first version of the file. The minimum size can be specified either with --size or in configuration as ``largefiles.size``. After running this command you will need to make sure that largefiles is enabled anywhere you intend to push the new repository. Use --to-normal to convert largefiles back to normal files; after this, the DEST repository can be used without largefiles at all.t to_normaltsizetdefaults %s is not a local Mercurial reposinitializing destination %s tcreatec3s|]}ˆ|VqdS(N((t.0tctx(trsrc(s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pys Gsitpatternstsconverting revisionstunittrevisionttotalttipt largefilesN(2tFalsetTruetlfutilt getminsizetgettNoneRtislocalRtAbortR t repositorytstatustwlocktlockt changelogt nodesbetweentheadsRtnullidtsett configlisttlongnametmatch_Rtroottlisttprogresstrevt_lfconvert_addchangesettostpathtexiststwjoint shortnametshutiltrmtreetkeystisfiletunlinkt removedirstdirnametOSErrort requirementstaddt_writerequirementst _addchangesettdirstatetclearR (tuitsrctdesttpatstoptsttolfileR trdsttsuccesstdstwlocktdstlocktctxstrevmaptlfilest normalfilestmatchert lfiletohashRtf((Rs?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyt lfconvertsp  $     ! &     c s¢tˆˆƒ}tˆ|ƒ‰‡‡‡‡‡fd†}g}xCˆD];}tj|ƒrt|jtj|ƒƒqF|j|ƒqFWt||ˆ||ˆƒdS(Nc s›tj|ƒˆkryˆjtj|ƒƒ}Wntjk rMt‚nX|jƒ}|rvtj|dƒ}n|jƒj ƒ}tj ˆ|ƒ}|dkrt ˆˆˆj ƒƒtj ˆ|ƒ}|dkrtjtdƒ|t jˆj ƒƒfƒ‚qnd}d}zt|dƒ}|jƒ}Wd|rO|jƒnXtj||d|jƒkd|jƒk|ƒSt|jˆ|ˆƒSdS(Nis'missing largefile '%s' from revision %sRtrbtltx(RtstandintfilectxRt LookupErrortIOErrortrenamedt splitstandintdatatstriptfindfileRt cachelfilesRRR R thextopentreadtcloseRt memfilectxtflagst_getnormalcontextRE( trepotmemctxRUtfctxR^thashR3R`tfd(RtfilesRPRRE(s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyt getfilectx‚s6     %(t_convertparentst_getchangedfilesRt isstandintappendR_t_commitcontext( RERRKRRPtparentsRqtdstfilestfile((RRpRPRREs?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyRB{s& c  s§tˆˆƒ} tˆ| ƒ} g} xN| D]F} | |kr| |krt| ˆ||ƒ} | ˆjƒkrëˆj| ƒ}|jƒ}|ož|d|k}| |O} d|jƒkrë|rßtjt dƒ| ƒ‚nt } qën| r|j | ƒq|j | ƒn| |krd| j t j| ƒƒ| ˆjƒkrqˆj| ƒ}d|jƒkr§|jƒ}|r§|d|kr§tjt dƒ| ƒ‚q§ntjdƒ}|jˆ| jƒƒ|jƒ}| ˆksõˆ| |kra|j| ˆ| jƒˆ| jƒƒdˆ| jƒk}t j|t j| ƒ||ƒ|ˆ| ||ƒr>tSy%|j|ƒjƒ|ddkSWntjk rztSXdS(slReturn true if file should be considered a largefile, i.e. matcher matches it or it is larger than size.s.hgtagss .hgignores.hgsigsiN(RRR[R RR\(RyRRSR ((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyR{Cs$%c s|s dStj||dtƒ}d}|jdt|ƒƒ|j|ƒ‰t‡fd†|ƒ}|jdt|ƒƒx„|D]|}|jtdƒ|dd d t|ƒƒt j ||ƒ}|sæt j td ƒ|ƒ‚n|j ||ƒ|d 7}q„W|jtdƒdƒdS( s&upload largefiles to the central storeNtputis,sending statlfile command for %d largefiles cs ˆ| S(N((th(tretval(s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyt[ss"%d largefiles need to be uploaded suploading largefilesRt largefileRs6largefile %s missing from store (needs to be uploaded)i(t basestoret _openstoreRtdebugR‘R4tfilterR/R RRbRR R¢R(RERRKRptstoretatRntsource((R¤s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyt uploadlfilesPs$   cCsF|rtt|ƒƒ}n dg}tj|ƒ}|j|d|ƒS(s)Verify that every largefile revision in the current changeset exists in the central store. With --contents, also verify that the contents of each local largefile file revision are correct (SHA-1 hash matches the revision ID). With --all, check every changeset in this repository.t.tcontents(trangeR‘R§R¨tverify(RERktallR°trevsR«((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyt verifylfilesjs  cCs{tj||ƒ}xbt|jjƒƒD]K\}}d|dd@tj@}|jd|d||d|fƒq(WdS(s2Show basic information for the largefiles dirstates%3oiiÿs%c %s %10d %s iiN(Rtopenlfdirstatetsortedt_mapt iteritemsRtumasktwrite(RERkt lfdirstatetfile_tenttmode((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyt debugdirstatezs"c Csútj||ƒ}|r1t|ƒt|ƒ@}ng}xŽ|D]†}y'||tj|ƒjƒjƒ}Wn.tk r›}|jtjkr•q>n‚nXtj ||ƒs>|j ||fƒq>q>W|rðt j |ƒ} | j |ƒ} | SggfS(s.cachelfiles ensures that all largefiles needed by the specified revision are present in the repository's largefile cache. returns a tuple (cached, missing). cached is the list of files downloaded by this operation; missing is the list of files that were needed but could not be found.(Rt listlfilesR)RZR`RaR]terrnotENOENTRbRuR§R¨R( RERkRtfilelistRQttogettlfilet expectedhashterrR«R((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyRcs$ 'c Csûtj|d|jtjƒgiƒ}d„}d}d}|gkr´xhtj||i|d6|ƒD]D}t|||j ƒƒ\}} |t |ƒ7}|t | ƒ7}qiWn|j t dƒ|ƒ|dkrñ|j t dƒ|ƒn||fS(NcSsdS(N((Rtfns((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pytprepare¡siR0s %d additional largefiles cached s!%d largefiles failed to download ( RRRR5RR6RtwalkchangerevsRcRR‘R"R ( RERkR0tmatchfnRÊt totalsuccesst totalmissingRRLtmissing((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pytdownloadlfilesžs     c CsŽ|jƒ}zptj||ƒ}ttj|ƒƒt|ƒB}|dk rtg|D]}||krS|^qS}nt}|rµ|rµ|jtdƒƒt }t ||d|ƒnd\} } x|D]y}t |||ƒ} | r | dkrÿ| | 7} q | | 8} n|rÈ| s| rÈ| rÈ|jtdƒƒt }qÈqÈW|j ƒ|r{|r{|jtdƒ| | fƒnWd|j ƒXdS(Nsgetting changed largefiles is"%d largefiles updated, %d removed (ii(R#RR¶R)RÁRRR"R RRct _updatelfileR»R ( RERkRÄt printmessageR#R¼RQRUtprintedtupdatedtremovedti((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyt updatelfiles°s4  (         c Cs\d}|j|ƒ}|jtj|ƒƒ}tjj|ƒrltjj|dƒr~tjj|ƒr~tj||dƒntj||ƒ}|dkr&tjj|ƒ sÄ|tj |ƒkr&tj |||ƒs||d krÿt j |dtƒn|j|ƒd S|j|ƒd}ntj|ƒj}|tj|ƒjkr°tj||ƒd}q°nDtjj|ƒr°|jj|ƒ|d kr°t j |ƒd}n|jtj|ƒ}|dkrt|dtƒrô|j|ƒqX|j|ƒnT|d kr |j|ƒn8|d kr<|j|ƒn|d krX|j|ƒn|S( s(updates a single largefile and copies the state of its standin from the repository's dirstate to its state in the lfdirstate. returns 1 if the file was modified, -1 if the file was removed, 0 if the file was unchanged, and None if the needed largefile was missing from the cache.is.origRt ignoremissingiiÿÿÿÿtnt _isrebasingtrtat?N(R5RRZR2R3R4R7tcopyfilet readstandinthashfilet copyfromcacheRRt unlinkpathRt normallookuptnormaltstattst_modetchmodRCt normalizetgetattrRtremoveR@tdrop( RkR¼RÆRtabslfilet absstandint expecthashR¿tstate((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyRÑÒsJ(           R c Ks¼||_|jdgƒ}|s9tjtdƒƒ‚ntj||ƒ}d}xM|D]E}|jtdƒ|ƒt|||ƒ\}}|t |ƒ7}qXW|j tdƒ|ƒdS(s0pull largefiles for the specified revisions from the specified source Pull largefiles that are referenced from local changesets but missing locally, pulling from a remote repository to the local cache. If SOURCE is omitted, the 'default' path will be used. See :hg:`help urls` for more information. .. container:: verbose Some examples: - pull largefiles for all branch heads:: hg lfpull -r "head() and not closed()" - pull largefiles on the default branch:: hg lfpull -r "branch(default)" R0sno revisions specifiedis#pulling largefiles for revision %s s%d largefiles cached N( t lfpullsourceRRR R RtrevrangetnoteRcR‘R"( RERkR­RIR´t numcachedR0tcachedRÏ((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pytlfpulls  tsR Rs9minimum size (MB) for files to be converted as largefilestSIZEs to-normals/convert from a largefiles repo to a normal repos#hg lfconvert SOURCE DEST [FILE ...]RVRÛR0s#pull largefiles for these revisionss--r REV... [-e CMD] [--remotecmd CMD] [SOURCE]Rõs lfconvert(,t__doc__R2RÂR7t mercurialRRR,RRRRRRRtmercurial.i18nR tmercurial.lockR RR§RVRBR1RvRsRrRjR“R{R®RRµRÀRRcRÐRR×RÑRõt remoteoptstcmdtablet inferrepo(((s?/sys/lib/python2.7/site-packages/hgext/largefiles/lfcommands.pyt sJ @   c 6 M       " < %