^cydZddlZddlZddlmZddlmZddlmZm Z m Z m Z ddl m Z mZiZe jeZdZedged ej dd Zd Zd ZdZdS)z-recreates hardlinks between repository clonesN)_)open)errorhg registrarutil) stringutilurlutilsships-with-hg-corerelinks[ORIGIN]) helpcategoryc (tjtdrtjtds!tjt d| d|jvrd}t jd|||\}}tj |j |}| t d|j j |j j fz|j|jkr$| t ddStj|j j |j j s!tjt d |5|5t#t%||}t'||j j |j j |}t)|j j |j j ||dddn #1swxYwYddddS#1swxYwYdS) arecreate 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.) ssamefiles samedevices*hardlinks are not supported on this systemNsdefault-relinkr srelinking %s to %s sthere is nothing to relink /source and destination are on different devices)r safehasattrrAbortrpathsr get_unique_pull_pathr repositorybaseuistatusstorepathroot samedevicelocksortedcollectprune do_relink) uirepooriginoptsr__src candidatestargetss ./usr/lib/python3/dist-packages/hgext/relink.pyrelinkr(#sl8  D+ . .Ld6F m77Lk!IJJKKK ~+rx77"+ItRHHHD" - T * *CIIa'((CINDJO+LLMMM yCH !344555 ?39>4:? ; ;Qk!NOOPPP @@chhjj@@GC,,--  CINDJORHH#).$*/7B???@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@s7$H9A*G/# H/G3 3H6G3 7HH H cttjj}g}t|d}|dzdz}|jj}|tdtd|}d}|td||fztj |D]\}} } | |t||zd} t| D]} | d dd vrtj tj || } tj| js[|d z }|tj | | | f||| ||td t|z|S)Nstips collectingfilesunittotalrs6tip has %d files, estimated total number of files: %d )s.ds.iitems%collected %d candidate storage files )lenosrsepmanifestr makeprogressrrwalksortrstatjoinS_ISREGst_modeappendupdatecomplete)r$rseplenr%liver/progressposdirpathdirnames filenamesrelpathfilenamests r'rrWs   FJ s6{##%% & &D 1HME ).Cq//akkOOH CII DEE - )+ 0 0$9 #c((V+--.y)) 0 0H}N22gx8899B< ++  1HC   rw||GX>>C D D D OOChO / / / / 0 IIa9::S__LMMM cnd}g}|tdtdt|}d}|D]\}} |dz }tj||} tj||} || | | } | s|d|zr||| jf| ||| | td t|z|S) Nc tj|}n#t$rYdSwxYwtj||rdStj||s!t jtd|j |j krdS|S)NFr) r5r;OSErrorrsamefilerrrrst_size)r$dstrKtss r' linkfilterzprune..linkfilter|s BB   55  =c " " 5sC(( +DEE  : # #5 s  %%spruningr,r-rr1not linkable: %s r2s,pruned down to %d probably relinkable files ) r8rr4r5rr<debugr?rQr@rAr) r%r$rRrrTr&rDrEfnrKsrcpathtgtrSs r'rr{sD"G * AhKKs:H C & &B q',,sB''gll3## Zb ) )  HH*R/ 0 0 0 BJ'((("%%%% II :;;c'llJ NrLc d}d}d}d}|tdtdt|}d} |D]j\} } | dz } tj|| } tj|| } t | d}t | d}||}|r3||}||krn||}|3|||r| d | z || | | | | |dz }|| z }(#t$r7}| d | tj|fzYd}~dd}~wwxYw||td |t#j|fzdS) Nc|dz}tj|| tj||n$#t$rtj||wxYwtj|dS)Ns.bak)r5renameroslinkrOremove)r$rRbaks r' relinkfilezdo_relink..relinkfileszGm #s  KS ! ! ! !    Ic3      #s 2!Airs relinkingr,r-r1srbrUr2s%s: %s s!relinked %d files (%s reclaimed) )r8rr4r5rr<rreadcloserVr@rOwarnr forcebytestrrArr bytecount)r$rRfilesrr`CHUNKLENrelinked savedbytesrDrEfszsourcerYsfpdfpsindininsts r'rrsCHHJ ,akkUH CHH2 qc1%%gll3""65!!3hhx   %((8$$Cczz((8$$C  %    HH*Q. / / /  H Jvs # # # OOCaO ( ( ( MH " JJ H H H GGK3 (?(E(E"FF G G G G G G G G H II /00 T^J// 0 1s-E55 F6?,F11F6)N)__doc__r5r;mercurial.i18nrmercurial.pycompatr mercurialrrrrmercurial.utilsr r cmdtablecommand testedwithCATEGORY_MAINTENANCEr(rrrrLr'r|sM43 ######   ) H % % #   r11[>>0L.@.@.@.@b!!!H&&&R22222rL