
    6hQ                        S r SSKJr  SSKrSSKrSSKJr  SSKJrJ	r	J
r
Jr  SSKJrJr  0 r\
R                   " \5      rSr\" S/ \" S	5      \R$                  S
9SS j5       rS rS rS rg)z-recreates hardlinks between repository clones    )annotationsN)_)errorhg	registrarutil)
stringutilurlutils   ships-with-hg-core   relinks   [ORIGIN])helpcategoryc                   [        [        S5      (       a  [        [        S5      (       d  [        R                  " [	        S5      5      eUc  SU R
                  ;   a  Sn[        R                  " SX5      n[        R                  " UR                  UR                  5      nU R                  [	        S5      UR                  R                  UR                  R                  4-  5        UR                  UR                  :X  a  U R                  [	        S5      5        g[        R                   " UR                  R                  UR                  R                  5      (       d  [        R                  " [	        S	5      5      eUR#                  5          UR#                  5          [%        ['        XP5      5      n[)        XeR                  R                  UR                  R                  U 5      n[+        UR                  R                  UR                  R                  Xp5        SSS5        SSS5        g! , (       d  f       N= f! , (       d  f       g= f)
ao  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.)
samefile
samedevices*   hardlinks are not supported on this systemNs   default-relinkr   s   relinking %s to %s
s   there is nothing to relink
/   source and destination are on different devices)hasattrr   r   Abortr   pathsr
   get_unique_pull_path_objr   
repositorybaseuilocstatusstorepathrootr   locksortedcollectprune	do_relink)uirepooriginoptsr   src
candidatestargetss           ./usr/lib/python3/dist-packages/hgext/relink.pyrelinkr)   $   sf   8 4$$GD,,G,Gkk!IJKK~+rxx7"++IrBD
--TXX
.CIIa'(CIINNDJJOO+LLMyyCHH
		!345??399>>4::??;;kk!NOPP	chhjGC,-

IINNDJJOORH#))..$**//7? !jjs%   I!A?H1 I1
H?	;I
Ic                   [        [        R                  R                  5      n/ n[        U S   R	                  5       5      nUS-  S-  nU R
                  R                  n UR                  [        S5      [        S5      US9nSnUR                  [        S5      XE4-  5        [        R                  " U 5       H  u  pn
U	R                  5         U[        U 5      U-   S  n[        U
5       H  nUS	S  S
;  a  M  [        R                  " [        R                  R                  X5      5      n[        R                  " UR                  5      (       d  Mh  US-  nUR!                  [        R                  R                  X5      U45        UR#                  X|S9  M     M     UR%                  5         UR                  [        S5      [        U5      -  5        U$ )Ns   tip      s
   collecting   filesunittotalr   s6   tip has %d files, estimated total number of files: %d
)s   .ds   .i   items%   collected %d candidate storage files
)lenosr   sepmanifestr   makeprogressr   r   walksortr   statjoinS_ISREGst_modeappendupdatecomplete)r%   r!   seplenr&   liver0   progressposdirpathdirnames	filenamesrelpathfilenamests                 r(   r   r   V   s|   FJs6{##%&D 1HME
))..Cq/akOH
CII	
DE-	 )+$9#c(V+-.y)H}N2g89B<<

++1HCrww||G>CDOOCO/ * )5 IIa9:S_LM    c                   S n/ nUR                  [        S5      [        S5      [        U 5      S9nSnU  H  u  pUS-  n[        R                  R                  X5      n
[        R                  R                  X(5      nU" XU	5      nU(       d  UR                  SU-  5        Mn  UR                  XR                  45        UR                  XxS9  M     UR                  5         UR                  [        S	5      [        U5      -  5        U$ )
Nc                6    [         R                  " U5      n[        R                  " X5      (       a  g[        R
                  " X5      (       d  [        R                  " [        S5      5      eUR                  UR                  :w  a  gU$ ! [         a     gf = f)NFr   )
r6   r<   OSErrorr   r   r   r   r   r   st_size)r%   dstrL   tss       r(   
linkfilterprune.<locals>.linkfilter{   s    	B ==""s((++DE  ::#	  		s   B 
BBs   pruningr-   r.   r   r2      not linkable: %s
r3   s,   pruned down to %d probably relinkable files
)r9   r   r5   r6   r   r=   debugr@   rQ   rA   rB   r   )r&   r%   rR   r!   rT   r'   rE   rF   fnrL   srcpathtgtrS   s                r(   r   r   z   s    " G	*AhKs:  H Cq'',,s'ggll3#b)HH*R/0JJ'(%  II	
:;c'lJ NrM   c           	        S nSnSnSnUR                  [        S5      [        S5      [        U5      S9nSn	U GH  u  pU	S-  n	[        R                  R                  X
5      n[        R                  R                  X5      n[        US5       n[        US5       nUR                  U5      nU(       a2  UR                  U5      nUU:w  a  OUR                  U5      nU(       a  M2  U(       a'  UR                  S	U
-  5         S S S 5        S S S 5        M   S S S 5        S S S 5         U" X5        UR                  XS
9  US-  nX{-  nGM     UR                  5         UR                  [        S5      U[         R"                  " U5      4-  5        g ! , (       d  f       N= f! , (       d  f       N= f! [         a6  nUR                  SU[        R                  " U5      4-  5         S nAGM  S nAff = f)Nc                    US-   n[         R                  " X5         [        R                  " X5        [         R
                  " U5        g ! [         a    [         R                  " X!5        e f = f)Ns   .bak)r6   renamer   oslinkrP   remove)r%   rR   baks      r(   
relinkfiledo_relink.<locals>.relinkfile   sU    Gm
		#	KK! 			#  	IIc	s   A
 
"A,i   r   s	   relinkingr-   r.   r2   rbrV   r3   s   %s: %s
s!   relinked %d files (%s reclaimed)
)r9   r   r5   r6   r   r=   openreadrW   rA   rP   warnr	   forcebytestrrB   r   r   	bytecount)r%   rR   filesr!   ra   CHUNKLENrelinked
savedbytesrE   rF   fszsourcerZ   sfpdfpsindininsts                      r(   r    r       s    HHJ	,akU  H Cqc%ggll3"&$3S$3((8$Chhx(#:hhx(	 # .23 )8  )8	Hv#OOCO(MHJ) 0 II	
/0T^^J/
0	1+ )8   	HGGK3
(?(?(E"FFGG	HsI   F!A	F'FF!F!' F2
FF!!
F/	2
G2<*G--G2)N)__doc__
__future__r   r6   r<   mercurial.i18nr   	mercurialr   r   r   r   mercurial.utilsr	   r
   cmdtablecommand
testedwithCATEGORY_MAINTENANCEr)   r   r   r     rM   r(   <module>r      s    4 " 	   
 


H
%
 #
 	r1[>0L0L,@,@^!H&R0rM   