
    6h                    R    S SK Jr  SSKJr  SSKJr  S rS rS rS r	S	 r
S
 rS rg)    )annotations   )_)mdiffc              #  &  #    0 nU R                   R                  [        S5      [        U5      [        U5      -   [        S5      S9nU HK  nUR	                  5         [        UR                  5       5      nXc;  a  U/X6'   M8  X6   R                  U5        MM     U Hb  nUR	                  5         UR                  5       n[        U5      nUR                  U/ 5       H  nXxR                  5       :X  d  M  X4v     M`     Md     UR                  5         g7f)zfind renamed files that have no changes

Takes a list of new filectxs and a list of removed filectxs, and yields
(before, after) tuples of exact matches.
s   searching for exact renames   files)totalunitN)
uimakeprogressr   len	incrementhashdataappendgetcomplete)	repoaddedremovedhashesprogressfctxhadatarfctxs	            3/usr/lib/python3/dist-packages/mercurial/similar.py_findexactmatchesr      s      Fww##	
()5zCL(x[ $ H
 ?FIIT"  		KZZ2&E

$m#	 '	  s   C,D2Dc                R    U R                  5       nU[        R                  " U5      4$ N)r   r   splitnewlines)r   origs     r   _ctxdatar#   5   s#    99;D$$T***    c                    Uu  p#U R                  5       nSn[        R                  " XB5      nU H  u  pxpX9U
  H  nU[        U5      -  nM     M!     [        U5      [        U5      -   nUS-  U-  $ )Nr   g       @)r   r   blocksr   )r   	otherdatar"   linestextequalmatchesx1x2y1y2linelengthss                r   _scorer2   ;   sv    KD99;D Ell4&G!RLDSYE ! " $i#d)#G3;  r$   c                ,    [        U [        U5      5      $ r    )r2   r#   )fctx1fctx2s     r   scorer6   J   s    %%))r$   c              #    #    0 nU R                   R                  [        S5      [        S5      [        U5      S9nU HZ  nUR	                  5         SnU H?  nUR                  USU45      S   n	Uc  [        U5      n[        X5      n
X:  d  M:  Xj4XH'   MA     M\     UR                  5         UR                  5        H  u  pUu  pXU4v   M     g7f)zfind potentially renamed files based on similar file content

Takes a list of new filectxs and a list of removed filectxs, and yields
(before, after, score) tuples of partial matches.
s   searching for similar filesr   )r
   r	   Nr   )
r   r   r   r   r   r   r#   r2   r   items)r   r   r   	thresholdcopiesr   rr   a	bestscoremyscoredestvsourcebscores                  r   _findsimilarmatchesrC   N   s      Fww##	
()(3w< $ H A

1tY&78;I|{QoG"L	   <<>F"" "s   BCACc                \    U  Vs/ s H  oR                  5       S:  d  M  UPM     sn$ s  snf )Nr   )size)fctxsxs     r   
_dropemptyrH   i   s$    -u!1Au---s   ))c              #    ^^#    U S   mTR                  5       m[        U4S j[        U5       5       5      n[        U4S j[        U5       5       5      n[        5       n[	        XU5       H9  u  pxUR                  U5        UR                  5       UR                  5       S4v   M;     US:  aS  U V	s/ s H  oU;  d  M
  U	PM     nn	[        XXS5       H)  u  pxn
UR                  5       UR                  5       U
4v   M+     ggs  sn	f 7f)z:find renamed files -- yields (before, after, score) tuplesNc              3  .   >#    U  H
  nTU   v   M     g 7fr     ).0fpwctxs     r   	<genexpr>findrenames.<locals>.<genexpr>u   s     =}DH}s   c              3  <   >#    U  H  oT;   d  M
  TU   v   M     g 7fr    rK   )rL   rM   pctxs     r   rO   rP   v   s     O2$Jhd2hs   	g      ?)p1rH   sortedsetr   addpathrC   )r   r   r   r9   
addedfilesremovedfilesmatchedfilesr<   brG   r6   rR   rN   s              @@r   findrenamesr\   m   s     :D779D
 =ve}==JOOOL 5L!$LAvvx3'' B
 3!+EA/Da
E.l
KA% 668QVVXu--
 Es   B/D3	D DADN)
__future__r   i18nr    r   r   r#   r2   r6   rC   rH   r\   rK   r$   r   <module>r`      s6    # 
"J+!*#6..r$   