ó çƒQc@s‘dZddlmZmZddlmZddlZddlZdZdd„Z d„Z d„Z d „Z ie ged ƒfd 6ZdS( s-recreates hardlinks between repository clonesiÿÿÿÿ(thgtutil(t_Ntinternalc KsRtjtdƒ s&tjtdƒ r>tjtdƒƒ‚ntj|j|j|pYd|pbdƒƒ}|jtdƒ|j j |j j fƒ|j |j kr½|jtdƒƒdS|j ƒ}zw|j ƒ}zYt t||ƒƒ}t||j j |j j |ƒ}t|j j |j j ||ƒWd|jƒXWd|jƒXdS( s³recreate hardlinks between two repositories When repositories are cloned locally, their data files will be hardlinked so that they only use the space of a single repository. Unfortunately, subsequent pulls into either repository will break hardlinks for any files touched by the new changesets, even if both repositories end up pulling the same changes. Similarly, passing --rev to "hg clone" will fail to use any hardlinks, falling back to a complete copy of the source repository. This command lets you recreate those hardlinks and reclaim that wasted space. This repository will be relinked to share space with ORIGIN, which must be on the same local disk. If ORIGIN is omitted, looks for "default-relink", then "default", in [paths]. Do not attempt any read operations on this repository while the command is running. (Both repositories will be locked against writes.) tsamefilet samedevices*hardlinks are not supported on this systemsdefault-relinktdefaultsrelinking %s to %s sthere is nothing to relink N(Rt safehasattrtAbortRRt repositorytbaseuit expandpathtstatuststoretpathtroottlocktsortedtcollecttprunet do_relinktrelease( tuitrepotorigintoptstsrct locallockt remotelockt candidatesttargets((s0/sys/lib/python2.7/site-packages/hgext/relink.pytrelinks$)  !#c Cs—ttjjƒ}g}t|djƒƒ}|dd}|jj}d}|jtdƒ||fƒxòtj|ƒD]á\}}} |j ƒ|t|ƒ|} x±t | ƒD]£} | dd krÑqµntj tjj || ƒƒ} t j | jƒsqµn|d 7}|jtjj | | ƒ| fƒ|jtd ƒ|| td ƒ|ƒqµWq{W|jtd ƒdƒ|jtd ƒt|ƒƒ|S(Nttipiiis6tip has %d files, estimated total number of files: %s iþÿÿÿs.ds.iit collectingtfiless%collected %d candidate storage files (s.ds.i(tlentosRtseptmanifestR R RtwalktsortRtstattjointS_ISREGtst_modetappendtprogresstNone( RRtseplenRtlivettotaltpostdirpathtdirnamest filenamestrelpathtfilenametst((s0/sys/lib/python2.7/site-packages/hgext/relink.pyR?s.   "-c Cs d„}g}t|ƒ}d}x²|D]ª\}} |d7}tjj||ƒ} tjj||ƒ} || | | ƒ} | s—|jd|ƒq(n|j|| jfƒ|jtdƒ||tdƒ|ƒq(W|jtdƒdƒ|j tdƒt|ƒƒ|S(NcSs‚ytj|ƒ}Wntk r'tSXtj||ƒr>tStj||ƒshtjtdƒƒ‚n|j |j kr~tS|S(Ns/source and destination are on different devices( R$R)tOSErrortFalseRRRRRtst_size(RtdstR9tts((s0/sys/lib/python2.7/site-packages/hgext/relink.pyt linkfilter`s iisnot linkable: %s tpruningR"s,pruned down to %d probably relinkable files ( R#R$RR*tdebugR-R<R.RR/R ( RRR=RR?RR2R3tfnR9tsrcpathttgtR>((s0/sys/lib/python2.7/site-packages/hgext/relink.pyR_s"   )cCsÎd„}d}d}d}d}t|ƒ} x^|D]V\} } |d7}tjj|| ƒ} tjj|| ƒ} t| dƒ}t| dƒ}|j|ƒ}x8|rÛ|j|ƒ}||krÉPn|j|ƒ}q¤W|jƒ|jƒ|r |jd| ƒq4nyJ|| | ƒ|jt dƒ|| t dƒ| ƒ|d7}|| 7}Wq4t k r‰}|j d | t |ƒfƒq4Xq4W|jt dƒdƒ|jt d ƒ|tj|ƒfƒdS( NcSsf|d}tj||ƒytj||ƒWn$tk rTtj||ƒ‚nXtj|ƒdS(Ns.bak(R$trenameRtoslinkR:tremove(RR=tbak((s0/sys/lib/python2.7/site-packages/hgext/relink.pyt relinkfileƒs  iiitrbsnot linkable: %s t relinkingR"s%s: %s s!relinked %d files (%s reclaimed) (R#R$RR*tfiletreadtcloseRAR.RR:twarntstrR/R Rt bytecount(RR=R"RRItCHUNKLENtrelinkedt savedbytesR3R2tftsztsourceRDtsfptdfptsintdintinst((s0/sys/lib/python2.7/site-packages/hgext/relink.pyR‚sB        % %s[ORIGIN]R(t__doc__t mercurialRRtmercurial.i18nRR$R)t testedwithR/RRRRtcmdtable(((s0/sys/lib/python2.7/site-packages/hgext/relink.pyts / # 0