403Webshell
Server IP : 50.21.180.56  /  Your IP : 216.73.216.208
Web Server : Apache
System : Linux info 3.0 #1337 SMP Tue Jan 01 00:00:00 CEST 2000 all GNU/Linux
User : ws67922704 ( 67922704)
PHP Version : 8.5.13
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /kunden/lib/python3/dist-packages/breezy/bzr/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /kunden/lib/python3/dist-packages/breezy/bzr/__pycache__/index.cpython-313.pyc
�

p��g�<��J�Sr/SQrSSKrSSKJr SSKJr SSKJr \"\"5S5 SS	K	J
r
Jr SS
K	Jr
 SrSrS
rSrSr"SS\R&5r"SS\R&5r"SS\R&5r"SS\R&5r"SS\R&5r"SS\R&5r\R4"S5r\R4"S5rSrSr"S S!5r"S"S#5r "S$S%5r!"S&S'\5r""S(S)5r#S*r$S+r%g),zIndexing facilities.)�CombinedGraphIndex�
GraphIndex�GraphIndexBuilder�GraphIndexPrefixAdapter�InMemoryGraphIndex�N)�bisect_right)�BytesIO�)�lazy_importzX
from breezy import (
    bisect_multi,
    revision as _mod_revision,
    trace,
    )
)�debug�errors)�	transport)r��s
key_elements=slen=snode_ref_lists=sBazaar Graph Index 1
c��\rSrSrSrSrSrg)�BadIndexFormatSignature�5z,%(value)s is not an index of type %(_type)s.c�Z�[RRU5 XlX lg�N)r
�BzrError�__init__�value�_type)�selfrrs   �2/usr/lib/python3/dist-packages/breezy/bzr/index.pyr� BadIndexFormatSignature.__init__8s����� � ��&��
��
�)rrN��__name__�
__module__�__qualname__�__firstlineno__�_fmtr�__static_attributes__�rrrr5s��9�D�rrc��\rSrSrSrSrSrg)�BadIndexData�>z"Error in data for index %(value)s.c�N�[RRU5 Xlgr�r
rrr�rrs  rr�BadIndexData.__init__A������ � ��&��
r�rNrr$rrr&r&>s��/�D�rr&c��\rSrSrSrSrSrg)�BadIndexDuplicateKey�Fz2The key '%(key)s' is already in index '%(index)s'.c�Z�[RRU5 XlX lgr)r
rr�key�index)rr2r3s   rr�BadIndexDuplicateKey.__init__Is����� � ��&����
r)r3r2Nrr$rrr/r/Fs��?�D�rr/c��\rSrSrSrSrSrg)�BadIndexKey�Oz%The key '%(key)s' is not a valid key.c�N�[RRU5 Xlgr)r
rrr2�rr2s  rr�BadIndexKey.__init__Rs����� � ��&��r)r2Nrr$rrr6r6Os��2�D�rr6c��\rSrSrSrSrSrg)�BadIndexOptions�Wz,Could not parse options for index %(value)s.c�N�[RRU5 Xlgrr)r*s  rr�BadIndexOptions.__init__Zr,rr-Nrr$rrr<r<Ws��9�D�rr<c��\rSrSrSrSrSrg)�
BadIndexValue�_z+The value '%(value)s' is not a valid value.c�N�[RRU5 Xlgrr)r*s  rr�BadIndexValue.__init__br,rr-Nrr$rrrArA_s��8�D�rrAs	[	

 ]s[
]c�*�XRU/5;$)z�Check if this index has one key.

If it's possible to check for multiple keys at once through
calling get_parent_map that should be faster.
)�get_parent_mapr9s  r�_has_key_from_parent_maprGks���%�%�s�e�,�,�,rc�N�[U5[URU55-
$r)�setrF�r�keyss  r�_missing_keys_from_parent_maprLts!���t�9�s�4�.�.�t�4�5�5�5rc�f�\rSrSrSrSSjrSrSrSrSr	Sr
SS	jrS
rSr
SS
jrSrSrg)r�xa�A builder that can build a GraphIndex.

The resulting graph has the structure::

  _SIGNATURE OPTIONS NODES NEWLINE
  _SIGNATURE     := 'Bazaar Graph Index 1' NEWLINE
  OPTIONS        := 'node_ref_lists=' DIGITS NEWLINE
  NODES          := NODE*
  NODE           := KEY NULL ABSENT? NULL REFERENCES NULL VALUE NEWLINE
  KEY            := Not-whitespace-utf8
  ABSENT         := 'a'
  REFERENCES     := REFERENCE_LIST (TAB REFERENCE_LIST){node_ref_lists - 1}
  REFERENCE_LIST := (REFERENCE (CR REFERENCE)*)?
  REFERENCE      := DIGITS  ; digits is the byte offset in the index of the
                            ; referenced key.
  VALUE          := no-newline-no-null-bytes
c�r�Xl0Ul[5UlSUlX lSUlSUlg)z�Create a GraphIndex builder.

:param reference_lists: The number of node references lists for each
    entry.
:param key_elements: The number of bytestrings in each key.
NFT)�reference_lists�_nodesrI�_absent_keys�
_nodes_by_key�_key_length�_optimize_for_size�_combine_backing_indices)rrP�key_elementss   rr�GraphIndexBuilder.__init__�s9�� /������E���!���'��"'���(,��%rc��[U5[4;a[U5eUR[	U5:wa[U5eUH@nU(a-[U[5(a[RU5cM7[U5e g)z;Raise BadIndexKey if key is not a valid key for this index.N)	�type�tupler6rT�len�
isinstance�bytes�_whitespace_re�search)rr2�elements   r�
_check_key�GraphIndexBuilder._check_key�sn����9�U�H�$��c�"�"����s�3�x�'��c�"�"��G��!�'�5�1�1�!�(�(��1�=�!�#�&�&�
rc���[5n[5nURS:�aFUR5H.nURUS5 UR	USS5 M0 X!-
$[5$)�5Return references that are not present in this index.��)rIrP�iter_all_entries�add�update)rrK�refs�nodes    r�_external_references�&GraphIndexBuilder._external_references�sj���u���u�����!�#��-�-�/������a��!����D��G�A�J�'�0��;��
�5�Lrc���URc�0nUR(aZURR5H;unup4nU(aMUnUSSHnUR	U05nM X%U4XbS'M= OXURR5H:unup4nU(aMUnUSSHnUR	U05nM X%4XbS'M< XlUR$�N���)rSrPrQ�items�
setdefault)r�nodes_by_keyr2�absent�
referencesr�key_dict�subkeys        r�_get_nodes_by_key�#GraphIndexBuilder._get_nodes_by_key�s������%��L��#�#�8<���8I�8I�8K�4�C�4�&�e�� �+�H�"%�c�r�(��#+�#6�#6�v�r�#B��#+�(+�J�(>�H��W�%�
9L�9=���8I�8I�8K�4�C�4�&�e�� �+�H�"%�c�r�(��#+�#6�#6�v�r�#B��#+�(+�
�H��W�%�
9L�".���!�!�!rc��URcgURnUR(aXU4nOX4nUSSHnURU05nM XTUS'g)z|Update the _nodes_by_key dict with a new key.

For a key of (foo, bar, baz) create
_nodes_by_key[foo][bar][baz] = key_value
Nrq)rSrPrs)rr2r�	node_refsrw�	key_valuerxs       r�_update_nodes_by_key�&GraphIndexBuilder._update_nodes_by_key�sf�����%���%�%������Y�/�I���I��#�2�h�F��*�*�6�2�6�H��%��R��rc	���URU5 [RU5b[U5e[	U5UR
:wa[U5e/n/nUHunUH6nXpR;dMURU5 URU5 M8 [UVs/sHn[U5PM sn5nURU5 Mw [U5U4$s snf)a�Check that 'key' and 'references' are all valid.

:param key: A key tuple. Must conform to the key interface (be a tuple,
    be of the right length, not have any whitespace or nulls in any key
    element.)
:param references: An iterable of reference lists. Something like
    [[(ref, key)], [(ref, key), (other, key)]]
:param value: The value associate with this key. Must not contain
    newlines or null characters.
:return: (node_refs, absent_references)

    * node_refs: basically a packed form of 'references' where all
      iterables are tuples
    * absent_references: reference keys that are not in self._nodes.
      This may contain duplicates if the same key is referenced in
      multiple lists.
)	rb�_newline_null_rer`rAr\rPrQ�appendr[)	rr2rvrr|�absent_references�reference_list�	reference�refs	         r�_check_key_ref_value�&GraphIndexBuilder._check_key_ref_value�s���$	
������"�"�5�)�5���&�&��z�?�d�2�2�2��
�+�+��	���(�N�+�	��K�K�/��O�O�I�.�%�,�,�Y�7�,�#�.�#I�.�3�E�#�J�.�#I�J�N����^�,�)��Y��!2�2�2��$Js�%C#
c��URXU5upEXR;a!URUSS:wa[X5eUHnSURU'M URR	U5 URRU5 SXB4URU'URb$URS:�aURXU5 ggg)a�Add a node to the index.

:param key: The key. keys are non-empty tuples containing
    as many whitespace-free utf8 bytestrings as the key length
    defined for this index.
:param references: An iterable of iterables of keys. Each is a
    reference to another key.
:param value: The value to associate with the key. It may be any
    bytes as long as it does not contain \\0 or \\n.
r�a)r�r$rrNrf)	r�rQr/rRrj�discardrSrTr~)rr2rrvr|r�r�s       r�add_node�GraphIndexBuilder.add_node
s���*.�)B�)B��U�*
�&���+�+��$�+�+�c�"2�1�"5��"=�&�s�1�1�*�I�&5�D�K�K�	�"�+�	
��� � �!2�3����!�!�#�&���2����C�����)�d�.>�.>��.B��%�%�c�)�<�/C�)rc��g)zqSee GraphIndex.clear_cache().

This is a no-op, but we need the api to conform to a generic 'Index'
abstraction.
Nr$�rs r�clear_cache�GraphIndexBuilder.clear_cache$��rc	�,�[/nURS[UR4-5 URS[UR
4-5 [
UR5[
UR5-
nURS[U4-5 [SU55n[URR55nSnUR(Ga /nUnSnUH�un	up�nURX�U45 U[SU	55-
nUR
S:�aXpR
S-
-
nU[
U5S-S--
nU
(aUS-
nMtUR(dM�XpRS-
-
nUH+n
U[
U
5-
nU
(dMU[
U
5S-
-
nM- M� SnXxU--nSU-U:aUS-
nXxU--nSU-U:aMUS-n0nUHup�nXxU--UU	'M S	U-nUH�un	up�n/nUHEn
/nU
HnURWWU-5 M URS
RU55 MG SRU	5nURSUU
S
RU5U4-5 M� URS5 [SRU55nU(aP[
UR55U:wa3[ R""S[
UR55SU35eU$)zmFinish the index.

:returns: cBytesIO holding the full context of the index as it
should be written to disk.
s%s%d
c3�8# �UHn[U5v� M g7fr�r\)�.0�xs  r�	<genexpr>�+GraphIndexBuilder.finish.<locals>.<genexpr>6s���2�E�q�C��F�F�E���Nrc3�8# �UHn[U5v� M g7frr�)r�ras  rr�r�Vs���$E��g�S��\�\��r�rfrg�
s%%0%dd�
�s%s%s%s%s
�	�
rzUFailed index creation. Internal error: mismatched output length and expected length: � )�
_SIGNATUREr��_OPTION_NODE_REFSrP�_OPTION_KEY_ELEMENTSrTr\rQrR�_OPTION_LEN�sum�sortedrr�joinr	�getvaluer
r)r�lines�	key_count�
prefix_length�nodes�expected_bytes�key_offset_info�
non_ref_bytes�total_referencesr2rurvr�ref_list�digits�possible_total_bytes�
key_addresses�
format_string�flattened_references�
ref_addressesr��
string_key�results                       r�finish�GraphIndexBuilder.finish+s?�����
���Y�"3�T�5I�5I�!J�J�K�
���Y�"6��8H�8H�!I�I�J�����$�s�4�+<�+<�'=�=�	�
���Y�+�y�!9�9�:��2�E�2�2�
� �t�{�{�(�(�*�+�������� �O�)�M� ��49�0��0�f�%� �&�&��<L�'M�N���$E��$E�!E�E�
��#�#�a�'�!�%5�%5��%9�9�M���U��a��!�!3�3�
��!�Q�&�M��)�)�)�!�%9�%9�A�%=�=�M�$.��(�C��M�9�(�#�8�)�S��]�Q�->�>�M�%/�'5:�4�F�#0�f�3L�#L� ��f�*�3�3��!���'4�&�7P�'P�$��f�*�3�3�2�A�5�N��M�8G�4��$4�%2��5N�%N�
�c�"�9H�&��.�M�05�,�C�,�&�e�#%� �&�� "�
�!)�I�!�(�(���y�9Q�)Q�R�"*�$�+�+�E�J�J�}�,E�F�	'�
!���c�*�J��L�L�)��v�u�z�z�2F�'G��O�P�
�16�	���U������%��)���c�&�/�/�"3�4��F��/�/�g�hk�lr�l{�l{�l}�h~�g�@A�BP�AQ�R��
��
rNc�*�UbXlUbX lgg)a�Change how the builder tries to optimize the result.

:param for_size: Tell the builder to try and make the index as small as
    possible.
:param combine_backing_indices: If the builder spills to disk to save
    memory, should the on-disk indices be combined. Set to True if you
    are going to be probing the index, but to False if you are not. (If
    you are not querying, then the time spent combining is wasted.)
:return: None
N)rUrV)r�for_size�combine_backing_indicess   r�set_optimize�GraphIndexBuilder.set_optimize�s!����&.�#�"�.�,C�)�/rc�P�[U5n0n[5nU(a�[5nURU5HWupxp�X�nX�U'URUVs/sHo�U;dM
UPM sn5 URURU55 MY UnU(aM�XE4$s snf)z'See CombinedGraphIndex.find_ancestry().)rI�iter_entriesrj�
difference)
rrK�ref_list_num�pending�
parent_map�missing_keys�next_pending�_r2�_value�	ref_lists�parent_keys�ps
             r�
find_ancestry�GraphIndexBuilder.find_ancestry�s����d�)���
��u����5�L�-1�->�->�w�-G�)���'�5��"-�3���#�#��$S��1�
�?R�Q��$S�T��#�#�G�$6�$6�z�$B�C�	.H�
#�G��g��'�'��%Ts�	B#
�$B#
)rRrVrTrQrSrUrP)rrf�r$)NN)rrr r!�__doc__rrbrmryr~r�r�r�r�r�r�r#r$rrrrxsB���$-�"'��*"�,&�""3�H=�4�\�|D�$
(rrc���\rSrSrSrS$SjrSrSrSrSr	Sr
S%S
jrSrSr
S
rSrSrSr\S5rSrSrSrSrSrSrSrSrSrSrSrSrSr Sr!S r"S!r#S"r$S#r%g	)&ri�aAn index for data with embedded graphs.

The index maps keys to a list of key reference lists, and a value.
Each node has the same number of key reference lists. Each key reference
list can be empty or an arbitrary length. The value is an opaque NULL
terminated string without any newlines. The storage of the index is
hidden in the interface: keys and key references are always tuples of
bytestrings, never the internal representation (e.g. dictionary offsets).

It is presumed that the index will not be mutated - it is static data.

Successive iter_all_entries calls will read the entire index each time.
Additionally, iter_entries calls will read the index linearly until the
desired keys are found. XXX: This must be fixed before the index is
suitable for production use. :XXX
c��XlX lSUlSUl/Ul/UlSUlSUlSUlX0l	SUl
XPlg)a�Open an index called name on transport.

:param transport: A breezy.transport.Transport.
:param name: A path to provide to transport API calls.
:param size: The size of the index in bytes. This is used for bisection
    logic to perform partial index reads. While the size could be
    obtained by statting the file this introduced an additional round
    trip as well as requiring stat'able transports, both of which are
    avoided by having it supplied. If size is None, then bisection
    support will be disabled and accessing the index will just stream
    all the data.
:param offset: Instead of starting the index data at offset 0, start it
    at an arbitrary offset.
Nr)�
_transport�_name�
_bisect_nodesrQ�_parsed_byte_map�_parsed_key_map�
_key_count�_keys_by_offsetrS�_size�_bytes_read�_base_offset)rr�name�size�unlimited_cache�offsets      rr�GraphIndex.__init__�s_��$���
�"������!#��� "������#���!����
����"�rc���[U[U55=(aY URUR:H=(a9 URUR:H=(a URUR:H$)z@Equal when self and other were created with the same parameters.)r]rZr�r�r��r�others  r�__eq__�GraphIndex.__eq__�sZ��
�t�T�%�[�)�
*����5�#3�#3�3�
*��
�
�e�k�k�)�
*��
�
�e�k�k�)�		
rc�.�URU5(+$r)r�r�s  r�__ne__�GraphIndex.__ne__�s���;�;�u�%�%�%rc��[U[5(d [U[5(d[U5e[	U5[	U5:$r�r]rr�	TypeError�hashr�s  r�__lt__�GraphIndex.__lt__��A���%��,�,�Z��%�6
�6
��E�"�"��D�z�D��K�'�'rc�n�[[U5URURUR45$r)r�rZr�r�r�r�s r�__hash__�GraphIndex.__hash__�s&���T�$�Z����$�*�*�d�j�j�I�J�Jrc��SRURRURR	UR
55$)Nz{}({!r}))�format�	__class__rr��abspathr�r�s r�__repr__�GraphIndex.__repr__�s7��� � ��N�N�#�#�T�_�_�%<�%<�T�Z�Z�%H�
�	
rNc��URbgS[R;a9[R	SUR
R
UR55 Uc[UR
RUR5nURS:wa&[UR5URS5nURU5 SUR-Ul0Ul0UlSUlSnUR#5nUR5R%S5nUR'5 US	UR)XC5u  pRURR+5HCupgp�U(aMUR,(aX�R/U54n
OU	n
X�RU'ME US:wa[1U5eg!UR'5 f=f)	zIBuffer all the index data.

Mutates self._nodes and self.keys_by_offset.
Nr3zReading entire index %srrgr�rqrf)rQr�debug_flags�trace�mutterr�r�r��getr�r	�read�_read_prefixrT�_expected_elementsr�rS�tell�split�close�_parse_lines�values�node_ref_lists�_resolve_referencesr&)r�stream�trailers�posr�r�r2rurvr�
node_values           r�_buffer_all�GraphIndex._buffer_all�s���
�;�;�"���e�'�'�'��L�L�2�D�O�O�4K�4K�D�J�J�4W�X��>��_�_�(�(����4�F�� � �A�%�!�����t�/@�/@�/B�!C�D��	����f�%�&'�$�*:�*:�&:�D�#�#%�D� ��D�K�!%�D���H��+�+�-�C��K�K�M�'�'��.�E��L�L�N��"�I� �-�-�e�9���1�a�.2�.B�.B�.I�.I�.K�*�C�����"�"�#�%=�%=�j�%I�J�
�"�
�)�K�K���/L��q�=��t�$�$���
�L�L�N�s
�;A+G�Gc��g)z�Clear out any cached/memoized values.

This can be called at any time, but generally it is used when we have
extracted some information, but don't expect to be requesting any more
from this index.
Nr$r�s rr��GraphIndex.clear_cache,r�rc�L�UR5 US-UR:�a[SUSURS35e[5nURnUR5H5unupVXanUR
UVs/sHo�U;dM
UPM sn5 M7 U$s snf)rerfzNo ref list z, index has z
 ref lists)rr	�
ValueErrorrIrQrrrj)	rr�rkr��_keyr�r�r�r�s	         r�external_references�GraphIndex.external_references4s��������!��d�1�1�1���|�n�L��9L�9L�8M�Z�X��
��u������).����%�D�%�6� �.�H��K�K��E���u�4D���E�F�*7����Fs�	B!
�B!
c��URc�0nUR(aPURR5H1unup4UnUSSHnUR	U05nM X#U4XRS'M3 OKURR5H-up#UnUSSHnUR	U05nM X#4XRS'M/ XlUR$rp)rSr	rQrrrs)rrtr2rrvrwrxs       rry�GraphIndex._get_nodes_by_keyBs������%��L��"�"�04���0A�0A�0C�,�C�,�%�+�H�"%�c�r�(��#+�#6�#6�v�r�#B��#+�(+�J�(>�H��W�%�	1D�#'�+�+�"3�"3�"5�J�C�+�H�"%�c�r�(��#+�#6�#6�v�r�#B��#+�(+�
�H��W�%�	#6�
".���!�!�!rc#�h# �S[R;a[RSS5 URcUR5 UR(a-URR5Hunup#XX#4v� M gURR5HupXU4v� M
 g7f)aIterate over all keys within the index.

:return: An iterable of (index, key, value) or (index, key, value, reference_lists).
    The former tuple is used when there are no reference lists in the
    index, making the API compatible with simple key:value index types.
    There is no defined order for the result iteration - it will be in
    the most efficient order for the index.
�evilrg�-iter_all_entries scales with size of history.N)rr�r��mutter_callsiterQrr	rr)rr2rr	s    rrh�GraphIndex.iter_all_entriesTs�����U�&�&�&��!�!�!�%T�U��;�;���������04���0A�0A�0C�,��,�e���6�6�1D�#�k�k�/�/�1�
����&�&�2�s�B0B2c�f�UR[UR555nX R5:Xd[UR[
5eUR
5nUR[5(d[U5e[U[[5S5UlUR
5nUR[5(d[U5e[U[[5S5UlUR
5nUR[5(d[U5e[U[[5S5Ulg![an[U5UeSnAff=f![an[U5UeSnAff=f![an[U5UeSnAff=frp)rr\�
_signaturerr�r�readline�
startswithr�r<�intr	rr�rTr�r�)rr�	signature�options_line�es     rr�GraphIndex._read_prefixhsn���K�K��D�O�O�$5� 6�7�	��O�O�-�-�)�$�*�*�j�A�A����(���&�&�'8�9�9�!�$�'�'�	/�"%�l�3�7H�3I�B�&O�"P�D�����(���&�&�';�<�<�!�$�'�'�	/�"�<��4H�0I�B�#O�P�D�����(���&�&�{�3�3�!�$�'�'�	/�!�,�s�;�/?�"�"E�F�D�O���	/�!�$�'�Q�.��	/���	/�!�$�'�Q�.��	/���	/�!�$�'�Q�.��	/�sH� E�" E7�8 F�
E4�#E/�/E4�7
F�F
�
F�
F0�F+�+F0c
��/nUH=nUR[UVs/sHo@RUSPM sn55 M? [U5$s snf)aAReturn the resolved key references for references.

References are resolved by looking up the location of the key in the
_keys_by_offset map and substituting the key name, preserving ordering.

:param references: An iterable of iterables of key locations. e.g.
    [[123, 456], [123]]
:return: A tuple of tuples of keys.
r)r�r[r�)rrvr|r�r�s     rr
�GraphIndex._resolve_references�sT���	�"�H����U�H�#U�H�S�$8�$8��$=�a�$@�H�#U�V�W�#��Y����$Vs�Ac�r�[X5S-
nUS-[U5:aXS-SUS:XaUS-$U$)z�Helper for the _parsed_*_index calls.

Given a range map - [(start, end), ...], finds the index of the range
in the map for key if it is in the map, and if it is not there, the
immediately preceeding range in the map.
rfr)rr\)�	range_mapr2r�s   r�_find_index�GraphIndex._find_index�sJ���i�-��1���A�:��I��&��!��$�Q�'�3�q�6�1���z�!��
rc�B�US4nURURU5$)a/Return the index of the entry immediately before offset.

e.g. if the parsed map has regions 0,10 and 11,12 parsed, meaning that
there is one unparsed byte (the 11th, addressed as[10]). then:
asking for 0 will return 0
asking for 10 will return 0
asking for 11 will return 1
asking for 12 will return 1
r)r,r�)rr�r2s   r�_parsed_byte_index�GraphIndex._parsed_byte_index�s&���q�k������ 5� 5�s�;�;rc�B�US4nURURU5$)aNReturn the index of the entry immediately before key.

e.g. if the parsed map has regions (None, 'a') and ('b','c') parsed,
meaning that keys from None to 'a' inclusive, and 'b' to 'c' inclusive
have been parsed, then:
asking for '' will return 0
asking for 'a' will return 0
asking for 'b' will return 1
asking for 'e' will return 1
r)r,r�)rr2�
search_keys   r�_parsed_key_index�GraphIndex._parsed_key_index�s&���3�Z�
����� 4� 4�j�A�Arc���URU5nU[UR5:XaXRUS-
S:$URUup4X:�=(a X:$)z'Returns True if offset has been parsed.rf)r/r\r�)rr�r3�start�ends     r�
_is_parsed�GraphIndex._is_parsed�sc���'�'��/���C��-�-�.�.��1�1�%�!�)�<�Q�?�?�?��*�*�5�1�
����/�6�<�/rc#��# �URnUVs/sHo3U;dM
UPM nnUR(aUHnX#upEXXE4v� M gUHnXX#4v� M
 gs snf7f)z2Iterate over keys when the entire index is parsed.N)rQr	)rrKr�r2rr|s      r�_iter_entries_from_total_buffer�*GraphIndex._iter_entries_from_total_buffer�sn�������#�4�t��e�|��t��4������#(�:� ����1�1�������+�+���
5�s�A&�	A!�A!�AA&c��[U5nU(d/$URcURcUR5 URc0[	U5S-UR5:�aUR5 URbUR
U5$S[RURURU55$)a Iterate over keys within the index.

:param keys: An iterable providing the keys to be retrieved.
:return: An iterable as per iter_all_entries, but restricted to the
    keys supplied. No additional keys will be returned, and every
    key supplied that is in the index will be returned.
�c3�,# �UH
nUSv� M g7f)rfNr$)r�r�s  rr��*GraphIndex.iter_entries.<locals>.<genexpr>�s�����F��q�	��s�)
rIr�rQrr\r�r;�bisect_multi�bisect_multi_bytes�_lookup_keys_via_locationrJs  rr��GraphIndex.iter_entries�s����4�y����I��:�:��$�+�+�"5������;�;��3�t�9�r�>�D�N�N�4D�#D������;�;�"��7�7��=�=��*�=�=��2�2�D�J�J����
rc#�|# �[U5nU(dgURcUR5 URS:XaRUHKn[	X5 UR
(aURUup4XX44v� M8XURU4v� MM gUR
5n[XU5Shv�N gN7f)a�Iterate over keys within the index using prefix matching.

Prefix matching is applied within the tuple of a key, not to within
the bytestring of each key element. e.g. if you have the keys ('foo',
'bar'), ('foobar', 'gam') and do a prefix search for ('foo', None) then
only the former key is returned.

WARNING: Note that this method currently causes a full index parse
unconditionally (which is reasonably appropriate as it is a means for
thunking many small indices into one larger one and still supplies
iter_all_entries at the thunk layer).

:param keys: An iterable providing the key prefixes to be retrieved.
    Each key prefix takes the form of a tuple the length of a key, but
    with the last N elements 'None' rather than a regular bytestring.
    The first element cannot be 'None'.
:return: An iterable as per iter_all_entries, but restricted to the
    keys with a matching prefix to those supplied. No additional keys
    will be returned, and every match that is in the index will be
    returned.
Nrf)rIrQrrT�_sanity_check_keyr	ry�_iter_entries_prefix)rrKr2rr|rts      r�iter_entries_prefix�GraphIndex.iter_entries_prefix�s����,�4�y�����;�;���������q� ���!�$�,��&�&�'+�{�{�3�'7�$�E��U�5�5��T�[�[��%5�5�5�
�
��-�-�/��'��D�A�A�A�s�B2B<�4B:�5B<c�,�[5n[5nURU5H0upxp�X�nURU5 X�U'URU5 M2 UR[U5R	U55 UR	U5nU$)zSee BTreeIndex._find_ancestors.)rIr�rirjr�)rrKr�r�r��
found_keys�search_keys�_indexr2r�rkr�s            r�_find_ancestors�GraphIndex._find_ancestorss���
�U�
��e��)-�):�):�4�)@�%�F���,�K��N�N�3��)�s�O����{�+�	*A�	���C��I�0�0��<�=�!�,�,�Z�8���rc�`�URcUR[/5 UR$)z_Return an estimate of the number of keys in this index.

For GraphIndex the estimate is exact.
)r��_read_and_parse�
_HEADER_READVr�s rr��GraphIndex.key_count+s(��
�?�?�"�� � �-��1����rc
�4	�/nUGH8up4UR(aX@R;aM(URU5n[UR5(aNURUSU::a8URUSU:�d URUSUR
:XaM�UR
U5n[UR5(a.URUSU::aURUSU:�aM�SnX6-UR
:�aUR
U-
nUS:�dGM&URX645 GM; URcUR[5 URU5 /nURb�UH�up4X@R;aURX44S45 M*UR(a)URUup�URX44XX�445 MdURX44XURU445 M� U$/n
[5nUGH�up4X@R;a�UR(a�URUup�/nU	H.n
U
H%nX�R;dMURU5 M' M0 U(a%URU5 U
RX445 M�URX44XX�RU	5445 O#URX44XURU445 M�URU5nURUSU::aMURUSU:�d URUSUR
:XaURX44S45 GMXUR
U5nX@RUS:aSnOSnURX44U45 GM� /nUH@nSnX6-UR
:�aUR
U-
nUS:�dM.URX645 MB URU5 URb4U
H,up4URUup�URX44XX�445 M. U$U
H;up4URUup�URX44XX�RU	5445 M= U$)a�Public interface for implementing bisection.

If _buffer_all has been called, then all the data for the index is in
memory, and this method should not be called, as it uses a separate
cache because it cannot pre-resolve all indices, which buffer_all does
for performance.

:param location_keys: A list of location(byte offset), key tuples.
:return: A list of (location_key, result) tuples as expected by
    breezy.bisect_multi.bisect_multi_bytes.
rrfi Frq)r�r3r\r�r�r�r/r�rRrQrQr	rIr�rjr
)r�
location_keys�readv_ranges�locationr2r3�lengthr�rrk�pending_references�pending_locations�wanted_locationsr�r��	directions                rrC�$GraphIndex._lookup_keys_via_location4s���.��*�M�H��!�!�c�-?�-?�&?���*�*�3�/�E��D�(�(�)�)��(�(��/��2�c�9��(�(��/��2�c�9��)�)�%�0��3�t�z�z�A�
��+�+�H�5�E��D�)�)�*�*��)�)�%�0��3�x�?��)�)�%�0��3�h�>���F�� �4�:�:�-����h�.����z��#�#�X�$6�7�C+�F���%����
�.����\�*����;�;�"�"/�
���k�k�)��M�M�H�?�E�":�;��(�(�"&�+�+�c�"2�K�E��M�M�H�?�T��4L�"M�N��M�M�H�?�T����C�@P�4Q�"R�S�"/��M�
 ���E��*�M�H��(�(�(��&�&�"&�"4�"4�S�"9�K�E�')�$�$(��#+�C�"�*>�*>�>� 0� 7� 7�� <�$,�%)�(�)�0�0�1A�B�*�1�1�8�/�B� ��M�M�%�O�!��/G�/G��/M�N����M�M�"��4�d�6H�6H��6M�*N�O����.�.�s�3���'�'��.�q�1�S�8��(�(��/��2�c�9��)�)�%�0��3�t�z�z�A��M�M�H�?�E�":�;���+�+�H�5�E��)�)�%�0��3�3��	��	��M�M�H�?�I�6�7�]+�^��)�H��F�� �4�:�:�-����h�.����z��#�#�X�$6�7�*�	
���\�*��;�;�"�"4�
��"�k�k�#�.����
�
����E�0H�I�J�"4��M�/�M�H��,�,�S�1�K�E��M�M���4�e�5M�5M�d�5S�"T�U�
�0��
rc�L�US[UR55nX R5:Xd[UR[5eU[UR55SR5nUSnUR
[5(d[U5e[U[[5S5Ul
USnUR
[5(d[U5e[U[[5S5Ul
USnUR
[5(d[U5e[U[[5S5Ul[U5[US5-[US5-[US5-S-nUR!SSUS5 SUR-Ul0Ul0UlXaUS4$![an[U5UeSnAff=f![an[U5UeSnAff=f![an[U5UeSnAff=f)z�Parse the header from a region of bytes.

:param bytes: The data to parse.
:return: An offset, data tuple such as readv yields, for the unparsed
    data. (which may length 0).
rNrfr
rgr$)r\r rr�r�
splitlinesr"r�r<r#r	rr�rTr�r��
_parsed_bytesrr�r�)rr^r$r�r%r&�
header_ends       r�_parse_header_from_bytes�#GraphIndex._parse_header_from_bytes�s
���!�c�$�/�/�"3�4�5�	��O�O�-�-�)�$�*�*�j�A�A��c�$�/�/�+�,�.�/�:�:�<���Q�x���&�&�'8�9�9�!�$�'�'�	/�"%�l�3�7H�3I�3K�&L�"M�D���Q�x���&�&�';�<�<�!�$�'�'�	/�"�<��4H�0I�0K�#L�M�D���Q�x���&�&�{�3�3�!�$�'�'�	/�!�,�s�;�/?�/A�"B�C�D�O���^�c�%��(�m�3�c�%��(�m�C�c�%�PQ�(�m�S�VW�W�
����1�b�*�b�1�"#�d�&6�&6�"6���!���������-�-�-��3�	/�!�$�'�Q�.��	/���	/�!�$�'�Q�.��	/���	/�!�$�'�Q�.��	/�sH� G�* G*�5 H�
G'�G"�"G'�*
H�4H�H�
H#�H�H#c��U[U5-nUnURU5nX0RUS:agURXX55upFU(agME)z�Parse node data returned from a readv operation.

:param offset: The byte offset the data starts at.
:param data: The data to parse.
rfN)r\r/r��_parse_segment)rr��datar7�high_parsedr3�last_segments       r�
_parse_region�GraphIndex._parse_region�sg���s�4�y� ������+�+�K�8�E��*�*�5�1�!�4�4��)-�(;�(;�F�#�(U�%�K���rc
�`�SnXRUS:aURUSU-
nSnOXRUS:XaSnSnOSnSnX0R:XaSnSnSn	O�US-[UR5:XaSnSnSn	OoX0RUS-S:XaSnSnSn	OPX0RUS-S:�a2URUS-SU-
nSnX0RUS-S:n	OSnSnSn	U(d>UcURS5S-nOURSU5S-nUS:wd[	S5eU(d?UcURS5S-nOURSSU5S-nUS:wd[	S5eX&Un
U
(d$[	SUS	US
US	U[U5-S3	5eU(aX-
nU
R
S5nUS	UnURX�5up�nnUHunnUURU'M URXU[U
5-U5 U[U
5-U	4$)
aParse one segment of data.

:param offset: Where 'data' begins in the file.
:param data: Some data to parse a segment of.
:param end: Where data ends
:param index: The current index into the parsed bytes map.
:return: True if the parsed segment is the last possible one in the
    range of data.
:return: high_parsed_byte, last_segment.
    high_parsed_byte is the location of the highest parsed byte in this
    segment, last_segment is True if the parsed segment is the last
    possible one in the data block.
NrfTFrr�zno 
 was presentzread unneeded data [�:z] from [�]rq)
r�r�r\�find�AssertionError�rfindrrr�r`)rr�rfr7r3�trim_end�
trim_start�start_adjacent�end_adjacentrh�trimmed_datar�r
�	first_key�last_keyr�r�r2rs                   rre�GraphIndex._parse_segments������)�)�%�0��3�3��.�.�u�5�a�8�6�A�J�!�N�
�,�,�U�3�A�6�
6��J�!�N��J�"�N��*�*���H��L��L�
�Q�Y�#�d�3�3�4�
4��H� �L��L�
�)�)�%�!�)�4�Q�7�
7��H��L��L�
�(�(����3�A�6�
6��,�,�U�Q�Y�7��:�V�C�H��L��!6�!6�u�q�y�!A�!�!D�D�L��H� �L��L���!�!�Y�Y�u�-��1�
�!�Y�Y�u�j�9�A�=�
��!�O�$�%8�9�9�����:�:�e�,�q�0���:�:�e�T�8�<�q�@����M�$�%8�9�9��x�0��� �&�z�l�!�H�:�X�f�X�Q�v�X[�\`�Xa�Oa�Nb�bc�d��
��� �F��"�"�5�)���"�I���(,�(9�(9�%�(E�%�	�U�A��J�C��&+�D���s�#� ����6�f�s�<�7H�.H�(�S���L�)�)�<�7�7rc�$�SnSnSn/nUGHynUS:XaPUR(a8URUS-:Xd%[SRURU55eUS-
nMZURS5n[	U5UR
:wa[
U5e[USUR5nUcUnUSSup�n/nU
RS5HNn
UR[U
RS5Vs/sHo�(dM[U5PM sn55 MP [U5nX9X�4URU'U[	U5S--
nU	(aGMPUR(aX�4nOUnURX?45 GM| XCXe4$s snf)	Nrrrfz{} {}r����r�r�)
r�ror�rr\rr&r[rTr�r#r�r	)rr�r
r2rvrr��line�elementsrurvrr��
ref_stringr�rs                rr�GraphIndex._parse_lines|s������	������D��s�{��:�:� �J�J�#��'�1�,�W�^�^�D�J�J��-L�M�M��A�
����z�z�%�(�H��8�}�� 7� 7�7�"�4�(�(���!3�4�#3�#3�4�5�C�� ��	�(0���
�%�F���I�(�.�.�u�5�
�� � ��z�/?�/?��/F�N�/F��#�8�3�s�8�/F�N�O��6��i�(�I�),�i�(G�D� � ��%��3�t�9�q�=� �C����"�"�#�/�
�"�
��L�L�#�*�+�?�B�u�.�.��Os�8
F
�F
c��URU5nX4nX$4nUS:Xa7URRXV5 URRXW5 gUS-[	UR5:a�URUSU:Xa�URUS-SU:Xa�URUSURUS-S4URU'URUSURUS-S4URU'URUS-	URUS-	gURUSU:XaCURUSU4URU'URUSU4URU'gUS-[	UR5:ahURUS-SU:XaOUURUS-S4URUS-'UURUS-S4URUS-'gURRUS-U5 URRUS-U5 g)z�Mark the bytes from start to end as parsed.

Calling self._parsed_bytes(1,2) will mark one byte (the one at offset
1) as parsed.

:param start: The start of the parsed region.
:param end: The end of the parsed region.
rqNrfr)r/r��insertr�r\)rr6�	start_keyr7�end_keyr3�	new_value�new_keys        rr`�GraphIndex._parsed_bytes�ss���'�'��.���L�	��&���B�;��!�!�(�(��:�� � �'�'��7��
�A�I��D�1�1�2�2��%�%�e�,�Q�/�5�8��%�%�e�a�i�0��3�s�:��%�%�e�,�Q�/��%�%�e�a�i�0��3�,�D�!�!�%�(�
�$�$�U�+�A�.��$�$�U�Q�Y�/��2�+�D� � ��'��%�%�e�a�i�0��$�$�U�Q�Y�/�
�
"�
"�5�
)�!�
,��
5�,0�,A�,A�%�,H��,K�S�+Q�D�!�!�%�(�+/�+?�+?��+F�q�+I�7�*S�D� � ��'��A�I��D�1�1�2�2��%�%�e�a�i�0��3�s�:���%�%�e�a�i�0��3�0�D�!�!�%�!�)�,�
��$�$�U�Q�Y�/��2�/�D� � ����+�
�!�!�(�(����I�>�� � �'�'���	�7�;rc���U(dgURc.URS-UR:�aUR5 gURnUS:waUVVs/sHup4X2-U4PM
 nnnUR
R
URUSURUR-5nUH�upgXb-nU=R[U5-
slUS:aXv*SnSnUS:Xa5[U5UR:XaUR[U55  gURc#US:Xd
[5eURU5upgURXg5 M� gs snnf)zaRead the ranges and parse the resulting data.

:param readv_ranges: A prepared readv range list.
Nr
rT)rQr�r�rr�r��readvr�r\r	r�rorbri)rrV�base_offsetr6r��
readv_datar�rfs        rrQ�GraphIndex._read_and_parse�sO��
���;�;��4�#3�#3�a�#7�4�:�:�#E�
������'�'���!��KW�X�<�K�E�U�0�$�7�<�L�X��_�_�*�*��J�J��d�D�J�J��9J�9J�,J�
�
�'�L�F��!�F�����D�	�)����z��G�H�~������{�s�4�y�D�J�J�6�� � ����/���!�!�)��!��(�*�*�#�<�<�T�B������v�,�)'��Ys�E&c��[$)z'The file signature for this index type.)r�r�s rr �GraphIndex._signatures���rc�2�UR5HnM g�z6Validate that everything in the index can be accessed.N)rh)r�_nodes  r�validate�GraphIndex.validates���*�*�,�E��-r)r�r�r�rr�rTr�r�rQrSr�r�r�r�r	)Frr)&rrr r!r�rr�r�r�r�r�rr�rryrhrr
�staticmethodr,r/r3r8r;r�rHrNr�rCrbrirerr`rQr r�r#r$rrrr�s����"$#�L
�&�(�K�
�
+%�Z��"�$'�(/�4
 �����<�B�0�,��B&B�P�"�Y�v).�V�,j8�X&/�P:<�x)-�V�rrc��\rSrSrSrSSjrSrSrSr\	r
SSjrS	rS
r
SrSrS
rSrSrSr\rSrSrSrSrg)ria�A GraphIndex made up from smaller GraphIndices.

The backing indices must implement GraphIndex, and are presumed to be
static data.

Queries against the combined index will be made against the first index,
and then the second and so on. The order of indices can thus influence
performance significantly. For example, if one index is on local disk and a
second on a remote server, the local disk index should be before the other
in the index list.

Also, queries tend to need results from the same indices as previous
queries.  So the indices will be reordered after every query to put the
indices that had the result(s) of that query first (while otherwise
preserving the relative ordering).
Nc�f�XlX l/UlS/[UR5-Ulg)a&Create a CombinedGraphIndex backed by indices.

:param indices: An ordered list of indices to query for data.
:param reload_func: A function to call if we find we are missing an
    index. Should have the form reload_func() => True/False to indicate
    if reloading actually changed anything.
N)�_indices�_reload_func�_sibling_indicesr\�_index_names)r�indices�reload_funcs   rr�CombinedGraphIndex.__init__(s3�� �
�'��!#���"�F�S����%7�7��rc	��SRURRSR[	[
UR555$)Nz{}({})z, )r�r�rr��map�reprr�r�s rr��CombinedGraphIndex.__repr__:s6������N�N�#�#�T�Y�Y�s�4����/G�%H�
�	
rc�J�URHnUR5 M g)zSee GraphIndex.clear_cache().N)r�r�)rr3s  rr��CombinedGraphIndex.clear_cache?s���]�]�E�����#rc�$�[U5n[RU;a2UR[R5 [R/0nO0nUR	U5H'upEpgUSnU(d[R4nX�U'M) U$)z0See graph.StackedParentsProvider.get_parent_map.r)rI�
_mod_revision�
NULL_REVISIONr�r�)	rrKrL�
found_parentsrMr2r�rk�parentss	         rrF�!CombinedGraphIndex.get_parent_mapDs����$�i���&�&�+�5����
� ;� ;�<�*�8�8�"�=�M��M�)-�):�):�;�)G�%�F���1�g�G��(�6�6�8��!(�#��	*H�
�rc�p�URRX5 URRX5 g)aVInsert a new index in the list of indices to query.

:param pos: The position to insert the index.
:param index: The index to insert.
:param name: a name for this index, e.g. a pack name.  These names can
    be used to reflect index reorderings to related CombinedGraphIndex
    instances that use the same names.  (see set_sibling_indices)
N)r�r�r�)rr
r3r�s    r�insert_index�CombinedGraphIndex.insert_indexUs*��	
�
�
���S�(���� � ��+rc#�2# �[5nURH=nUR5H&nUSU;dMUv� URUS5 M( M? g![R
a!nUR
U5(deSnAOSnAff=fM�7f)a?Iterate over all keys within the index.

Duplicate keys across child indices are presumed to have the same
value and are only reported once.

:return: An iterable of (index, key, reference_lists, value).
    There is no defined order for the result iteration - it will be in
    the most efficient order for the index.
rfN)rIr�rhri�_mod_transport�
NoSuchFile�_try_reload)r�	seen_keysr3rlr&s     rrh�#CombinedGraphIndex.iter_all_entriesas�����E�	��	
�!�]�]�E� %� 6� 6� 8����7�)�3�"&�J�%�M�M�$�q�'�2�!9�+�
��!�,�,�
��'�'��*�*��+��
���s3�B�)A� A�B�B�1B
�B�
B�Bc#�# �[U5n/nURHZnU(d ORSnURU5HnURUS5 Uv� SnM U(dMIUR	U5 M\ URU5 g![
Ra!nURU5(deSnAOSnAff=fM�7f)axIterate over keys within the index.

Duplicate keys across child indices are presumed to have the same
value and are only reported once.

:param keys: An iterable providing the keys to be retrieved.
:return: An iterable of (index, key, reference_lists, value). There is
    no defined order for the result iteration - it will be in the most
    efficient order for the index.
TFrfN)	rIr�r��remover�r�r�r��_move_to_front)rrK�hit_indicesr3�	index_hitrlr&s       rr��CombinedGraphIndex.iter_entriesxs�����4�y�����
�!�]�]�E��� %�I� %� 2� 2�4� 8�����D��G�,�"�
�$(�	�!9�!�y�#�*�*�5�1�+��	
���K�(��"�,�,�
��'�'��*�*��+��
���s5�C	�AB�'B�<C	�C�#B?�:C	�?C�C	c#�# �[U5nU(dg[5n/nURH\nSnURU5H(nUSU;aMURUS5 Uv� SnM* U(dMKUR	U5 M^ URU5 g![
Ra!nURU5(deSnAOSnAff=fM�7f)aiIterate over keys within the index using prefix matching.

Duplicate keys across child indices are presumed to have the same
value and are only reported once.

Prefix matching is applied within the tuple of a key, not to within
the bytestring of each key element. e.g. if you have the keys ('foo',
'bar'), ('foobar', 'gam') and do a prefix search for ('foo', None) then
only the former key is returned.

:param keys: An iterable providing the key prefixes to be retrieved.
    Each key prefix takes the form of a tuple the length of a key, but
    with the last N elements 'None' rather than a regular bytestring.
    The first element cannot be 'None'.
:return: An iterable as per iter_all_entries, but restricted to the
    keys with a matching prefix to those supplied. No additional keys
    will be returned, and every match that is in the index will be
    returned.
NTFrf)	rIr�rHrir�r�r�r�r�)rrKr�r�r3r�rlr&s        rrH�&CombinedGraphIndex.iter_entries_prefix�s����(�4�y�����E�	����
�!�]�]�E� %�I� %� 9� 9�$� ?����7�i�/�$�!�
�
�d�1�g�.�"�
�$(�	�!@�!�y�#�*�*�5�1�+��	
���K�(��"�,�,�
��'�'��*�*��+��
���s5�!C�AB#�;B#�C�#C�7C�C�C�Cc��URS[U5U:XagURU5nURHnUR	U5 M g)ayRearrange self._indices so that hit_indices are first.

Order is maintained as much as possible, e.g. the first unhit index
will be the first index in _indices after the hit_indices, and the
hit_indices will be present in exactly the order they are passed to
_move_to_front.

_move_to_front propagates to all objects in self._sibling_indices by
calling _move_to_front_by_name.
N)r�r\�_move_to_front_by_indexr��_move_to_front_by_name)rr��	hit_names�sibling_idxs    rr��!CombinedGraphIndex._move_to_front�sP���=�=�+�3�{�+�,��;�
��0�0��=�	��0�0�K��.�.�y�9�1rc���[URUR5nS[R;a"[U5n[RSUU5 /n/n/n/n[U5H�unup�X�;a�URU5 URU	5 [U5[U5:XaDURURUS-S5 URURUS-S5  O(M�URU5 URU	5 M� XV-UlX4-UlS[R;a [RSUR5 U$)z`Core logic for _move_to_front.

Returns a list of names corresponding to the hit_indices param.
r3z9CombinedGraphIndex reordering: currently %r, promoting %rrfNz CombinedGraphIndex reordered: %r)�zipr�r�rr��listr�r��	enumerater�r\�extend)
rr��indices_infor��unhit_names�new_hit_indices�
unhit_indicesr�r��idxs
          rr��*CombinedGraphIndex._move_to_front_by_index�sI��
�4�,�,�d�m�m�<���e�'�'�'���-�L��L�L�K���
�
�	������
�#,�\�#:��F�K�T��!�� � ��&��&�&�s�+���'�3�{�+;�;� �&�&�t�'8�'8��!���'F�G�!�(�(����v��z�|�)D�E��<��"�"�4�(��$�$�S�)�$;�(�7��
�%�3����e�'�'�'��L�L�;�T�]�]�K��rc��[URUR5n/nUHupEXA;dMURU5 M UR	U5 g)zaMoves indices named by 'hit_names' to front of the search order, as
described in _move_to_front.
N)r�r�r�r�r�)rr�r�r�r�r�s      rr��)CombinedGraphIndex._move_to_front_by_name�sO���4�,�,�d�m�m�<����%�I�D�� ��"�"�3�'�&�	
�$�$�[�1rc���[5n0n[U5nSnU(a�US-
nSn[UR5Heup�[5n
UnSnU(a US-
nU	RX�XJ5nU(aM U
nUc[U
5nOUR	U
5 U(aMe O UcURU5 SnO"URU5 UR
U5 U(aM�XC4$)a-Find the complete ancestry for the given set of keys.

Note that this is a whole-ancestry request, so it should be used
sparingly.

:param keys: An iterable of keys to look for
:param ref_list_num: The reference list which references the parents
    we care about.
:return: (parent_map, missing_keys)
rrfN)rIr�r�rN�intersection_updaterj�difference_update)
rrKr�r�r��keys_to_lookup�
generation�all_index_missing�
_index_idxr3�index_missing_keysrL�sub_generations
             rr�� CombinedGraphIndex.find_ancestrys	���u���
��T����
���!�O�J� $��
&/�t�}�}�%=�!�
�&)�U�"�-��!"��"�"�a�'�N�#(�"7�"7�#�:�#�K�"�k�"4��$�,�(+�,>�(?�%�%�9�9�:L�M�%�~��?&>�@!�(��#�#�N�3�!%���#�#�$5�6��0�0�1B�C�]�n�^�'�'rc��[SUR5S5$![Ra!nUR	U5(deSnAOSnAff=fMX)aReturn an estimate of the number of keys in this index.

For CombinedGraphIndex this is approximated by the sum of the keys of
the child indices. As child indices may have duplicate keys this can
have a maximum error of the number of child indices * largest number of
keys in any index.
c3�@# �UHoR5v� M g7fr)r�)r�r3s  rr��/CombinedGraphIndex.key_count.<locals>.<genexpr>Ss���I�=�%�O�O�-�-�=�s�rN)r�r�r�r�r�)rr&s  rr��CombinedGraphIndex.key_countIsW���
��I�4�=�=�I�1�M�M��!�,�,�
��'�'��*�*��+��
��s� �A�A�Ac��URcg[RS[U55 UR5(d[RS5 gg)zoWe just got a NoSuchFile exception.

Try to reload the indices, if it fails, just raise the current
exception.
Fz,Trying to reload after getting exception: %szG_reload_func indicated nothing has changed. Raising original exception.T)r�r�r��str)r�errors  rr��CombinedGraphIndex._try_reloadZsN�����$��
���C�S��Z�P�� � �"�"��L�L�/�
��rc��Xlg)zDSet the CombinedGraphIndex objects to reorder after reordering self.N)r�)r�sibling_combined_graph_indicess  r�set_sibling_indices�&CombinedGraphIndex.set_sibling_indicesls�� >�rc���URHnUR5 M g![Ra!nUR	U5(deSnAOSnAff=fM_r�)r�r�r�r�r�)rr3r&s   rr��CombinedGraphIndex.validatepsY���
�!�]�]�E��N�N�$�+���!�,�,�
��'�'��*�*��+��
��s�#'�A�A�A)r�r�r�r�r)rrr r!r�rr�r�rFrG�__contains__r�rhr�rHr�r�r�r�r�rLr�r�r�r�r#r$rrrrsh���"8�$
�
 �

�,�L�
,��.)�>))�V:�&$�L2�?(�B
�1�L��$?�	rrc�B�\rSrSrSrSrSrSrSrSr	Sr
S	rS
rg)ri|a
A GraphIndex which operates entirely out of memory and is mutable.

This is designed to allow the accumulation of GraphIndex entries during a
single write operation, where the accumulated entries need to be immediately
available - for example via a CombinedGraphIndex.
c��UR(aUHup#nURX#U5 M gUHup#URX#5 M g)�^Add nodes to the index.

:param nodes: An iterable of (key, node_refs, value) entries to add.
N)rPr�)rr�r2rr|s     r�	add_nodes�InMemoryGraphIndex.add_nodes�sD��
���).�%��I��
�
�c�)�4�*/�$�
���
�
�c�)�$rc#�\# �S[R;a[RSS5 UR(a7UR
R
5Hunup#nU(aMXXC4v� M gUR
R
5Hunup#nU(aMXU4v� M g7f)z�Iterate over all keys within the index.

:return: An iterable of (index, key, reference_lists, value). There is no
    defined order for the result iteration - it will be in the most
    efficient order for the index (in this case dictionary hash order).
rrgrN)rr�r�rrPrQrr)rr2rurvrs     rrh�#InMemoryGraphIndex.iter_all_entries�s�����U�&�&�&��!�!�!�%T�U����48�K�K�4E�4E�4G�0��0�f�%��v��U�6�6�5H�59�K�K�4E�4E�4G�0��0�f�%��v��U�*�*�5H�s�A$B,�*3B,�!B,c#�# �URnUVs/sHo3U;dM
UPM nnUR(a'UH nX#nUS(aMXUSUS4v� M" gUHnX#nUS(aMXUS4v� M gs snf7f)�7Iterate over keys within the index.

:param keys: An iterable providing the keys to be retrieved.
:return: An iterable of (index, key, value, reference_lists). There is no
    defined order for the result iteration - it will be in the most
    efficient order for the index (keys iteration order in this case).
rr
rfN)rQrP)rrKr�r2rls     rr��InMemoryGraphIndex.iter_entries�s��������#�4�t��e�|��t��4�������z���A�w�w��T�!�W�d�1�g�5�5��
���z���A�w�w��T�!�W�,�,���5�s �B�	B�B�$B�#B�5Bc#�P# �[U5nU(dgURS:XaYUHRn[X5 URUnUS(aM)UR(aXUSUS4v� MIXUS4v� MT gUR5n[
XU5Shv�N gN7f)�Iterate over keys within the index using prefix matching.

Prefix matching is applied within the tuple of a key, not to within
the bytestring of each key element. e.g. if you have the keys ('foo',
'bar'), ('foobar', 'gam') and do a prefix search for ('foo', None) then
only the former key is returned.

:param keys: An iterable providing the key prefixes to be retrieved.
    Each key prefix takes the form of a tuple the length of a key, but
    with the last N elements 'None' rather than a regular bytestring.
    The first element cannot be 'None'.
:return: An iterable as per iter_all_entries, but restricted to the
    keys with a matching prefix to those supplied. No additional keys
    will be returned, and every match that is in the index will be
    returned.
Nrfrr
)rIrTrFrQrPryrG)rrKr2rlrts     rrH�&InMemoryGraphIndex.iter_entries_prefix�s����"�4�y�������q� ���!�$�,��{�{�3�'����7���'�'��T�!�W�d�1�g�5�5��T�!�W�,�,��
��-�-�/��'��D�A�A�A�s�BB&�B$�B&c�X�[UR5[UR5-
$)zgReturn an estimate of the number of keys in this index.

For InMemoryGraphIndex the estimate is exact.
)r\rQrRr�s rr��InMemoryGraphIndex.key_count�s#��
�4�;�;��#�d�&7�&7�"8�8�8rc��g)z9In memory index's have no known corruption at the moment.Nr$r�s rr��InMemoryGraphIndex.validate�r�rc��[U[5(d [U[5(d[U5e[	U5[	U5:$rr�r�s  rr��InMemoryGraphIndex.__lt__�r�rr$N)
rrr r!r�r�rhr�rHr�r�r�r#r$rrrr|s-���
*�+�$-�. B�D9�H�(rrc�V�\rSrSrSrSSjrSrSSjrSrSr	S	r
S
rSrSr
S
rg)ri�a�An adapter between GraphIndex with different key lengths.

Queries against this will emit queries against the adapted Graph with the
prefix added, queries for all items use iter_entries_prefix. The returned
nodes will have their keys and node references adjusted to remove the
prefix. Finally, an add_nodes_callback can be supplied - when called the
nodes and references being added will have prefix prepended.
Nc�b�XlUSU--UlX l[U5UlX@lg)z1Construct an adapter against adapted with prefix.rN)�adapted�
prefix_key�prefixr\�
prefix_len�add_nodes_callback)rr�r��missing_key_lengthr�s     rr� GraphIndexPrefixAdapter.__init__�s/���� �7�-?�#?�?������f�+���"4�rc�<^�[U5n/nUH;up4n[U4SjU55nURTRU-XF45 M= TR	U5 g![a. UH%up4URTRU-U45 M' NIf=f)r�c3�N># �UHn[U4SjU55v� M g7f)c3�B># �UHnTRU-v� M g7fr�r��r��ref_noders  �rr��>GraphIndexPrefixAdapter.add_nodes.<locals>.<genexpr>.<genexpr>
s����J��X�$�+�+��0����N�r[�r�r�rs  �rr��4GraphIndexPrefixAdapter.add_nodes.<locals>.<genexpr>s&����,�$-���J��J�J�J�$-���"%N)r[r�r�rr�)rr��translated_nodesr2rr|�adjusted_referencess`      rr��!GraphIndexPrefixAdapter.add_nodess�����e�����	D�*/�%��I�&+�,�$-�,�'�#�!�'�'����s�):�E�(W�X�*/�	
��� 0�1��
�	D�$�
�� �'�'����s�):�E�(B�C�$�		D�s�AA#�#5B�Bc�,�URXU445 g)a�Add a node to the index.

:param key: The key. keys are non-empty tuples containing
    as many whitespace-free utf8 bytestrings as the key length
    defined for this index.
:param references: An iterable of iterables of keys. Each is a
    reference to another key.
:param value: The value to associate with the key. It may be any
    bytes as long as it does not contain \0 or \n.
N)r�)rr2rrvs    rr�� GraphIndexPrefixAdapter.add_nodes��	
����Z�0�2�3rc	#�X^# �UH�nUSSTRTR:wa[T5eUSH4nUH+nUSTRTR:wdM"[T5e M6 USUSTRSUS[U4SjUS554v� M� g7f)z+Strip prefix data from nodes and return it.rfNrgrr
c3�N># �UHn[U4SjU55v� M g7f)c3�@># �UHoTRSv� M g7fr)r�rs  �rr��BGraphIndexPrefixAdapter._strip_prefix.<locals>.<genexpr>.<genexpr>6s����S�(�h�t���'8�9�(�s�Nr	r
s  �rr��8GraphIndexPrefixAdapter._strip_prefix.<locals>.<genexpr>5s&�����(/�H��S�(�S�S�S�(/�r)r�r�r&r[)r�an_iterrlr�rs`    r�
_strip_prefix�%GraphIndexPrefixAdapter._strip_prefix&s������D��A�w�(����)�T�[�[�8�"�4�(�(� ��G�� (�H�� 1�$�/�/�2�d�k�k�A�*�4�0�0�!)�$�
�Q���Q�����)�*��Q����(,�Q����
�

��s
�AB*� A
B*c�l�URURRUR/55$)aUIterate over all keys within the index.

iter_all_entries is implemented against the adapted index using
iter_entries_prefix.

:return: An iterable of (index, key, reference_lists, value). There is no
    defined order for the result iteration - it will be in the most
    efficient order for the index (in this case dictionary hash order).
)rr�rHr�r�s rrh�(GraphIndexPrefixAdapter.iter_all_entries<s+���!�!�$�,�,�"B�"B�D�O�O�CT�"U�V�Vrc�l^�TRTRRU4SjU555$)r�c3�B># �UHnTRU-v� M g7frr�r�r2rs  �rr��7GraphIndexPrefixAdapter.iter_entries.<locals>.<genexpr>Qs����%H�4�C�d�k�k�C�&7�4�r)rr�r�rJs` rr��$GraphIndexPrefixAdapter.iter_entriesHs0����!�!��L�L�%�%�%H�4�%H�H�
�	
rc�l^�TRTRRU4SjU555$)r�c3�B># �UHnTRU-v� M g7frrrs  �rr��>GraphIndexPrefixAdapter.iter_entries_prefix.<locals>.<genexpr>fs����,O�$�3�T�[�[�3�->�$�r)rr�rHrJs` rrH�+GraphIndexPrefixAdapter.iter_entries_prefixTs0���"�!�!��L�L�,�,�,O�$�,O�O�
�	
rc�F�[[UR555$)z�Return an estimate of the number of keys in this index.

For GraphIndexPrefixAdapter this is relatively expensive - key
iteration with the prefix is done.
)r\r�rhr�s rr��!GraphIndexPrefixAdapter.key_countis���4��-�-�/�0�1�1rc�8�URR5 g)zCall the adapted's validate.N)r�r�r�s rr�� GraphIndexPrefixAdapter.validateqs�������r)r�r�r�r�r�rr�)rrr r!r�rr�r�rrhr�rHr�r�r#r$rrrr�s5���5�2�24��,
W�

�
�*2� rrc�n�USc[U5e[U5UR:wa[U5eg)z<Raise BadIndexKey if key cannot be used for prefix matching.rN)r6r\rT)�index_or_builderr2s  rrFrFvs9��
�1�v�~��#���
�3�x�#�/�/�/��#���0rc#�2# �UH�n[X5 Un[U5n[U5(a6USb0XESnURS5 [U5(aUSbM0[U5(a�U/nU(auUR5R5n[
[U55n[U[5(aURU5 OUHnU4U-v� M
 U(aMsM�M�U4U-v� M� g![a GMf=f7f)z2Helper for implementing prefix matching iterators.rN)rFr�r\�pop�KeyErrorr�next�iterr]�dictr�)	r*rtrKr2rwr|�dicts�values_viewrs	         rrGrG~s�������*�0�����9��	��h�-�-�H�Q�K�$;�#�Q�K�0�����Q���h�-�-�H�Q�K�$;��x�=�=��J�E��#�i�i�k�0�0�2���T�+�.�/���e�T�*�*��L�L��-�"-�� 0�1�E�9�9�"-��%�$�%��0�0�=���	��	�s0�D�AD�'BD�4D�
D�D�D�D)&r��__all__�re�bisectr�ior	r�globals�rr
rr�rRr�r�r�r�rrr&r/r6r<rA�compiler_r�rGrLrrrrrrFrGr$rr�<module>r:s,��"���
���%���I��	��*��
�'����&��
&�
��f�o�o���6�?�?���6�?�?���&�/�/���f�o�o���F�O�O�����4�5���:�:�i�(��-�6�p(�p(�f	h
�h
�Vc�c�Lo(�*�o(�dE �E �P� 1r

Youez - 2016 - github.com/yon3zu
LinuXploit