ó
    6°hÈ  ã                  ó  • S r SSKJr  SSKJr  SSKJrJr  Sr\S-  r	Sr
\
S-  r\	\-
  r\S-  r\S	-
  S
-  rS rSS jrS rS rS r\" S5       V s/ s H  n \" U 5      PM     sn rS rS rS rS r " S S5      rgs  sn f )a3  
A "pvec" is a changeset property based on the theory of vector clocks
that can be compared to discover relatedness without consulting a
graph. This can be useful for tasks like determining how a
disconnected patch relates to a repository.

Currently a pvec consist of 448 bits, of which 24 are 'depth' and the
remainder are a bit vector. It is represented as a 70-character base85
string.

Construction:

- a root changeset has a depth of 0 and a bit vector based on its hash
- a normal commit has a changeset where depth is increased by one and
  one bit vector bit is flipped based on its hash
- a merge changeset pvec is constructed by copying changes from one pvec into
  the other to balance its depth

Properties:

- for linear changes, difference in depth is always <= hamming distance
- otherwise, changes are probably divergent
- when hamming distance is < 200, we can reliably detect when pvecs are near

Issues:

- hamming distance ceases to work over distances of ~ 200
- detecting divergence is less accurate when the common ancestor is very close
  to either revision or total distance is high
- this could probably be improved by modeling the relation between
  delta and hdist

Uses:

- a patch pvec can be used to locate the nearest available common ancestor for
  resolving conflicts
- ordering of patches can be established without a DAG
- two head pvecs can be compared to determine whether push/pull/merge is needed
  and approximately how many changesets are involved
- can be used to find a heuristic divergence measure between changesets on
  different branches
é    )Úannotationsé   )Únullrev)ÚpycompatÚutiliÀ  é   é   é   é   c                ó>   • SnU  H  nUS-  [        U5      -   nM     U$ )zconvert a bytestring to a longr   é   )Úord)ÚbsÚvÚbs      Ú0/usr/lib/python3/dist-packages/mercurial/pvec.pyÚ_binr   D   s(   € à	€AÛˆØ�‰G”c˜!“fÑŠñ à€Hó    c                óp   • Sn[        U5       H$  n[        R                  " U S-  5      U-   nU S-  n M&     U$ )Nr   éÿ   r   )Úranger   Úbytechr)r   Úlr   Úps       r   Ú_strr   L   s>   € Ø	€BÜ�1ŽXˆÜ×Ò˜a #™gÓ&¨Ñ+ˆØ	ˆa‰Šñ ð €Ir   c                óJ   • [        U S[         5      [        U [        S 5      4$ )zdepth and bitvecN)r   Ú_depthbytes)r   s    r   Ú_splitr   T   s#   € ä��,”;�Ó ¤$ q¬¨ Ó"7Ð7Ð7r   c                óD   • [        U [        5      [        U[        5      -   $ ©N)r   r   Ú	_vecbytes)ÚdepthÚbitvecs     r   Ú_joinr$   Y   s   € Ü�”{Ó#¤d¨6´9Ó&=Ñ=Ð=r   c                óR   • SnU (       a  U S-  (       a  US-  nU S-  n U (       a  M  U$ )Nr   r   © )ÚxÚcs     r   Ú_hweightr)   ]   s1   € Ø	€AÞ
Øˆq�5Ø�‰FˆAØ	ˆa‰ˆ÷ ˆ!ð €Hr   r   c                óZ   • X-  nSnU(       a  U[         US-     -  nUS-  nU(       a  M  U$ )z+find the hamming distance between two longsr   r   r   )Ú_htab)Úar   Údr(   s       r   Ú_hammingr.   i   s:   € à	‰€AØ	€AÞ
Ø	ŒU�1�t‘8‰_ÑˆØ	ˆa‰ˆ÷ ˆ!ð €Hr   c                ó  • U u  p4Uu  pVX5:  a  XSXd4u  p5pF[        XF5      nX5-
  nUn	XF-  n
SnXx:”  a  Xx-
  S-   S-  nOSnX<-   nU
(       a*  U(       a   X«-  (       a	  X›-  n	US-  nUS-  nU(       a  M   XÙ4$ [        X’5      n	XÙ4$ )Nr   r   )r.   Ú_flipbit)r'   Úyr(   Úd1Úv1Úd2Úv2ÚhdistÚddistr   ÚmÚiÚchangesr"   s                 r   Ú	_mergevecr;   s   s´   € ð
 �F€BØ�F€BØ	ƒwØ ˜‰ˆ�ä�RÓ€EØ‰G€EØ
€AØ
‰€AØ	€Aàƒ}ð ‘= 1Ñ$¨Ñ*‰ð ˆØ‰L€Eö 	ÞØ�uØ‘�Ø˜1‘�Ø�!‰GˆA÷	 ˆgð ˆ8€Oô �Q‹Nˆàˆ8€Or   c                ó<   • [        U5      S-  [        -  nU SU-  -  $ )Nl   ÿÿ r   )ÚhashÚ_vecbits)r   ÚnodeÚbits      r   r0   r0   ™   s#   € ä�‹:˜
Ñ"¤hÑ
.€CØ��S‘‰>Ðr   c                ól  • U R                  5       n[        US5      (       d  0 Ul        UR                  nU R                  5       U;  a¶  UR                  n[        U R                  5       S-   5       HŠ  nXB;  d  M
  UR                  U5      nUR                  U5      u  pgU[        :X  a  S[        US-  S[         5      4X$'   MS  U[        :X  a  X&   u  p‰US-   [        X•5      4X$'   Mw  [        X&   X'   U5      X$'   MŒ     [        X R                  5          6 n
[        [        R                   " U
5      5      $ )z3construct a pvec for ctx while filling in the cacheÚ
_pveccacher   r   é   N)ÚrepoÚhasattrrB   ÚrevÚ	changelogr   r?   Ú
parentrevsr   r   r!   r0   r;   r$   Úpvecr   Ú	b85encode)ÚctxÚrÚpvcÚclÚnr?   Úp1Úp2r-   r   r   s              r   ÚctxpvecrR   Ÿ   s   € à�‰‹
€AÜ�1�l×#Ñ#ØˆŒØ
�,‰,€CØ
‡w�wƒy˜ÓØ�[‰[ˆÜ�s—w‘w“y 1‘}Ö%ˆAØ�|Ø—w‘w˜q“z�ØŸ™ qÓ)‘�Øœ“=à¤ t¨a¡x°´)Ð&<Ó!=Ð>�C“FØœ7“]Ø™7‘D�AØ !™e¤X¨aÓ%6Ð7�C“Fä& s¡w°±¸Ó>�C“Fñ &ô 
�—G‘G“I‘Ð	€BÜ”—’˜rÓ"Ó#Ð#r   c                  óJ   • \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rSrg)rI   é·   c                ó´   • [        U[        5      (       a3  Xl        [        [        R
                  " U5      5      u  U l        U l        g [        U5      U l        g r    )	Ú
isinstanceÚbytesÚ_bsr   r   Ú	b85decodeÚ_depthÚ_vecrR   )ÚselfÚ	hashorctxs     r   Ú__init__Úpvec.__init__¸   s<   € Ü�i¤×'Ñ'Ø ŒHÜ%+¬D¯NªN¸9Ó,EÓ%FÑ"ˆDŒK˜�ä 	Ó*ˆD�Ir   c                ó   • U R                   $ r    )rX   )r\   s    r   Ú__str__Úpvec.__str__¿   s   € Ø�x‰xˆr   c                ót   • U R                   UR                   :H  =(       a    U R                  UR                  :H  $ r    )r[   rZ   ©r\   r   s     r   Ú__eq__Úpvec.__eq__Â   s'   € Ø�y‰y˜AŸF™FÑ"×> t§{¡{°a·h±hÑ'>Ð>r   c                óŽ   • UR                   U R                   -
  nUS:  a  g[        U R                  UR                  5      U:”  a  gg)Nr   FT)rZ   r.   r[   ©r\   r   Údeltas      r   Ú__lt__Úpvec.__lt__Å   s;   € Ø—‘˜4Ÿ;™;Ñ&ˆØ�1‹9ØÜ�D—I‘I˜qŸv™vÓ&¨Ó.ØØr   c                ó
   • X:  $ r    r&   rd   s     r   Ú__gt__Úpvec.__gt__Í   s	   € Ø‰xˆr   c                ó’   • [        UR                  U R                  -
  5      n[        U R                  UR                  5      U::  a  gg)NFT)ÚabsrZ   r.   r[   rh   s      r   Ú__or__Úpvec.__or__Ð   s6   € Ü�A—H‘H˜tŸ{™{Ñ*Ó+ˆÜ�D—I‘I˜qŸv™vÓ&¨%Ó/ØØr   c                ó\   • X-  (       a  [        S5      eU R                  UR                  -
  $ )Ns   concurrent pvecs)Ú
ValueErrorrZ   rd   s     r   Ú__sub__Úpvec.__sub__Ö   s&   € Ø�8ÜÐ0Ó1Ð1Ø�{‰{˜QŸX™XÑ%Ð%r   c                óœ   • [        UR                  U R                  -
  5      n[        U R                  UR                  5      n[	        X#5      $ r    )rp   rZ   r.   r[   Úmax)r\   r   r-   Úhs       r   ÚdistanceÚpvec.distanceÛ   s7   € Ü�—‘˜4Ÿ;™;Ñ&Ó'ˆÜ�T—Y‘Y §¡Ó'ˆÜ�1‹yÐr   c                ó®   • [        UR                  U R                  -
  5      nU[        :”  d(  [	        U R
                  UR
                  5      [        :”  a  gg )NF)rp   r"   rZ   Ú_radiusr.   r[   )r\   r   Údists      r   ÚnearÚ	pvec.nearà   s?   € Ü�1—7‘7˜TŸ[™[Ñ(Ó)ˆØ”'‹>œX d§i¡i°·±Ó8¼7ÓBØð Cr   )rX   rZ   r[   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r^   ra   re   rj   rm   rq   ru   rz   r   Ú__static_attributes__r&   r   r   rI   rI   ·   s/   † ò+òò?òòòò&ò
õ
r   rI   N)r   Úintr   r†   ÚreturnrW   )Ú__doc__Ú
__future__r   r?   r   Ú r   r   Ú_sizeÚ_bytesÚ
_depthbitsr   r!   r>   r}   r   r   r   r$   r)   r   r+   r.   r;   r0   rR   rI   )r'   s   0r   Ú<module>rŽ      s³   ðñ)õV #å ÷ð
 	€Ø	�!‰€Ø€
Ø˜A‰o€Ø�[Ñ €	Ø�q‰=€Ø�b‰=˜QÑ
€òôò8ò
>òñ $ CœjÓ)šj˜‰�!Ž™jÑ)€òò#òLò$÷0,ò ,ùòc 	*s   ÁA>