HEX
Server: Apache
System: Linux p102.lithium.hosting 4.18.0-553.141.1.el8_10.x86_64 #1 SMP Fri Jul 10 17:48:02 UTC 2026 x86_64
User: bvzmoamr (9955)
PHP: 8.1.34
Disabled: syslog
Upload Files
File: //proc/self/root/lib64/python2.7/site-packages/mercurial/pvec.pyo
�
1�3\c@@sdZddlmZddlmZddlmZmZdZedZ	dZ
e
dZe	eZedZ
e
d	d
Zd�Zd�Zd
�Zd�Zd�Zgejd�D]Zee�^q�Zd�Zd�Zd�Zd�Zdefd��YZdS(s3
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
i(tabsolute_importi(tnullrev(tpycompattutili�iiiicC@s/d}x"|D]}|dt|�}q
W|S(sconvert a bytestring to a longii(tord(tbstvtb((s4/usr/lib64/python2.7/site-packages/mercurial/pvec.pyt_binCs
cC@sBd}x5tj|�D]$}t|d@�|}|dL}qW|S(Nti�i(Rtxrangetchr(RtlRtp((s4/usr/lib64/python2.7/site-packages/mercurial/pvec.pyt_strJs
cC@st|t �t|t�fS(sdepth and bitvec(Rt_depthbytes(R((s4/usr/lib64/python2.7/site-packages/mercurial/pvec.pyt_splitQscC@st|t�t|t�S(N(RRt	_vecbytes(tdepthtbitvec((s4/usr/lib64/python2.7/site-packages/mercurial/pvec.pyt_joinUscC@s8d}x+|r3|d@r&|d7}n|dL}q	W|S(Nii((txtc((s4/usr/lib64/python2.7/site-packages/mercurial/pvec.pyt_hweightXs	

icC@s=||A}d}x&|r8|t|d@7}|dL}qW|S(s+find the hamming distance between two longsii�i(t_htab(taRtdR((s4/usr/lib64/python2.7/site-packages/mercurial/pvec.pyt_hammingas
	cC@s�|\}}|\}}||krE||||f\}}}}nt||�}||}|}	||A}
d}||kr�||dd}nd}||}
|
r�xG|r�|
|@r�|	|N}	|d8}n|dK}q�Wnt|	|�}	|
|	fS(Nii(Rt_flipbit(RtyRtd1tv1td2tv2thdisttddistRtmtitchangesR((s4/usr/lib64/python2.7/site-packages/mercurial/pvec.pyt	_mergevecjs*!


	


cC@s t|�d@t}|d|>AS(NI����i(thasht_vecbits(Rtnodetbit((s4/usr/lib64/python2.7/site-packages/mercurial/pvec.pyR�scC@sX|j�}tj|d�s*i|_n|j}|j�|kr/|j}x�tj|j�d�D]�}||krh|j|�}|j	|�\}}|t
kr�dt|dt �f||<q(|t
kr||\}}	|dt
|	|�f||<q(t|||||�||<qhqhWnt||j��}
ttj|
��S(s3construct a pvec for ctx while filling in the cachet
_pveccacheiii(trepoRtsafehasattrR,trevt	changelogRR
R*t
parentrevsRRRRR'Rtpvect	b85encode(tctxtrtpvctcltnR*tp1tp2RRR((s4/usr/lib64/python2.7/site-packages/mercurial/pvec.pytctxpvec�s$		 ! (R2cB@sYeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
RS(	cC@sOt|t�r<||_ttj|��\|_|_nt|�|_dS(N(	t
isinstancetstrt_bsRRt	b85decodet_deptht_vecR;(tselft	hashorctx((s4/usr/lib64/python2.7/site-packages/mercurial/pvec.pyt__init__�s	$cC@s|jS(N(R>(RB((s4/usr/lib64/python2.7/site-packages/mercurial/pvec.pyt__str__�scC@s"|j|jko!|j|jkS(N(RAR@(RBR((s4/usr/lib64/python2.7/site-packages/mercurial/pvec.pyt__eq__�scC@sC|j|j}|dkr tSt|j|j�|kr?tStS(Ni(R@tFalseRRAtTrue(RBRtdelta((s4/usr/lib64/python2.7/site-packages/mercurial/pvec.pyt__lt__�scC@s
||kS(N((RBR((s4/usr/lib64/python2.7/site-packages/mercurial/pvec.pyt__gt__�scC@s9t|j|j�}t|j|j�|kr5tStS(N(tabsR@RRARGRH(RBRRI((s4/usr/lib64/python2.7/site-packages/mercurial/pvec.pyt__or__�scC@s'||Brtd��n|j|jS(Nsconcurrent pvecs(t
ValueErrorR@(RBR((s4/usr/lib64/python2.7/site-packages/mercurial/pvec.pyt__sub__�s
cC@s8t|j|j�}t|j|j�}t||�S(N(RLR@RRAtmax(RBRRth((s4/usr/lib64/python2.7/site-packages/mercurial/pvec.pytdistance�scC@sEt|j|j�}|tks=t|j|j�tkrAtSdS(N(RLRR@t_radiusRRARG(RBRtdist((s4/usr/lib64/python2.7/site-packages/mercurial/pvec.pytnear�s'(t__name__t
__module__RDRERFRJRKRMRORRRU(((s4/usr/lib64/python2.7/site-packages/mercurial/pvec.pyR2�s								N(t__doc__t
__future__RR*RR	RRt_sizet_bytest
_depthbitsRRR)RSRRRRRR
RRRR'RR;tobjectR2(((s4/usr/lib64/python2.7/site-packages/mercurial/pvec.pyt<module>1s*



					(			%