https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/mercurial/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/mercurial/__pycache__/setdiscovery.cpython-310.pyc
o

�]LbH�@s�dZddlmZddlZddlZddlmZddlmZddl	m
Z
mZmZddd	�Z
ddd�ZGd
d�de�ZeZejdded�Z	
		ddd�ZdS)a;
Algorithm works in the following way. You have two repository: local and
remote. They both contains a DAG of changelists.

The goal of the discovery protocol is to find one set of node *common*,
the set of nodes shared by local and remote.

One of the issue with the original protocol was latency, it could
potentially require lots of roundtrips to discover that the local repo was a
subset of remote (which is a very common case, you usually have few changes
compared to upstream, while upstream probably had lots of development).

The new protocol only requires one interface for the remote repo: `known()`,
which given a set of changelists tells you if they are present in the DAG.

The algorithm then works as follow:

 - We will be using three sets, `common`, `missing`, `unknown`. Originally
 all nodes are in `unknown`.
 - Take a sample from `unknown`, call `remote.known(sample)`
   - For each node that remote knows, move it and all its ancestors to `common`
   - For each node that remote doesn't know, move it and all its descendants
   to `missing`
 - Iterate until `unknown` is empty

There are a couple optimizations, first is instead of starting with a random
sample of missing, start by sending all heads, in the case where the local
repo is a subset, you computed the answer in one round trip.

Then you can do something similar to the bisecting strategy used when
finding faulty changesets. Instead of random samples, you can try picking
nodes that will maximize the number of nodes that will be
classified with it (since all ancestors or descendants will be marked as well).
�)�absolute_importN�)�_��nullrev)�error�policy�utilcCs�i}t�|�}t�}d}|r_|��}	|	|vrq|�|	d�}
|
|kr%|d9}|
|kr8|�|	�|r8t|�|kr8dS|�|	�||	�D]}|tkrZ|rM||vrZ|�||
d�|�|�qA|sdSdS)a[update an existing sample to match the expected size

    The sample is updated with revs exponentially distant from each head of the
    <revs> set. (H~1, H~2, H~4, H~8, etc).

    If a target size is specified, the sampling will stop once this size is
    reached. Otherwise sampling will happen until roots of the <revs> set are
    reached.

    :revs:  set of revs we want to discover (if None, assume the whole dag)
    :heads: set of DAG head revs
    :sample: a sample to update
    :parentfn: a callable to resolve parents for a revision
    :quicksamplesize: optional target size of the sampler�N)	�collections�deque�set�popleft�
setdefault�add�lenr�append)�revs�heads�sample�parentfn�quicksamplesize�dist�visit�seen�factor�curr�d�p�r�8/usr/lib/python3/dist-packages/mercurial/setdiscovery.py�
_updatesample9s,



��r!TcCsDt|�|kr|S|rtt�||��St|�}|��t|d|��S)z�return a random subset of sample of at most desiredlen item.

    If randomize is False, though, a deterministic subset is returned.
    This is meant for integration tests.
    N)rr
�randomr�list�sort)r�
desiredlen�	randomizerrr �_limitsample_sr'c@s~eZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	e
dd��Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)�partialdiscoveryaban object representing ongoing discovery

    Feed with data from the remote repository, this object keep track of the
    current set of changeset in various states:

    - common:    revs also known remotely
    - undecided: revs we don't have information on yet
    - missing:   revs missing remotely
    (all tracked revisions are known locally)
    TcCs<||_||_|j��|_d|_t�|_d|_||_	||_
dS�N)�_repo�_targetheads�	changelog�incrementalmissingrevs�_common�
_undecidedr
�missing�_childrenmap�_respectsizer&)�self�repo�targetheads�respectsizer&rrr �__init__zs
zpartialdiscovery.__init__cCs,|j�|�|jdur|j�|j�dSdS)zregister nodes known as commonN)r.�addbasesr/�removeancestorsfrom)r3�commonsrrr �
addcommons�s
�zpartialdiscovery.addcommonscCs6|j�d||j�}|r|j�|�|j�|�dSdS)zregister some nodes as missings%ld::%ldN)r*r�	undecidedr0�update�difference_update)r3�missings�
newmissingrrr �addmissings�s
�zpartialdiscovery.addmissingscCsXt�}t�}|D]\}}|r|�|�q|�|�q|r!|�|�|r*|�|�dSdS)z*consume an iterable of (rev, known) tuplesN)r
rr;rA)r3r�commonr0�rev�knownrrr �addinfo�s
�zpartialdiscovery.addinfocC�
|j��S)z6return True is we have any clue about the remote state)r.�hasbases�r3rrr �hasinfo�s
zpartialdiscovery.hasinfocCs|jduo|jS)z1True if all the necessary data have been gatheredN)r/rHrrr �
iscomplete�szpartialdiscovery.iscompletecCs*|jdur|jSt|j�|j��|_|jSr))r/r
r.�missingancestorsr+rHrrr r<�s
zpartialdiscovery.undecidedcCsdt|j�iS)Nr<)rr<rHrrr �stats�s
�zpartialdiscovery.statscCrF)z!the heads of the known common set)r.�
basesheadsrHrrr �commonheads�s
zpartialdiscovery.commonheadscs|jjjj��fdd�}|S)Ncs�|�dd�S)N��r)�r��getrevrr �
getparents�sz3partialdiscovery._parentsgetter.<locals>.getparents)r*r,�index�__getitem__)r3rTrrRr �_parentsgetter�szpartialdiscovery._parentsgettercCsz|jdur	|jjSi|_}|��}|j}t|�D] }g||<||�D]}|tkr*q#|�|�}|dur8|�|�q#q|jSr))r1rVrWr<�sortedr�getr)r3�children�
parentrevsrrC�prev�crrr �_childrengetter�s 



��z partialdiscovery._childrengettercCsb|j}t|�|kr
t|�St|j�d|��}t|�|kr$t|||jd�Std|||�	�|d�|S)atakes a quick sample of size <size>

        It is meant for initial sampling and focuses on querying heads and close
        ancestors of heads.

        :headrevs: set of head revisions in local DAG to consider
        :size: the maximum size of the sample�
heads(%ld)�r&N)r)
r<rr#r
r*rr'r&r!rW)r3�headrevs�sizerrrrr �takequicksample�s�z partialdiscovery.takequicksamplecCs|j}t|�|kr
t|�S|j}t|�d|��}|��}|��}t||||�t|�d|��}|�	�}	t||||	�|s>J�|j
sMt|tt|�t|���}t
|||jd�}t|�|kr�|t|�}
t||�}|jru|�t�||
��|S|��|�|d|
��|S)Nr_s
roots(%ld)r`)r<rr#r*r
rrW�copyr!r^r2�max�minr'r&r=r"rr$)r3rarbrr4rr[�	revsheads�	revsroots�childrenrevs�more�takefromrrr �takefullsample�s0�zpartialdiscovery.takefullsampleN�T)�__name__�
__module__�__qualname__�__doc__r7r;rArErIrJ�propertyr<rLrNrWr^rcrlrrrr r(ns 


r(�	discovery�PartialDiscovery)�member�defaultc(	s�t|�dd��}t��}d}|j}	|	j�|	j�|dur%�fdd�|D�}
n	dd�|	��D�}
|�dd�}|�	dd	�}|�	dd
�}
|r�|j
rOt|
|�}t|�}n|
}|�
d�|d7}|���}|�d
i�}|�dd�fdd�|D�i�}Wd�n1s~wY|��|��}}|dur�d|d<|	��tkr�||	jgkr�|	jgd|fS|	jgdgfSn|���}|�d
i�}Wd�n1s�wY|��}|�td��g}|D]}||	jkr�q�z	|��|��Wq�tjy�Yq�w|�r-t|�t|�k�r
|�
d�|d|fSt|�t|
�k�r-t|��r-|�td���fdd�|
D�}|d|fS|jj}|dd�}|�o<|j
}|dd�}|�pG|j
}|�dd�}|	jj�rWt}nt }|||
||d�}|�rq|�!|�|�"t#||��|}|j$td�td�d�}|�%��s|�s�|�&��r�|�r�|�td��n|�
d �|j'} |
}!|�r�t(|
|�}
n
|�
d!�|j)} |}!| |
|!�}|d7}|�*|�|�+�}"|�
d"||"d#t|�f�t|�}|���}|�dd�fd$d�|D�i���}Wd�n	1�s�wYd}|�"t#||��|�%��r�|�,�}#t��|}$|�-�|�
d%||$f�d&}%t.|#�t.|�}&|�/d'|%t|#�t|&�||$�|du�rF||d<|#�sh||	jgk�rh|�rZt�0td(���|�1td)��|	jhd|fS||	jgk}'�fd*d+�|#D�}#|#|'|fS),aReturn a tuple (common, anyincoming, remoteheads) used to identify
    missing nodes from or in remote.

    The audit argument is an optional dictionnary that a caller can pass. it
    will be updated with extra data about the discovery, this is useful for
    debug.
    sdevelsdiscovery.grow-sample.raterNc�g|]}�|��qSrr)�.0�n)�clrevrr �
<listcomp>6�z#findcommonheads.<locals>.<listcomp>cSsg|]}|tkr|�qSrr)rxrCrrr r{8ssdiscovery.exchange-headssdiscovery.sample-size.initialsdiscovery.sample-sizesquery 1; heads
rsheadssknownsnodescrwrr�rxrQ��clnoderr r{r|stotal-roundtripsTFssearching for changes
sall remote heads known locally
s$all local changesets known remotely
crwrrr}r~rr r{�r|sdiscovery.grow-samplesdiscovery.grow-sample.dynamicsdiscovery.randomizer`s	searchingsqueries)�unitssampling from both directions
staking initial sample
staking quick initial sample
s2query %i; still undecided: %i, sample size is: %i
r<crwrrr}r~rr r{�r|s%d total queries in %.4fs
sDfound %d common and %d unknown server heads, %d roundtrips in %.4fs
s	discoverysrepository is unrelateds!warning: repository is unrelated
csh|]}�|��qSrrr}r~rr �	<setcomp>r|z"findcommonheads.<locals>.<setcomp>)2�float�configr	�timerr,�noderCra�
configbool�	configint�limitedargumentsr'r#�debug�commandexecutor�callcommand�result�tiprevr�nullid�statusrrr�LookupErrorr�all�note�uirU�rust_ext_compatr(�pure_partialdiscoveryr;rE�zip�makeprogressrJrIrl�intrcr=rLrN�completer
�log�Abort�warn)(r��local�remote�abortwhenunrelated�ancestorsof�audit�samplegrowth�start�
roundtrips�cl�ownheads�initial_head_exchange�initialsamplesize�fullsamplesizer�e�fheads�fknown�
srvheadhashes�yesno�
knownsrvheadsr��
ownheadhashesr��grow_sample�dynamic_sample�hard_limit_sampler&�pd�disco�full�progress�
samplefunc�
targetsizerLr��elapsed�msgr0�anyincomingr)rrzr �findcommonheadss4



���	�
�
�








�


��
����
�)�
�
r�)rrm)TNN)rq�
__future__rrr"�i18nrr�r�rrr	r!r'�objectr(r��
importrustr�rrrr �<module>s&#

&(�	�

https://t.me/RX1948 - 2025