§
    cÌc¥V ã                   ó¼  — d Z ddlZddlmZ ddlZddlmZ  e e¦   «         d¦  «         ddlmZm	Z	m
Z
mZ ddl	mZmZmZ dd	l
mZmZmZmZ dd
lmZ ddlmZmZmZmZmZmZmZmZmZ ddlmZ  dZ!dZ"dZ# G d„ de¦  «        Z$ G d„ de$¦  «        Z% G d„ de%¦  «        Z& G d„ de$¦  «        Z' G d„ de$¦  «        Z( G d„ de$¦  «        Z) G d„ de$¦  «        Z* G d„ d ¦  «        Z+ G d!„ d"e+¦  «        Z, G d#„ d$e+¦  «        Z- G d%„ d&e+¦  «        Z. G d'„ d(e+¦  «        Z/ G d)„ d*e+¦  «        Z0 G d+„ d,e+¦  «        Z1 G d-„ d.e¦  «        Z2 G d/„ d0e¦  «        Z3d1„ Z4d2„ Z5 G d3„ d4¦  «        Z6 G d5„ d6e6¦  «        Z7 G d7„ d8e6¦  «        Z8 G d9„ d:¦  «        Z9 G d;„ d<e9¦  «        Z: G d=„ d>e9¦  «        Z;d?„ Z<d@„ Z=dA„ Z>dB„ Z? G dC„ dDe¦  «        Z@ G dE„ dF¦  «        ZA G dG„ dHeA¦  «        ZB G dI„ dJeA¦  «        ZC G dK„ dL¦  «        ZD G dM„ dN¦  «        ZE G dO„ dP¦  «        ZFdQ„ ZG G dR„ dSejH        ¦  «        ZI	 ddTlJmKZL dS # eM$ r!ZN e
jO        eN¦  «         ddUlPmQZL Y dZN[NdS dZN[Nww xY w)Vak  Knit versionedfile implementation.

A knit is a versioned file implementation that supports efficient append only
updates.

Knit file layout:
lifeless: the data file is made up of "delta records".  each delta record has a delta header
that contains; (1) a version id, (2) the size of the delta (in lines), and (3)  the digest of
the -expanded data- (ie, the delta applied to the parent).  the delta also ends with a
end-marker; simply "end VERSION"

delta can be line or full contents.a
... the 8's there are the index number of the annotation.
version robertc@robertcollins.net-20051003014215-ee2990904cc4c7ad 7 c7d23b2a5bd6ca00e8e266cec0ec228158ee9f9e
59,59,3
8
8         if ie.executable:
8             e.set('executable', 'yes')
130,130,2
8         if elt.get('executable') == 'yes':
8             ie.executable = True
end robertc@robertcollins.net-20051003014215-ee2990904cc4c7ad


whats in an index:
09:33 < jrydberg> lifeless: each index is made up of a tuple of; version id, options, position, size, parents
09:33 < jrydberg> lifeless: the parents are currently dictionary compressed
09:33 < jrydberg> lifeless: (meaning it currently does not support ghosts)
09:33 < lifeless> right
09:33 < jrydberg> lifeless: the position and size is the range in the data file


so the index sequence is the dictionary compressed sequence number used
in the deltas to provide line annotation

é    N)ÚBytesIOé   )Úlazy_importzý
import patiencediff
import gzip

from breezy import (
    debug,
    diff,
    trace,
    tsort,
    ui,
    )
from breezy.bzr import (
    pack,
    static_tuple,
    tuned_gzip,
    )

from breezy.bzr import pack_repo
from breezy.i18n import gettext
)ÚannotateÚerrorsÚosutilsÚ	transport)ÚInternalBzrErrorÚInvalidRevisionIdÚRevisionNotPresent)Úcontains_whitespaceÚ
sha_stringÚsha_stringsÚsplit_lines)Ú
NoSuchFile)	Ú_KeyRefsÚAbsentContentFactoryÚadapter_registryÚConstantMapperÚContentFactoryÚExistingContentÚsort_groupcompressÚUnavailableRepresentationÚVersionedFilesWithFallbacksé   )Úindexú.knitú.kndxi  P c                   ó   — e Zd ZdZdS )Ú	KnitErrorz
Knit errorN)Ú__name__Ú
__module__Ú__qualname__Ú_fmt© ó    ú1/usr/lib/python3/dist-packages/breezy/bzr/knit.pyr    r    …   s   € € € € € à€D€D€Dr&   r    c                   ó   — e Zd ZdZd„ ZdS )ÚKnitCorruptz"Knit %(filename)s corrupt: %(how)sc                 óV   — t                                | ¦  «         || _        || _        d S ©N)r    Ú__init__ÚfilenameÚhow)Úselfr-   r.   s      r'   r,   zKnitCorrupt.__init__Ž   s(   € Ý×Ò˜4Ñ Ô Ð Ø ˆŒØˆŒˆˆr&   N©r!   r"   r#   r$   r,   r%   r&   r'   r)   r)   Š   s(   € € € € € à/€Dðð ð ð ð r&   r)   c                   ó   — e Zd ZdZd„ ZdS )ÚSHA1KnitCorruptz‘Knit %(filename)s corrupt: sha-1 of reconstructed text does not match expected sha-1. key %(key)s expected sha %(expected)s actual sha %(actual)sc                 ó€   — t                                | ¦  «         || _        || _        || _        || _        || _        d S r+   )r    r,   r-   ÚactualÚexpectedÚkeyÚcontent)r/   r-   r4   r5   r6   r7   s         r'   r,   zSHA1KnitCorrupt.__init__š   s=   € Ý×Ò˜4Ñ Ô Ð Ø ˆŒØˆŒØ ˆŒØˆŒØˆŒˆˆr&   Nr0   r%   r&   r'   r2   r2   ”   s*   € € € € € ð€Dðð ð ð ð r&   r2   c                   ó   — e Zd ZdZd„ ZdS )ÚKnitDataStreamIncompatiblezeCannot insert knit data stream of format "%(stream_format)s" into knit of format "%(target_format)s".c                 ó"   — || _         || _        d S r+   )Ústream_formatÚtarget_format)r/   r;   r<   s      r'   r,   z#KnitDataStreamIncompatible.__init__©   s   € Ø*ˆÔØ*ˆÔÐÐr&   Nr0   r%   r&   r'   r9   r9   £   s+   € € € € € ð w€Dð+ð +ð +ð +ð +r&   r9   c                   ó   — e Zd ZdZd„ ZdS )ÚKnitDataStreamUnknownz<Cannot parse knit data stream of format "%(stream_format)s".c                 ó   — || _         d S r+   )r;   )r/   r;   s     r'   r,   zKnitDataStreamUnknown.__init__³   s   € Ø*ˆÔÐÐr&   Nr0   r%   r&   r'   r>   r>   ®   s+   € € € € € ð L€Dð+ð +ð +ð +ð +r&   r>   c                   ó   — e Zd ZdZd„ ZdS )ÚKnitHeaderErrorzBKnit header error: %(badline)r unexpected for file "%(filename)s".c                 óV   — t                                | ¦  «         || _        || _        d S r+   )r    r,   Úbadliner-   )r/   rC   r-   s      r'   r,   zKnitHeaderError.__init__»   s(   € Ý×Ò˜4Ñ Ô Ð ØˆŒØ ˆŒˆˆr&   Nr0   r%   r&   r'   rA   rA   ·   s(   € € € € € àO€Dð!ð !ð !ð !ð !r&   rA   c                   ó   — e Zd ZdZdZd„ ZdS )ÚKnitIndexUnknownMethodzwRaised when we don't understand the storage method.

    Currently only 'fulltext' and 'line-delta' are supported.
    zLKnit index %(filename)s does not have a known method in options: %(options)rc                 óV   — t                                | ¦  «         || _        || _        d S r+   )r    r,   r-   Úoptions)r/   r-   rG   s      r'   r,   zKnitIndexUnknownMethod.__init__Ê   s(   € Ý×Ò˜4Ñ Ô Ð Ø ˆŒØˆŒˆˆr&   N)r!   r"   r#   Ú__doc__r$   r,   r%   r&   r'   rE   rE   Á   s4   € € € € € ðð ð
'€Dðð ð ð ð r&   rE   c                   ó   — e Zd ZdZd„ ZdS )ÚKnitAdapterz$Base class for knit record adaption.c                 óŠ   — t          dd¦  «        | _        t          ¦   «         | _        t	          ¦   «         | _        || _        dS )záCreate an adapter which accesses full texts from basis_vf.

        :param basis_vf: A versioned file to access basis texts of deltas from.
            May be None for adapters that do not need to access basis texts.
        N)ÚKnitVersionedFilesÚ_dataÚKnitAnnotateFactoryÚ_annotate_factoryÚKnitPlainFactoryÚ_plain_factoryÚ	_basis_vf)r/   Úbasis_vfs     r'   r,   zKnitAdapter.__init__Ó   s<   € õ (¨¨dÑ3Ô3ˆŒ
Ý!4Ñ!6Ô!6ˆÔÝ.Ñ0Ô0ˆÔØ!ˆŒˆˆr&   N©r!   r"   r#   rH   r,   r%   r&   r'   rJ   rJ   Ð   s)   € € € € € Ø.Ð.ð	"ð 	"ð 	"ð 	"ð 	"r&   rJ   c                   ó   — e Zd ZdZd„ ZdS )ÚFTAnnotatedToUnannotatedú7An adapter from FT annotated knits to unannotated ones.c                 ót  — |dk    rt          |j        ||j        ¦  «        ‚|j        }| j                             |¦  «        \  }}| j                             ||d         ¦  «        }| j                             |d         f|d         | 	                    ¦   «         ¦  «        \  }}d 
                    |¦  «        S )Nú
knit-ft-gzr   é   r&   )r   r6   Ústorage_kindÚ_raw_recordrM   Ú_parse_record_uncheckedrO   Úparse_fulltextÚ_record_to_dataÚtextÚjoin)	r/   ÚfactoryÚtarget_storage_kindÚannotated_compressed_bytesÚrecÚcontentsr7   ÚsizeÚchunkss	            r'   Ú	get_bytesz"FTAnnotatedToUnannotated.get_bytesâ   s·   € Ø ,Ò.Ð.Ý+Ø”Ð0°'Ô2FñHô Hð Hà%,Ô%8Ð"àŒJ×.Ò.Ð/IÑJÔJñ 	ˆˆXàÔ(×7Ò7¸À#ÀaÄ&ÑIÔIˆØ”z×1Ò1Ø�ŒVˆI�s˜1”v˜wŸ|š|™~œ~ñ/ô /‰ˆˆfà�xŠx˜ÑÔÐr&   N©r!   r"   r#   rH   ri   r%   r&   r'   rV   rV   ß   s)   € € € € € ØAÐAð
 ð 
 ð 
 ð 
 ð 
 r&   rV   c                   ó   — e Zd ZdZd„ ZdS )ÚDeltaAnnotatedToUnannotatedú4An adapter for deltas from annotated to unannotated.c                 óˆ  — |dk    rt          |j        ||j        ¦  «        ‚|j        }| j                             |¦  «        \  }}| j                             ||d         d¬¦  «        }| j         	                    |¦  «        }| j         
                    |d         f|d         |¦  «        \  }}d                     |¦  «        S )Núknit-delta-gzr   T©ÚplainrZ   r&   )r   r6   r[   r\   rM   r]   rO   Úparse_line_deltarQ   Úlower_line_deltar_   ra   )	r/   rb   rc   rd   re   rf   Údeltarg   rh   s	            r'   ri   z%DeltaAnnotatedToUnannotated.get_bytesò   sÎ   € Ø /Ò1Ð1Ý+Ø”Ð0°'Ô2FñHô Hð Hà%,Ô%8Ð"àŒJ×.Ò.Ð/IÑJÔJñ 	ˆˆXàÔ&×7Ò7¸À#ÀaÄ&Ø>Bð 8ñ Dô DˆàÔ&×7Ò7¸Ñ>Ô>ˆØ”z×1Ò1°3°q´6°)¸SÀ¼VÀXÑNÔN‰ˆˆfØ�xŠx˜ÑÔÐr&   Nrj   r%   r&   r'   rl   rl   ï   s)   € € € € € Ø>Ð>ð ð  ð  ð  ð  r&   rl   c                   ó   — e Zd ZdZd„ ZdS )ÚFTAnnotatedToFullTextrW   c                 ój  — |j         }| j                             |¦  «        \  }}| j                             |j        d         ||j        d ¦  «        \  }}|dk    r'd                     |                     ¦   «         ¦  «        S |dv r|                     ¦   «         S t          |j        ||j
        ¦  «        ‚©NéÿÿÿÿÚfulltextr&   ©ÚchunkedÚlines)r\   rM   r]   rO   Úparse_recordr6   Ú_build_detailsra   r`   r   r[   )r/   rb   rc   rd   re   rf   r7   rt   s           r'   ri   zFTAnnotatedToFullText.get_bytes  sº   € Ø%,Ô%8Ð"àŒJ×.Ò.Ð/IÑJÔJñ 	ˆˆXàÔ/×<Ò<¸W¼[È¼_Ø=EÀwÔG]Ð_cñeô e‰ˆ�à *Ò,Ð,Ø—8’8˜GŸLšL™NœNÑ+Ô+Ð+Ø Ð$8Ð8Ð8Ø—<’<‘>”>Ð!Ý'ØŒKÐ,¨gÔ.BñDô Dð 	Dr&   Nrj   r%   r&   r'   rv   rv      s.   € € € € € ØAÐAðDð Dð Dð Dð Dr&   rv   c                   ó   — e Zd ZdZd„ ZdS )ÚDeltaAnnotatedToFullTextrm   c                 ó®  — |j         }| j                             |¦  «        \  }}| j                             ||d         d¬¦  «        }|j        d         }t          | j                             |gdd¦  «        ¦  «        }|j	        dk    rt          j        || j        ¦  «        ‚|                     d¦  «        }	t          |	|¦  «        }
|
                     ||d         ¦  «         |j        d         |
_        |dk    r'd	                     |
                     ¦   «         ¦  «        S |d
v r|
                     ¦   «         S t'          |j        ||j	        ¦  «        ‚)Nr   Trp   r   Ú	unorderedÚabsentr}   rz   r&   r{   )r\   rM   r]   rO   rr   ÚparentsÚnextrR   Úget_record_streamr[   r   r   Úget_bytes_asÚPlainKnitContentÚapply_deltar   Ú_should_strip_eolra   r`   r   r6   )r/   rb   rc   rd   re   rf   rt   Úcompression_parentÚbasis_entryÚbasis_linesÚbasis_contents              r'   ri   z"DeltaAnnotatedToFullText.get_bytes  sh  € Ø%,Ô%8Ð"àŒJ×.Ò.Ð/IÑJÔJñ 	ˆˆXàÔ&×7Ò7¸À#ÀaÄ&Ø>Bð 8ñ Dô Dˆà$œ_¨QÔ/ÐÝ˜4œ>×;Ò;ØÐ  +¨tñ5ô 5ñ 6ô 6ˆàÔ# xÒ/Ð/ÝÔ+Ð,>ÀÄÑOÔOÐOØ!×.Ò.¨wÑ7Ô7ˆõ )¨Ð6HÑIÔIˆØ×!Ò! %¨¨Q¬Ñ0Ô0Ð0Ø*1Ô*@ÀÔ*CˆÔ'à *Ò,Ð,Ø—8’8˜M×.Ò.Ñ0Ô0Ñ1Ô1Ð1Ø Ð$8Ð8Ð8Ø ×%Ò%Ñ'Ô'Ð'Ý'ØŒKÐ,¨gÔ.BñDô Dð 	Dr&   Nrj   r%   r&   r'   r�   r�     s.   € € € € € Ø>Ð>ðDð Dð Dð Dð Dr&   r�   c                   ó   — e Zd ZdZd„ ZdS )ÚFTPlainToFullTextz3An adapter from FT plain knits to unannotated ones.c                 ój  — |j         }| j                             |¦  «        \  }}| j                             |j        d         ||j        d ¦  «        \  }}|dk    r'd                     |                     ¦   «         ¦  «        S |dv r|                     ¦   «         S t          |j        ||j
        ¦  «        ‚rx   )r\   rM   r]   rQ   r~   r6   r   ra   r`   r   r[   )r/   rb   rc   Úcompressed_bytesre   rf   r7   rt   s           r'   ri   zFTPlainToFullText.get_bytes1  sº   € Ø"Ô.ÐàŒJ×.Ò.Ð/?Ñ@Ô@ñ 	ˆˆXàÔ,×9Ò9¸'¼+Àb¼/Ø:BÀGÔDZÐ\`ñbô b‰ˆ�à *Ò,Ð,Ø—8’8˜GŸLšL™NœNÑ+Ô+Ð+Ø Ð$8Ð8Ð8Ø—<’<‘>”>Ð!Ý'ØŒKÐ,¨gÔ.BñDô Dð 	Dr&   Nrj   r%   r&   r'   r‘   r‘   .  s.   € € € € € Ø=Ð=ðDð Dð Dð Dð Dr&   r‘   c                   ó   — e Zd ZdZd„ ZdS )ÚDeltaPlainToFullTextrm   c                 ó¤  — |j         }| j                             |¦  «        \  }}| j                             ||d         ¦  «        }|j        d         }t          | j                             |gdd¦  «        ¦  «        }|j	        dk    rt          j        || j        ¦  «        ‚|                     d¦  «        }	t          |	|¦  «        }
| j                             |d         ||j        |
¦  «        \  }}|dk    r'd                     |                     ¦   «         ¦  «        S |d	v r|                     ¦   «         S t%          |j        ||j	        ¦  «        ‚)
Nr   r   rƒ   Tr„   r}   rz   r&   r{   )r\   rM   r]   rQ   rr   r…   r†   rR   r‡   r[   r   r   rˆ   r‰   r~   r   ra   r`   r   r6   )r/   rb   rc   r“   re   rf   rt   rŒ   r�   rŽ   r�   r7   Ú_s                r'   ri   zDeltaPlainToFullText.get_bytesB  sV  € Ø"Ô.ÐàŒJ×.Ò.Ð/?Ñ@Ô@ñ 	ˆˆXàÔ#×4Ò4°X¸sÀ1¼vÑFÔFˆØ$œ_¨QÔ/Ðå˜4œ>×;Ò;ØÐ  +¨tñ5ô 5ñ 6ô 6ˆàÔ# xÒ/Ð/ÝÔ+Ð,>ÀÄÑOÔOÐOØ!×.Ò.¨wÑ7Ô7ˆÝ(¨Ð6HÑIÔIˆð Ô(×5Ò5°c¸!´f¸hØ6=Ô6LÈmñ]ô ]‰
ˆ�à *Ò,Ð,Ø—8’8˜GŸLšL™NœNÑ+Ô+Ð+Ø Ð$8Ð8Ð8Ø—<’<‘>”>Ð!Ý'ØŒKÐ,¨gÔ.BñDô Dð 	Dr&   Nrj   r%   r&   r'   r•   r•   ?  s.   € € € € € Ø>Ð>ðDð Dð Dð Dð Dr&   r•   c                   ó.   — e Zd ZdZ	 dd„Zd„ Zd„ Zd„ ZdS )ÚKnitContentFactoryzLContent factory for streaming from knits.

    :seealso ContentFactory:
    Nc	                 óö   — t          j        | ¦  «         || _        || _        || _        |d         dk    rd}	nd}	|rd}
nd}
d                     |
|	¦  «        | _        || _        || _        || _	        || _
        dS )	a  Create a KnitContentFactory for key.

        :param key: The key.
        :param parents: The parents.
        :param build_details: The build details as returned from
            get_build_details.
        :param sha1: The sha1 expected from the full text of this object.
        :param raw_record: The bytes of the knit data from disk.
        :param annotated: True if the raw data is annotated.
        :param network_bytes: None to calculate the network bytes on demand,
            not-none if they are already known.
        r   ú
line-deltart   Úftú
annotated-Ú zknit-{}{}-gzN)r   r,   Úsha1r6   r…   Úformatr[   r\   Ú_network_bytesr   Ú_knit)r/   r6   r…   Úbuild_detailsrŸ   Ú
raw_recordÚ	annotatedÚknitÚnetwork_bytesÚkindÚannotated_kinds              r'   r,   zKnitContentFactory.__init__a  s•   € õ 	Ô Ñ%Ô%Ð%ØˆŒ	ØˆŒØˆŒØ˜Ô˜|Ò+Ð+ØˆDˆDàˆDØð 	 Ø)ˆNˆNàˆNØ*×1Ò1°.À$ÑGÔGˆÔØ%ˆÔØ+ˆÔØ+ˆÔØˆŒ
ˆ
ˆ
r&   c                 ó  — d                      | j        ¦  «        }| j        €d}n$d                      d„ | j        D ¦   «         ¦  «        }| j        d         rd}nd}d	| j                             d
¦  «        |||| j        fz  }|| _        dS )z;Create a fully serialised network version for transmission.ó    Nó   None:ó   	c              3   ó@   K  — | ]}d                       |¦  «        V — ŒdS ©r«   N©ra   ©Ú.0r6   s     r'   ú	<genexpr>z;KnitContentFactory._create_network_bytes.<locals>.<genexpr>ˆ  sB   è è € ð &?ð &?Ø*-ð '.§l¢l°3Ñ&7Ô&7ð &?ð &?ð &?ð &?ð &?ð &?r&   r   ó   Nó    s   %s
%s
%s
%s%sÚascii)ra   r6   r…   r   r[   Úencoder\   r¡   )r/   Ú	key_bytesÚparent_bytesÚnoeolr§   s        r'   Ú_create_network_bytesz(KnitContentFactory._create_network_bytes�  s²   € ð —L’L ¤Ñ*Ô*ˆ	ØŒ<ÐØ#ˆLˆLà Ÿ:š:ð &?ð &?Ø15´ð&?ñ &?ô &?ñ ?ô ?ˆLàÔ˜qÔ!ð 	ØˆEˆEàˆEØ+ØÔ×$Ò$ WÑ-Ô-¨yØ˜% Ô!1ð/3ñ 3ˆð ,ˆÔÐÐr&   c                 óÞ  — || j         k    r"| j        €|                      ¦   «          | j        S d| j         v rB|dv r>| j         |f}t          j        |¦  «        } |d ¦  «        }|                     | |¦  «        S | j        �T|dv r%| j                             | j        d         ¦  «        S |dk    r%| j         	                    | j        d         ¦  «        S t          | j        || j         ¦  «        ‚)Nz-ft-©r|   rz   r}   r{   r   rz   )r[   r¡   r»   r   Úgetri   r¢   Ú	get_linesr6   Úget_textr   )r/   r[   Úadapter_keyÚadapter_factoryÚadapters        r'   rˆ   zKnitContentFactory.get_bytes_as“  s  € Ø˜4Ô,Ò,Ð,ØÔ"Ð*Ø×*Ò*Ñ,Ô,Ð,ØÔ&Ð&Ø�dÔ'Ð'Ð'Ø Ð$DÐDÐDØÔ,¨lÐ;ˆKÝ.Ô2°;Ñ?Ô?ˆOØ%�o dÑ+Ô+ˆGØ×$Ò$ T¨<Ñ8Ô8Ð8ØŒ:Ð!ð Ð3Ð3Ð3Ø”z×+Ò+¨D¬H°Q¬KÑ8Ô8Ð8Ø Ò+Ð+Ø”z×*Ò*¨4¬8°A¬;Ñ7Ô7Ð7Ý'¨¬°,Ø(,Ô(9ñ;ô ;ð 	;r&   c                 óF   — t          |                      |¦  «        ¦  «        S r+   )Úiterrˆ   )r/   r[   s     r'   Úiter_bytes_asz KnitContentFactory.iter_bytes_as¨  s   € Ý�D×%Ò% lÑ3Ô3Ñ4Ô4Ð4r&   ©NN)r!   r"   r#   rH   r,   r»   rˆ   rÆ   r%   r&   r'   r™   r™   [  se   € € € € € ðð ð 6:ðð ð ð ð@,ð ,ð ,ð$;ð ;ð ;ð*5ð 5ð 5ð 5ð 5r&   r™   c                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )ÚLazyKnitContentFactoryzgA ContentFactory which can either generate full text or a wire form.

    :seealso ContentFactory:
    c                 óŠ   — || _         || _        d| _        d| _        || _        d| _        |s| j        dz   | _        || _        dS )aª  Create a LazyKnitContentFactory.

        :param key: The key of the record.
        :param parents: The parents of the record.
        :param generator: A _ContentMapGenerator containing the record for this
            key.
        :param first: Is this the first content object returned from generator?
            if it is, its storage kind is knit-delta-closure, otherwise it is
            knit-delta-closure-ref
        Nzknit-delta-closurez-ref)r6   r…   rŸ   rg   Ú
_generatorr[   Ú_first)r/   r6   r…   Ú	generatorÚfirsts        r'   r,   zLazyKnitContentFactory.__init__²  sR   € ð ˆŒØˆŒØˆŒ	ØˆŒ	Ø#ˆŒØ0ˆÔØð 	;Ø $Ô 1°FÑ :ˆDÔØˆŒˆˆr&   c                 ó2  — || j         k    r"| j        r| j                             ¦   «         S dS |dv rL| j                             | j        ¦  «                             ¦   «         }|dv r|S d                     |¦  «        S t          | j        || j         ¦  «        ‚)Nr&   r½   r{   )	r[   rÌ   rË   Ú_wire_bytesÚ_get_one_workr6   r`   ra   r   ©r/   r[   rh   s      r'   rˆ   z#LazyKnitContentFactory.get_bytes_asÇ  s¥   € Ø˜4Ô,Ò,Ð,ØŒ{ð Ø”×2Ò2Ñ4Ô4Ð4ð �sØÐ;Ð;Ð;Ø”_×2Ò2°4´8Ñ<Ô<×AÒAÑCÔCˆFØÐ3Ð3Ð3Ø�à—x’x Ñ'Ô'Ð'Ý'¨¬°,Ø(,Ô(9ñ;ô ;ð 	;r&   c                 óÊ   — |dv r@| j                              | j        ¦  «                             ¦   «         }t	          |¦  «        S t          j        | j        || j        ¦  «        ‚)Nr{   )rË   rÑ   r6   r`   rÅ   r   r   r[   rÒ   s      r'   rÆ   z$LazyKnitContentFactory.iter_bytes_asØ  sa   € ØÐ/Ð/Ð/Ø”_×2Ò2°4´8Ñ<Ô<×AÒAÑCÔCˆFÝ˜‘<”<ÐÝÔ.¨t¬x¸Ø/3Ô/@ñBô Bð 	Br&   N)r!   r"   r#   rH   r,   rˆ   rÆ   r%   r&   r'   rÉ   rÉ   ¬  sP   € € € € € ðð ð
ð ð ð*;ð ;ð ;ð"Bð Bð Bð Bð Br&   rÉ   c                 óJ   — t          ||¦  «        }|                     ¦   «         S )zÚConvert a network record to a iterator over stream records.

    :param storage_kind: The storage kind of the record.
        Must be 'knit-delta-closure'.
    :param bytes: The bytes of the record on the network.
    )Ú_NetworkContentMapGeneratorr‡   )r[   ÚbytesÚline_endrÍ   s       r'   Úknit_delta_closure_to_recordsrØ   à  s%   € õ ,¨E°8Ñ<Ô<€IØ×&Ò&Ñ(Ô(Ð(r&   c           	      óÔ  — |}|                      d|¦  «        }t          |||…                              d¦  «        ¦  «        }|dz   }|                      d|¦  «        }|||…         }|dk    rd}n,t          d„ |                     d¦  «        D ¦   «         ¦  «        }|dz   }|||dz   …         dk    }d	| v rd
}nd}||f}	|dz   }||d…         }
d| v }t          |||	d|
||¬¦  «        gS )z¥Convert a network record to a record object.

    :param storage_kind: The storage kind of the record.
    :param bytes: The bytes of the record on the network.
    ó   
r«   r   r¬   Nc                 óV   — g | ]&}|¯t          |                     d ¦  «        ¦  «        ‘Œ'S ©r«   ©ÚtupleÚsplit©r²   Úsegments     r'   ú
<listcomp>z*knit_network_to_record.<locals>.<listcomp>û  s@   € ð ð ð ¨wØð�U�7—=’= Ñ)Ô)Ñ*Ô*ð ð ð r&   r­   r´   rœ   rz   r›   r¥   )r§   )ÚfindrÞ   rß   r™   )r[   rÖ   r×   Ústartr6   Úparent_liner…   rº   Úmethodr£   r¤   r¥   s               r'   Úknit_network_to_recordrç   ë  sC  € ð €EØ�zŠz˜% Ñ'Ô'€HÝ
��e˜H�nÔ%×+Ò+¨GÑ4Ô4Ñ
5Ô
5€CØ�q‰L€EØ�zŠz˜% Ñ'Ô'€HØ˜˜h˜Ô'€KØ�hÒÐØˆˆåðð ¸+×:KÒ:KÈEÑ:RÔ:Rð ñ ô ñô ˆð �q‰L€EØ�%˜ ™	�/Ô" dÒ*€EØˆ|ÐÐØˆˆàˆØ˜U�O€MØ�A‰I€EØ�u�v�v”€JØ˜|Ð+€IÝ˜s G¨]¸DÀ*Ø(¸ð?ñ ?ô ?ð @ð @r&   c                   ó@   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zed„ ¦   «         Z	dS )ÚKnitContenta  Content of a knit version to which deltas can be applied.

    This is always stored in memory as a list of lines with \n at the end,
    plus a flag saying if the final ending is really there or not, because that
    corresponds to the on-disk knit representation.
    c                 ó   — d| _         d S )NF)r‹   ©r/   s    r'   r,   zKnitContent.__init__  s   € Ø!&ˆÔÐÐr&   c                 ó*   — t          | j        ¦  «        ‚)ú4Apply delta to this object to become new_version_id.)ÚNotImplementedErrorrŠ   )r/   rt   Únew_version_ids      r'   rŠ   zKnitContent.apply_delta  s   € å! $Ô"2Ñ3Ô3Ð3r&   c              #   ó
  K  — |                      ¦   «         }|                       ¦   «         }t                               d||¦  «        }|                     ¦   «         D ]'\  }}}}}	|dk    rŒ|||	|z
  |j        ||	…         fV — Œ(dS )z9Generate line-based delta from this content to new_lines.NÚequal)r`   ÚpatiencediffÚPatienceSequenceMatcherÚget_opcodesÚ_lines)
r/   Ú	new_linesÚ	new_textsÚ	old_textsÚsÚtagÚi1Úi2Új1Új2s
             r'   Úline_delta_iterzKnitContent.line_delta_iter  s™   è è € à—N’NÑ$Ô$ˆ	Ø—I’I‘K”Kˆ	Ý×0Ò0°°yÀ)ÑLÔLˆØ#$§=¢=¡?¤?ð 	;ð 	;ÑˆC��R˜˜RØ�gŠ~ˆ~Øà�b˜"˜r™' 9Ô#3°B°r°EÔ#:Ð:Ð:Ð:Ð:Ð:ð		;ð 	;r&   c                 óF   — t          |                      |¦  «        ¦  «        S r+   )Úlistrÿ   )r/   rö   s     r'   Ú
line_deltazKnitContent.line_delta%  s   € Ý�D×(Ò(¨Ñ3Ô3Ñ4Ô4Ð4r&   c              #   ób  K  — t          |¦  «        }d}d}| D ]N\  }}}}	||z
  }
|
}|dk    r0|||z   dz
           |||z   dz
           k    r|dz  }|dk    r|||fV — |||
z   z  }|}ŒO||z
  }|dk    r0|||z   dz
           |||z   dz
           k    r|dz  }|dk    r|||fV — |||z
  z   |dfV — dS )z?Extract SequenceMatcher.get_matching_blocks() from a knit deltar   r   N)Úlen)Ú
knit_deltaÚsourceÚtargetÚ
target_lenÚs_posÚt_posÚs_beginÚs_endÚt_lenÚnew_textÚtrue_nÚns               r'   Úget_line_delta_blocksz!KnitContent.get_line_delta_blocks(  s+  è è € õ ˜‘[”[ˆ
ØˆØˆØ/9ð 	ð 	Ñ+ˆG�U˜E 8Ø˜u‘_ˆFØˆAØ�1Šuˆuð ˜% !™) a™-Ô(¨F°5¸1±9¸q±=Ô,AÒAÐAØ˜‘F�AØ�q’5�5Ø ¨˜/Ð)Ð)Ð)Ø�U˜V‘^Ñ#ˆEØˆEˆEØ˜ÑˆØˆqŠ5ˆ5Ø�e˜a‘i !‘mÔ$¨¨u°q©y¸1©}Ô(=Ò=Ð=Ø�Q‘�Ø�1ŠuˆuØ˜U A�oÐ%Ð%Ð%Ø�z EÑ)Ñ*¨J¸Ð9Ð9Ð9Ð9Ð9Ð9r&   N)
r!   r"   r#   rH   r,   rŠ   rÿ   r  Ústaticmethodr  r%   r&   r'   ré   ré     su   € € € € € ðð ð'ð 'ð 'ð4ð 4ð 4ð	;ð 	;ð 	;ð5ð 5ð 5ð ð:ð :ñ „\ð:ð :ð :r&   ré   c                   ó0   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ ZdS )ÚAnnotatedKnitContentzAnnotated content.c                 ób   — t                                | ¦  «         t          |¦  «        | _        d S r+   )ré   r,   r  rõ   ©r/   r}   s     r'   r,   zAnnotatedKnitContent.__init__F  s'   € Ý×Ò˜TÑ"Ô"Ð"Ý˜5‘k”kˆŒˆˆr&   c                 ó|   — | j         dd…         }| j        r%|d         \  }}||                     d¦  «        f|d<   |S )ú6Return a list of (origin, text) for each content line.Nry   rÚ   ©rõ   r‹   Úrstrip)r/   r}   ÚoriginÚ	last_lines       r'   r   zAnnotatedKnitContent.annotateJ  sK   € à”˜A˜A˜A”ˆØÔ!ð 	:Ø % b¤	ÑˆF�IØ ×!1Ò!1°%Ñ!8Ô!8Ð9ˆE�"‰IØˆr&   c                 ó\   — d}| j         }|D ]\  }}}}||||z   ||z   …<   |||z
  z   |z   }Œ dS ©rí   r   N©rõ   ©	r/   rt   rï   Úoffsetr}   rä   ÚendÚcountÚdelta_liness	            r'   rŠ   z AnnotatedKnitContent.apply_deltaR  s\   € àˆØ”ˆØ.3ð 	4ð 	4Ñ*ˆE�3˜˜{Ø1<ˆE�&˜5‘. ¨#¡Ð-Ñ.Ø˜u s™{Ñ+¨eÑ3ˆFˆFð	4ð 	4r&   c                 óÀ   — 	 d„ | j         D ¦   «         }n%# t          $ r}t          | d|›�¦  «        ‚d }~ww xY w| j        r|d                              d¦  «        |d<   |S )Nc                 ó   — g | ]\  }}|‘ŒS r%   r%   ©r²   r  r`   s      r'   râ   z-AnnotatedKnitContent.text.<locals>.<listcomp>\  s   € Ð:Ð:Ð:™l˜f d�TÐ:Ð:Ð:r&   z7line in annotated knit missing annotation information: ry   rÚ   )rõ   Ú
ValueErrorr)   r‹   r  )r/   r}   Úes      r'   r`   zAnnotatedKnitContent.textZ  sŒ   € ð	&Ø:Ð:¨d¬kÐ:Ñ:Ô:ˆEˆEøÝð 	&ð 	&ð 	&õ ˜d˜dà!" ð%ñ&ô &ð &øøøøð		&øøøð Ô!ð 	0Ø˜bœ	×(Ò(¨Ñ/Ô/ˆE�"‰IØˆs   ‚ ”
6ž1±6c                 ó*   — t          | j        ¦  «        S r+   )r  rõ   rë   s    r'   ÚcopyzAnnotatedKnitContent.copyh  s   € Ý# D¤KÑ0Ô0Ð0r&   N)	r!   r"   r#   rH   r,   r   rŠ   r`   r+  r%   r&   r'   r  r  C  se   € € € € € ØÐð"ð "ð "ðð ð ð4ð 4ð 4ðð ð ð1ð 1ð 1ð 1ð 1r&   r  c                   ó0   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ ZdS )r‰   zÈUnannotated content.

    When annotate[_iter] is called on this content, the same version is reported
    for all lines. Generally, annotate[_iter] is not useful on PlainKnitContent
    objects.
    c                 óV   — t                                | ¦  «         || _        || _        d S r+   )ré   r,   rõ   Ú_version_id©r/   r}   Ú
version_ids      r'   r,   zPlainKnitContent.__init__t  s+   € Ý×Ò˜TÑ"Ô"Ð"ØˆŒØ%ˆÔÐÐr&   c                 ó*   ‡ — ˆ fd„‰ j         D ¦   «         S )r  c                 ó"   •— g | ]}‰j         |f‘ŒS r%   )r.  )r²   Úliner/   s     €r'   râ   z-PlainKnitContent.annotate.<locals>.<listcomp>{  s!   ø€ ÐAÐAÐA¨T�Ô! 4Ð(ÐAÐAÐAr&   r  rë   s   `r'   r   zPlainKnitContent.annotatey  s   ø€ àAÐAÐAÐA°T´[ÐAÑAÔAÐAr&   c                 ój   — d}| j         }|D ]\  }}}}||||z   ||z   …<   |||z
  z   |z   }Œ || _        dS r  )rõ   r.  r   s	            r'   rŠ   zPlainKnitContent.apply_delta}  s`   € àˆØ”ˆØ.3ð 	4ð 	4Ñ*ˆE�3˜˜{Ø1<ˆE�&˜5‘. ¨#¡Ð-Ñ.Ø˜u s™{Ñ+¨eÑ3ˆFˆFØ)ˆÔÐÐr&   c                 óF   — t          | j        d d …         | j        ¦  «        S r+   )r‰   rõ   r.  rë   s    r'   r+  zPlainKnitContent.copy†  s   € Ý ¤¨A¨A¨A¤°Ô0@ÑAÔAÐAr&   c                 ór   — | j         }| j        r(|d d …         }|d                              d¦  «        |d<   |S )Nry   rÚ   r  r  s     r'   r`   zPlainKnitContent.text‰  sA   € Ø”ˆØÔ!ð 	0Ø˜!˜!˜!”HˆEØ˜bœ	×(Ò(¨Ñ/Ô/ˆE�"‰IØˆr&   N)	r!   r"   r#   rH   r,   r   rŠ   r+  r`   r%   r&   r'   r‰   r‰   l  so   € € € € € ðð ð&ð &ð &ð
Bð Bð Bð*ð *ð *ðBð Bð Bðð ð ð ð r&   r‰   c                   ó   — e Zd ZdZ	 dd„ZdS )Ú_KnitFactoryz(Base class for common Factory functions.Tc                 óê   — |\  }}|dk    rF|r|                      ¦   «         }n|}|                      ||¦  «        }	|                     |	|¦  «         n|                      ||¦  «        }d}	||_        ||	fS )aÂ  Parse a record into a full content object.

        :param version_id: The official version id for this content
        :param record: The data returned by read_records_iter()
        :param record_details: Details about the record returned by
            get_build_details
        :param base_content: If get_build_details returns a compression_parent,
            you must return a base_content here, else use None
        :param copy_base_content: When building from the base_content, decide
            you can either copy it and return a new object, or modify it in
            place.
        :return: (content, delta) A Content object and possibly a line-delta,
            delta may be None
        r›   N)r+  rr   rŠ   r^   r‹   )
r/   r0  ÚrecordÚrecord_detailsÚbase_contentÚcopy_base_contentræ   rº   r7   rt   s
             r'   r~   z_KnitFactory.parse_record”  s“   € ð  '‰ˆ�Ø�\Ò!Ð!Ø ð 'Ø&×+Ò+Ñ-Ô-��à&�Ø×)Ò)¨&°*Ñ=Ô=ˆEØ×Ò  zÑ2Ô2Ð2Ð2à×)Ò)¨&°*Ñ=Ô=ˆGØˆEØ$)ˆÔ!Ø˜ÐÐr&   N)T)r!   r"   r#   rH   r~   r%   r&   r'   r8  r8  ‘  s3   € € € € € Ø2Ð2ð 6:ð ð  ð  ð  ð  ð  r&   r8  c                   óH   — e Zd ZdZdZd„ Zd„ Zdd„Zd„ Zd„ Z	d	„ Z
d
„ Zd„ ZdS )rN   z/Factory for creating annotated Content objects.Tc                 ób   — t          |¦  «        }t          t          |g|z  |¦  «        ¦  «        S r+   )r  r  Úzip)r/   r}   r0  Ú	num_liness       r'   ÚmakezKnitAnnotateFactory.make¸  s,   € Ý˜‘J”Jˆ	Ý#¥C¨¨°yÑ(@À%Ñ$HÔ$HÑIÔIÐIr&   c                 ó8   — d„ |D ¦   «         }t          |¦  «        S )zËConvert fulltext to internal representation

        fulltext content is of the format
        revid(utf8) plaintext

        internal representation is of the format:
        (revid, plaintext)
        c              3   ó\   K  — | ]'}t          |                     d d¦  «        ¦  «        V — Œ(dS ©rµ   r   NrÝ   ©r²   r3  s     r'   r³   z5KnitAnnotateFactory.parse_fulltext.<locals>.<genexpr>È  s8   è è € Ð@Ð@°•�t—z’z $¨Ñ*Ô*Ñ+Ô+Ð@Ð@Ð@Ð@Ð@Ð@r&   )r  )r/   r7   r0  r}   s       r'   r^   z"KnitAnnotateFactory.parse_fulltext¼  s&   € ð AÐ@¸Ð@Ñ@Ô@ˆÝ# EÑ*Ô*Ð*r&   Fc                 ó°  ‡‡— g }t          ‰¦  «        Ši Šˆfd„}|r]‰D ]Y}d„ |                     d¦  «        D ¦   «         \  }}}	ˆfd„t          |	¦  «        D ¦   «         }
|                     |||	|
f¦  «         ŒZn\‰D ]Y}d„ |                     d¦  «        D ¦   «         \  }}}	ˆfd„t          |	¦  «        D ¦   «         }
|                     |||	|
f¦  «         ŒZ|S )aí  Convert a line based delta into internal representation.

        line delta is in the form of:
        intstart intend intcount
        1..count lines:
        revid(utf8) newline

        internal representation is
        (start, end, count, [1..count tuples (revid, newline)])

        :param plain: If True, the lines are returned as a plain
            list without annotations, not as a list of (origin, content) tuples, i.e.
            (start, end, count, [1..count newline])
        c                 óf   •— |                       dd¦  «        \  }}‰                     ||¦  «        |fS )Nrµ   r   )rß   Ú
setdefault)r3  r  r`   Úcaches      €r'   Úcache_and_returnz>KnitAnnotateFactory.parse_line_delta.<locals>.cache_and_returnÞ  s5   ø€ ØŸ:š: d¨AÑ.Ô.‰LˆF�DØ×#Ò# F¨FÑ3Ô3°TÐ9Ð9r&   c              3   ó4   K  — | ]}t          |¦  «        V — Œd S r+   ©Úint©r²   r  s     r'   r³   z7KnitAnnotateFactory.parse_line_delta.<locals>.<genexpr>ç  ó(   è è € Ð$HÐ$H°¥S¨¡V¤VÐ$HÐ$HÐ$HÐ$HÐ$HÐ$Hr&   ó   ,c                 ób   •— g | ]+}t          ‰¦  «                             d d¦  «        d         ‘Œ,S ©rµ   r   )r†   rß   ©r²   r—   r}   s     €r'   râ   z8KnitAnnotateFactory.parse_line_delta.<locals>.<listcomp>è  sD   ø€ ð 3ð 3ð 3Ø !õ ! ™KœK×-Ò-¨d°AÑ6Ô6°qÔ9ð 3ð 3ð 3r&   c              3   ó4   K  — | ]}t          |¦  «        V — Œd S r+   rM  rO  s     r'   r³   z7KnitAnnotateFactory.parse_line_delta.<locals>.<genexpr>í  rP  r&   c                 óp   •— g | ]2}t          t          ‰¦  «                             d d¦  «        ¦  «        ‘Œ3S rS  )rÞ   r†   rß   rT  s     €r'   râ   z8KnitAnnotateFactory.parse_line_delta.<locals>.<listcomp>î  sG   ø€ ð 3ð 3ð 3Ø !õ "¥$ u¡+¤+×"3Ò"3°D¸!Ñ"<Ô"<Ñ=Ô=ð 3ð 3ð 3r&   )rÅ   rß   ÚrangeÚappend)r/   r}   r0  rq   ÚresultrK  Úheaderrä   r"  r#  rf   rJ  s    `         @r'   rr   z$KnitAnnotateFactory.parse_line_deltaË  sL  øø€ ð ˆÝ�U‘”ˆàˆð	:ð 	:ð 	:ð 	:ð 	:ð ð 	=Øð =ð =�Ø$HÐ$H°V·\²\À$Ñ5GÔ5GÐ$HÑ$HÔ$HÑ!��s˜Eð3ð 3ð 3ð 3Ý%*¨5¡\¤\ð3ñ 3ô 3�à—’˜u c¨5°(Ð;Ñ<Ô<Ð<Ð<ð	=ð  ð =ð =�Ø$HÐ$H°V·\²\À$Ñ5GÔ5GÐ$HÑ$HÔ$HÑ!��s˜Eð3ð 3ð 3ð 3Ý%*¨5¡\¤\ð3ñ 3ô 3�à—’˜u c¨5°(Ð;Ñ<Ô<Ð<Ð<Øˆr&   c                 ó   — d„ |D ¦   «         S )ú/Extract just the content lines from a fulltext.c              3   óN   K  — | ] }|                      d d¦  «        d         V — Œ!dS rE  )rß   rF  s     r'   r³   z;KnitAnnotateFactory.get_fulltext_content.<locals>.<genexpr>õ  s5   è è € Ð9Ð9¨4�—
’
˜4 Ñ#Ô# AÔ&Ð9Ð9Ð9Ð9Ð9Ð9r&   r%   r  s     r'   Úget_fulltext_contentz(KnitAnnotateFactory.get_fulltext_contentó  s   € à9Ð9°5Ð9Ñ9Ô9Ð9r&   c              #   óþ   K  — t          |¦  «        }|D ]h}|                     d¦  «        }t          |d         ¦  «        }t          |¦  «        D ],}t	          |¦  «                             dd¦  «        \  }}|V — Œ-ŒidS )ú¨Extract just the content from a line delta.

        This doesn't return all of the extra information stored in a delta.
        Only the actual content lines.
        rQ  r   rµ   r   N©rÅ   rß   rN  rW  r†   )r/   r}   rZ  r#  r—   r  r`   s          r'   Úget_linedelta_contentz)KnitAnnotateFactory.get_linedelta_content÷  s�   è è € õ �U‘”ˆØð 	ð 	ˆFØ—\’\ $Ñ'Ô'ˆFÝ˜˜qœ	‘N”NˆEÝ˜5‘\”\ð ð �Ý# E™{œ{×0Ò0°°qÑ9Ô9‘�˜Ø�
�
�
�
ðð	ð 	r&   c                 ó$   — d„ |j         D ¦   «         S )ztconvert a fulltext content record into a serializable form.

        see parse_fulltext which this inverts.
        c                 ó"   — g | ]\  }}d ||fz  ‘ŒS )s   %s %sr%   )r²   ÚoÚts      r'   râ   z6KnitAnnotateFactory.lower_fulltext.<locals>.<listcomp>
  s%   € Ð=Ð=Ð=¡d a¨�˜A˜q˜6Ñ!Ð=Ð=Ð=r&   r  ©r/   r7   s     r'   Úlower_fulltextz"KnitAnnotateFactory.lower_fulltext  s   € ð
 >Ð=¨g¬nÐ=Ñ=Ô=Ð=r&   c                 ó’   — g }|D ]A\  }}}}|                      d|||fz  ¦  «         |                     d„ |D ¦   «         ¦  «         ŒB|S )zdconvert a delta into a serializable form.

        See parse_line_delta which this inverts.
        ó	   %d,%d,%d
c              3   ó,   K  — | ]\  }}|d z   |z   V — ŒdS )rµ   Nr%   r'  s      r'   r³   z7KnitAnnotateFactory.lower_line_delta.<locals>.<genexpr>  sC   è è € ð 2ð 2Ù'˜6 4ð  ‘} tÑ+ð 2ð 2ð 2ð 2ð 2ð 2r&   ©rX  Úextend©r/   rt   Úouträ   r"  Úcr}   s          r'   rs   z$KnitAnnotateFactory.lower_line_delta  sz   € ð ˆØ$)ð 	2ð 	2Ñ ˆE�3˜˜5Ø�JŠJ�}¨¨s°A Ñ6Ñ7Ô7Ð7Ø�JŠJð 2ð 2Ø+0ð2ñ 2ô 2ñ 2ô 2ð 2ð 2àˆ
r&   c                 ó  — |                      |¦  «        }t          |t          ¦  «        rE|d d…         }|                     ¦   «         }g }|D ] \  }}|                     ||fz   |f¦  «         Œ!|S |                     ¦   «         S ©Nry   )Ú_get_contentÚ
isinstancerÞ   r   rX  )	r/   r¦   r6   r7   ÚprefixÚoriginsrY  r  r3  s	            r'   r   zKnitAnnotateFactory.annotate  s™   € Ø×#Ò# CÑ(Ô(ˆõ �c�5Ñ!Ô!ð 
	&Ø˜˜"˜”XˆFØ×&Ò&Ñ(Ô(ˆGØˆFØ 'ð :ð :‘�˜Ø—’˜v¨¨	Ñ1°4Ð8Ñ9Ô9Ð9Ð9ØˆMð ×#Ò#Ñ%Ô%Ð%r&   N©F)r!   r"   r#   rH   r¥   rB  r^   rr   r^  rb  rh  rs   r   r%   r&   r'   rN   rN   ³  s    € € € € € Ø9Ð9à€IðJð Jð Jð+ð +ð +ð&ð &ð &ð &ðP:ð :ð :ðð ð ð>ð >ð >ðð ð ð&ð &ð &ð &ð &r&   rN   c                   óL   — e Zd ZdZdZd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ ZdS )rP   z+Factory for creating plain Content objects.Fc                 ó"   — t          ||¦  «        S r+   )r‰   r/  s      r'   rB  zKnitPlainFactory.make0  s   € Ý  zÑ2Ô2Ð2r&   c                 ó.   — |                       ||¦  «        S )z°This parses an unannotated fulltext.

        Note that this is not a noop - the internal representation
        has (versionid, line) - its just a constant versionid.
        )rB  )r/   r7   r0  s      r'   r^   zKnitPlainFactory.parse_fulltext3  s   € ð �yŠy˜ *Ñ-Ô-Ð-r&   c              #   óØ   K  — d}t          |¦  «        }||k     rP||         }|dz  }d„ |                     d¦  «        D ¦   «         \  }}}|||||||z   …         fV — ||z  }||k     °Nd S d S )Nr   r   c              3   ó4   K  — | ]}t          |¦  «        V — Œd S r+   rM  rO  s     r'   r³   z9KnitPlainFactory.parse_line_delta_iter.<locals>.<genexpr>A  s(   è è € Ð@Ð@¨�S ™VœVÐ@Ð@Ð@Ð@Ð@Ð@r&   rQ  )r  rß   )	r/   r}   r0  ÚcurrA  rZ  rä   r"  rp  s	            r'   Úparse_line_delta_iterz&KnitPlainFactory.parse_line_delta_iter;  s”   è è € ØˆÝ˜‘J”Jˆ	Ø�IŠoˆoØ˜3”ZˆFØ�1‰HˆCØ@Ð@¨V¯\ª\¸$Ñ-?Ô-?Ð@Ñ@Ô@‰MˆE�3˜Ø˜˜a  s¨3°©7 {Ô!3Ð3Ð3Ð3Ð3Ø�1‰HˆCð �IŠoˆoˆoˆoˆoˆor&   c                 óH   — t          |                      ||¦  «        ¦  «        S r+   )r  r~  r/  s      r'   rr   z!KnitPlainFactory.parse_line_deltaE  s    € Ý�D×.Ò.¨u°jÑAÔAÑBÔBÐBr&   c                 ó    — t          |¦  «        S )r\  )rÅ   r  s     r'   r^  z%KnitPlainFactory.get_fulltext_contentH  s   € å�E‰{Œ{Ðr&   c              #   óÌ   K  — t          |¦  «        }|D ]O}|                     d¦  «        }t          |d         ¦  «        }t          |¦  «        D ]}t	          |¦  «        V — ŒŒPdS )r`  rQ  r   Nra  )r/   r}   rZ  r#  r—   s        r'   rb  z&KnitPlainFactory.get_linedelta_contentL  s{   è è € õ �U‘”ˆØð 	"ð 	"ˆFØ—\’\ $Ñ'Ô'ˆFÝ˜˜qœ	‘N”NˆEÝ˜5‘\”\ð "ð "�Ý˜5‘k”kÐ!Ð!Ð!Ð!ð"ð	"ð 	"r&   c                 ó*   — |                      ¦   «         S r+   )r`   rg  s     r'   rh  zKnitPlainFactory.lower_fulltextY  s   € Ø�|Š|‰~Œ~Ðr&   c                 ó~   — g }|D ]7\  }}}}|                      d|||fz  ¦  «         |                     |¦  «         Œ8|S )Nrj  rl  rn  s          r'   rs   z!KnitPlainFactory.lower_line_delta\  sV   € ØˆØ$)ð 	ð 	Ñ ˆE�3˜˜5Ø�JŠJ�}¨¨s°A Ñ6Ñ7Ô7Ð7Ø�JŠJ�uÑÔÐÐØˆ
r&   c                 óJ   — t          |¦  «        }|                     |¦  «        S r+   )Ú_KnitAnnotatorÚannotate_flat)r/   r¦   r6   Ú	annotators       r'   r   zKnitPlainFactory.annotatec  s#   € Ý" 4Ñ(Ô(ˆ	Ø×&Ò& sÑ+Ô+Ð+r&   N)r!   r"   r#   rH   r¥   rB  r^   r~  rr   r^  rb  rh  rs   r   r%   r&   r'   rP   rP   +  s©   € € € € € Ø5Ð5à€Ið3ð 3ð 3ð.ð .ð .ðð ð ðCð Cð Cðð ð ð"ð "ð "ðð ð ðð ð ð,ð ,ð ,ð ,ð ,r&   rP   c                 ó   ‡ ‡— ˆ ˆfd„}|S )a  Create a factory for creating a file based KnitVersionedFiles.

    This is only functional enough to run interface tests, it doesn't try to
    provide a full pack environment.

    :param annotated: knit annotations are wanted.
    :param mapper: The mapper from keys to paths.
    c                 ót   •— t          | ‰d„ d„ d„ ¦  «        }t          | ‰¦  «        }t          ||‰¬¦  «        S )Nc                  ó   — d S r+   r%   r%   r&   r'   ú<lambda>z4make_file_factory.<locals>.factory.<locals>.<lambda>r  s   € °d€ r&   c                  ó   — dS ©NTr%   r%   r&   r'   r‹  z4make_file_factory.<locals>.factory.<locals>.<lambda>s  s   €  4€ r&   c                  ó   — dS r�  r%   r%   r&   r'   r‹  z4make_file_factory.<locals>.factory.<locals>.<lambda>s  s   € °€ r&   )r¥   )Ú
_KndxIndexÚ_KnitKeyAccessrL   )r	   r   Úaccessr¥   Úmappers      €€r'   rb   z"make_file_factory.<locals>.factoryq  sG   ø€ Ý˜9 f¨l¨lØ'˜<¨¨ñ7ô 7ˆå 	¨6Ñ2Ô2ˆÝ! %¨¸9ÐEÑEÔEÐEr&   r%   )r¥   r’  rb   s   `` r'   Úmake_file_factoryr“  h  s/   øø€ ðFð Fð Fð Fð Fð Fð
 €Nr&   c                 ó   ‡ ‡‡— ˆˆ ˆfd„}|S )a.  Create a factory for creating a pack based VersionedFiles.

    This is only functional enough to run interface tests, it doesn't try to
    provide a full pack environment.

    :param graph: Store a graph.
    :param delta: Delta compress contents.
    :param keylength: How long should keys be.
    c                 óÐ  •— ‰p‰
}d}‰r|dz  }‰
r|dz  }d}nd}t          j        |‰¬¦  «        }|                      d¦  «        }t                               |j        ¦  «        }|                     ¦   «          t          |d„ |‰
|j        ¬¦  «        }t           
                    i ¦  «        }|                     ||| df¦  «         t          |||¬¦  «        }	||	_        ||	_        |	S )	Nr   r   éÈ   )Úreference_listsÚkey_elementsÚnewpackc                  ó   — dS r�  r%   r%   r&   r'   r‹  z4make_pack_factory.<locals>.factory.<locals>.<lambda>’  s   € °T€ r&   )r…   ÚdeltasÚadd_callback)Úmax_delta_chain)Ú
_mod_indexÚInMemoryGraphIndexÚopen_write_streamÚpackÚContainerWriterÚwriteÚbeginÚ_KnitGraphIndexÚ	add_nodesÚ	pack_repoÚ_DirectPackAccessÚ
set_writerrL   ÚstreamÚwriter)r	   r…   Ú
ref_lengthr�  Úgraph_indexrª  r«  r   r‘  rY  rt   ÚgraphÚ	keylengths             €€€r'   rb   z"make_pack_factory.<locals>.factoryƒ  s  ø€ Ø�.˜5ˆØˆ
Øð 	Ø˜!‰OˆJØð 	 Ø˜!‰OˆJØ!ˆOˆOàˆOÝ Ô3ÀJØAJðLñ Lô Lˆà×,Ò,¨YÑ7Ô7ˆÝ×%Ò% f¤lÑ3Ô3ˆØ�Š‰ŒˆÝ ¨\¨\À7Ø',¸;Ô;PðRñ Rô Rˆå×,Ò,¨RÑ0Ô0ˆØ×Ò˜& +°	¸9Ð/EÑFÔFÐFÝ# E¨6Ø4CðEñ Eô EˆàˆŒØˆŒØˆr&   r%   )r®  rt   r¯  rb   s   ``` r'   Úmake_pack_factoryr°  y  s/   øøø€ ðð ð ð ð ð ð ð0 €Nr&   c                 ój   — | j                              ¦   «          | j                             ¦   «          d S r+   )rª  Úcloser«  r"  )Úversioned_filess    r'   Úcleanup_pack_knitr´  ž  s2   € ØÔ× Ò Ñ"Ô"Ð"ØÔ×ÒÑ Ô Ð Ð Ð r&   c                 óð   — i }|}|rFt          ¦   «         }|D ]1}||vrŒ||         \  }}}	|||<   |	|vr|                     |	¦  «         Œ2|}|°Ft          d„ |                     ¦   «         D ¦   «         ¦  «        S )a…  Determine the total bytes to build these keys.

    (helper function because _KnitGraphIndex and _KndxIndex work the same, but
    don't inherit from a common base.)

    :param keys: Keys that we want to build
    :param positions: dict of {key, (info, index_memo, comp_parent)} (such
        as returned by _get_components_positions)
    :return: Number of bytes to build those keys
    c              3   ó&   K  — | ]}|d          V — ŒdS )r   Nr%   )r²   Ú
index_memos     r'   r³   z(_get_total_build_size.<locals>.<genexpr>¼  sB   è è € ð Að AØð ˜!Œ}ð Að Að Að Að Að Ar&   )ÚsetÚaddÚsumÚvalues)
r/   ÚkeysÚ	positionsÚall_build_index_memosÚ
build_keysÚ	next_keysr6   r—   r·  rŒ   s
             r'   Ú_get_total_build_sizerÁ  £  sÎ   € ð ÐØ€JØ
ð Ý‘E”Eˆ	Øð 	2ð 	2ˆCð ˜)Ð#Ð#ØØ09¸#´Ñ-ˆAˆzÐ-Ø)3Ð! #Ñ&Ø!Ð)>Ð>Ð>Ø—’Ð0Ñ1Ô1Ð1øØˆ
ð ð õ ð Að AØ!6×!=Ò!=Ñ!?Ô!?ðAñ Aô Añ Aô Að Ar&   c                   óR  — e Zd ZdZ	 	 d0d„Zd„ Zd„ Zd„ Z	 	 	 d1d
„Z	 	 	 d2d„Z	d„ Z
d„ Zd„ Zd3d„Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd4d„Zi fd„Zd„ Zd„ Zd4d„Zd„ Zd4d„Zed„ ¦   «         Zefd„Zd„ Zd „ Z d!„ Z!d"„ Z"d#„ Z#d5d$„Z$d%„ Z%i dddfd&„Z&d'„ Z'd(„ Z(d)„ Z)d*„ Z*d+„ Z+d,„ Z,d5d-„Z-d.„ Z.d/„ Z/dS )6rL   a—  Storage for many versioned files using knit compression.

    Backend storage is managed by indices and data objects.

    :ivar _index: A _KnitGraphIndex or similar that can describe the
        parents, graph, compression and data location of entries in this
        KnitVersionedFiles.  Note that this is only the index for
        *this* vfs; if there are fallbacks they must be queried separately.
    r–  FNc                 óž   — || _         || _        || _        |rt          ¦   «         | _        nt          ¦   «         | _        g | _        || _        dS )a¢  Create a KnitVersionedFiles with index and data_access.

        :param index: The index for the knit data.
        :param data_access: The access object to store and retrieve knit
            records.
        :param max_delta_chain: The maximum number of deltas to permit during
            insertion. Set to 0 to prohibit the use of deltas.
        :param annotated: Set to True to cause annotations to be calculated and
            stored during insertion.
        :param reload_func: An function that can be called if we think we need
            to reload the pack listing and try again. See
            'breezy.bzr.pack_repo.AggregateIndex' for the signature.
        N)Ú_indexÚ_accessÚ_max_delta_chainrN   Ú_factoryrP   Ú_immediate_fallback_vfsÚ_reload_func)r/   r   Údata_accessr�  r¥   Úreload_funcs         r'   r,   zKnitVersionedFiles.__init__Ë  sT   € ð ˆŒØ"ˆŒØ /ˆÔØð 	/Ý/Ñ1Ô1ˆDŒMˆMå,Ñ.Ô.ˆDŒMØ')ˆÔ$Ø'ˆÔÐÐr&   c                 óX   — d                      | j        j        | j        | j        ¦  «        S )Nz{}({!r}, {!r}))r    Ú	__class__r!   rÄ  rÅ  rë   s    r'   Ú__repr__zKnitVersionedFiles.__repr__ä  s,   € Ø×&Ò&ØŒNÔ#ØŒKØŒLñô ð 	r&   c                 ód   — t          | j        | j        | j        | j        j        | j        ¦  «        S )z?Return a clone of this object without any fallbacks configured.)rL   rÄ  rÅ  rÆ  rÇ  r¥   rÉ  rë   s    r'   Úwithout_fallbacksz$KnitVersionedFiles.without_fallbacksê  s/   € å! $¤+¨t¬|Ø"&Ô"7¸¼Ô9PØ"&Ô"3ñ5ô 5ð 	5r&   c                 ó:   — | j                              |¦  «         dS )z~Add a source of texts for texts not present in this knit.

        :param a_versioned_files: A VersionedFiles object.
        N)rÈ  rX  )r/   Úa_versioned_filess     r'   Úadd_fallback_versioned_filesz/KnitVersionedFiles.add_fallback_versioned_filesð  s"   € ð
 	Ô$×+Ò+Ð,=Ñ>Ô>Ð>Ð>Ð>r&   Tc	           
      óÐ   — | j                              ¦   «          |                      ||||¦  «         |€d}d                     |¦  «        }	|                      ||||||||	¬¦  «        S )zSee VersionedFiles.add_lines().Nr%   r&   ©Ú
line_bytes)rÄ  Ú_check_write_okÚ
_check_addra   Ú_add)
r/   r6   r…   r}   Úparent_textsÚleft_matching_blocksÚnostore_shaÚ	random_idÚcheck_contentrÖ  s
             r'   Ú	add_lineszKnitVersionedFiles.add_lines÷  sy   € ð 	Œ×#Ò#Ñ%Ô%Ð%Ø�Š˜˜U I¨}Ñ=Ô=Ð=Øˆ?ð ˆGØ—X’X˜e‘_”_ˆ
Ø�yŠy˜˜e WØ%Ð';¸[È)Ø$.ð ñ 0ô 0ð 	0r&   c           
      ó  — | j                              ¦   «          |j        }|j        }|                      |d|d¬¦  «         |€d}|                     d¦  «        }|                     d¦  «        }	|                      ||||||||	¬¦  «        S )z!See VersionedFiles.add_content().NF)rÞ  r%   r}   rz   rÕ  )rÄ  r×  r6   r…   rØ  rˆ   rÙ  )
r/   Úcontent_factoryrÚ  rÛ  rÜ  rÝ  r6   r…   r}   rÖ  s
             r'   Úadd_contentzKnitVersionedFiles.add_content  s¢   € ð 	Œ×#Ò#Ñ%Ô%Ð%ØÔ!ˆØ!Ô)ˆØ�Š˜˜T 9¸EˆÑBÔBÐBØˆ?ð ˆGØ×,Ò,¨WÑ5Ô5ˆØ$×1Ò1°*Ñ=Ô=ˆ
Ø�yŠy˜˜e WØ%Ð';¸[È)Ø$.ð ñ 0ô 0ð 	0r&   c	                 ó   — t          |¦  «        }	||	k    rt          ‚g }
|€i }| j                             |¦  «        }|D ]}||v r|
                     |¦  «         Œt          |
¦  «        dk    s|
d         |d         k    rd}n|                      |
d         ¦  «        }t          |¦  «        }g }d}|r[|                     d¦  «        sF|                     d¦  «         d}|€t          j	        |¦  «        }n
|dd…         }|d         dz   |d<   |€t          j	        |¦  «        }|dd…         D ]9}t          |t          ¦  «        s"t          d                     |¦  «        ¦  «        ‚Œ:|d         €|dd…         d	|	z   fz   }n=t          |d         t          ¦  «        s"t          d                     |¦  «        ¦  «        ‚|d         }| j                             ||¦  «        }|rd|_        |s| j        j        r7t          |
¦  «        dk    r$|                      ||
||| j        j        |¦  «        }|rJ|                     d
¦  «         | j                             |¦  «        }|                      ||	|¦  «        \  }}n’|                     d¦  «         | j        j        t,          u r6|g}|r|                     d¦  «         |                      ||	||¦  «        \  }}n4| j                             |¦  «        }|                      ||	|¦  «        \  }}| j                             |||¦  «        }| j                             ||||ff|¬¦  «         |	||fS )a¶  Add a set of lines on top of version specified by parents.

        Any versions not present will be converted into ghosts.

        :param lines: A list of strings where each one is a single line (has a
            single newline at the end of the string) This is now optional
            (callers can pass None). It is left in its location for backwards
            compatibility. It should ''.join(lines) must == line_bytes
        :param line_bytes: A single string containing the content

        We pass both lines and line_bytes because different routes bring the
        values to this function. And for memory efficiency, we don't want to
        have to split/join on-demand.
        Nr   FrÚ   ó   no-eolTry   z"key contains non-bytestrings: {!r}s   sha1:ó
   line-deltaó   fulltext)rÝ  )r   r   rÄ  Úget_parent_maprX  r  Ú_check_should_deltaÚendswithr   r   rt  rÖ   Ú	TypeErrorr    rÇ  rB  r‹   r¥   Ú_merge_annotationsrs   r_   rÍ  rP   rh  rÅ  Úadd_raw_recordÚadd_records)r/   r6   r}   r…   rÚ  rÛ  rÜ  rÝ  rÖ  ÚdigestÚpresent_parentsÚpresent_parent_mapÚparentrt   Útext_lengthrG   Úno_eolÚelementr0  r7   Údelta_hunksÚstore_linesrg   ÚdataÚdense_linesÚaccess_memos                             r'   rÙ  zKnitVersionedFiles._add  sÎ  € õ& ˜JÑ'Ô'ˆØ˜&Ò Ð Ý!Ð!àˆØÐØˆLð "œ[×7Ò7¸Ñ@Ô@ÐØð 	/ð 	/ˆFØÐ+Ð+Ð+Ø×&Ò& vÑ.Ô.Ð.øõ �Ñ Ô  AÒ%Ð%Ø" 1Ô%¨°¬Ò3Ð3ØˆEˆEð
 ×,Ò,¨_¸QÔ-?Ñ@Ô@ˆEå˜*‘o”oˆØˆØˆð ð 		*˜j×1Ò1°%Ñ8Ô8ð 		*Ø�NŠN˜9Ñ%Ô%Ð%ØˆFàˆ}ÝÔ+¨JÑ7Ô7��à˜a˜a˜aœ�à˜bœ	 EÑ)ˆE�"‰IØˆ=ÝÔ'¨
Ñ3Ô3ˆEà˜3˜B˜3”xð 	Rð 	RˆGÝ˜g¥uÑ-Ô-ð RÝÐ D× KÒ KÈCÑ PÔ PÑQÔQÐQðRàˆrŒ7ˆ?Ø�c�r�c”(˜h¨Ñ/Ð1Ñ1ˆCˆCÝ˜C œG¥UÑ+Ô+ð 	NÝÐ@×GÒGÈÑLÔLÑMÔMÐMà˜”Wˆ
Ø”-×$Ò$ U¨JÑ7Ô7ˆØð 	-ð )-ˆGÔ%Øð 	H�T”]Ô,ð 	Hµ°_Ñ1EÔ1EÈÒ1IÐ1Ià×1Ò1°'¸?Ø2>ÀÀtÄ}ÔG^Ø2FñHô HˆKð ð 	LØ�NŠN˜=Ñ)Ô)Ð)Øœ-×8Ò8¸ÑEÔEˆKØ×-Ò-¨c°6¸;ÑGÔG‰JˆD�$�$à�NŠN˜;Ñ'Ô'Ð'àŒ}Ô&Õ*:Ð:Ð:ð  *˜l�Øð .Ø×&Ò& uÑ-Ô-Ð-Ø!×1Ò1°#°vØ27¸ñFô F‘
��d�dð
 #œm×:Ò:¸7ÑCÔC�Ø!×1Ò1°#°v¸{ÑKÔK‘
��dà”l×1Ò1°#°t¸TÑBÔBˆØŒ×ÒØ�7˜K¨Ð1Ð3Øð 	 ñ 	!ô 	!ð 	!ð �{ GÐ+Ð+r&   c                 ó8   — | j                              | |¦  «        S )zSee VersionedFiles.annotate.)rÇ  r   ©r/   r6   s     r'   r   zKnitVersionedFiles.annotate‡  s   € àŒ}×%Ò% d¨CÑ0Ô0Ð0r&   c                 ó    — t          | ¦  «        S r+   )r…  rë   s    r'   Úget_annotatorz KnitVersionedFiles.get_annotator‹  s   € Ý˜dÑ#Ô#Ð#r&   c                 ó\   — |€|                       ¦   «         S |                      |dd¦  «        S )zSee VersionedFiles.check().Nrƒ   T)Ú_logical_checkr‡   )r/   Úprogress_barr¼  s      r'   ÚcheckzKnitVersionedFiles.checkŽ  s3   € àˆ<Ø×&Ò&Ñ(Ô(Ð(ð ×)Ò)¨$°¸TÑBÔBÐBr&   c                 óP  — | j                              ¦   «         }|                      |¦  «        }|D ]V}| j                              |¦  «        dk    r6||         d         }||vr$t	          | d                     ||¦  «        ¦  «        ‚ŒW| j        D ]}|                     ¦   «          Œd S )Nrz   r   zMissing basis parent {} for {})rÄ  r¼  rç  Ú
get_methodr)   r    rÈ  r  )r/   r¼  Ú
parent_mapr6   rŒ   Úfallback_vfss         r'   rÿ  z!KnitVersionedFiles._logical_check–  sÕ   € ð
 Œ{×ÒÑ!Ô!ˆØ×(Ò(¨Ñ.Ô.ˆ
Øð 	Dð 	DˆCØŒ{×%Ò% cÑ*Ô*¨jÒ8Ð8Ø%/°¤_°QÔ%7Ð"Ø%¨ZÐ7Ð7Ý% dØ&F×&MÒ&MØ*<¸cñ'Cô 'CñDô Dð Døð !Ô8ð 	!ð 	!ˆLØ×ÒÑ Ô Ð Ð ð	!ð 	!r&   c                 ó.  — t          d„ |D ¦   «         ¦  «        st          |¦  «        ‚|d         }|�4t          |¦  «        rt          || ¦  «        ‚|                      |¦  «         |r,|                      |¦  «         |                      |¦  «         dS dS )z0check that version_id and lines are safe to add.c              3   óH   K  — | ]}t          |t          ¦  «        p|d u V — Œd S r+   ©rt  rÖ   )r²   Úxs     r'   r³   z0KnitVersionedFiles._check_add.<locals>.<genexpr>©  s5   è è € ÐBÐB¸•:˜a¥Ñ'Ô'Ð4¨1°¨9ÐBÐBÐBÐBÐBÐBr&   ry   N)Úallrê  r   r   Úcheck_not_reserved_idÚ_check_lines_not_unicodeÚ_check_lines_are_lines)r/   r6   r}   rÝ  rÞ  r0  s         r'   rØ  zKnitVersionedFiles._check_add§  s²   € åÐBÐB¸cÐBÑBÔBÑBÔBð 	!Ý˜C‘.”.Ð Ø˜”Wˆ
ØÐ!Ý" :Ñ.Ô.ð :Ý'¨
°DÑ9Ô9Ð9Ø×&Ò& zÑ2Ô2Ð2ð
 ð 	/Ø×)Ò)¨%Ñ0Ô0Ð0Ø×'Ò'¨Ñ.Ô.Ð.Ð.Ð.ð	/ð 	/r&   c                 óh   — |                       |¦  «        }|                      ||d         ¦  «         |S rr  )Ú_split_headerÚ_check_header_version)r/   r6   r3  re   s       r'   Ú_check_headerz KnitVersionedFiles._check_header¸  s4   € Ø× Ò  Ñ&Ô&ˆØ×"Ò" 3¨¨B¬Ñ0Ô0Ð0Øˆ
r&   c                 ór   — |d         |k    r*t          | d                     ||d         ¦  «        ¦  «        ‚dS )z�Checks the header version on original format knit records.

        These have the last component of the key embedded in the record.
        r   z)unexpected version, wanted {!r}, got {!r}N)r)   r    )r/   re   r0  s      r'   r  z(KnitVersionedFiles._check_header_version½  sM   € ð
 ˆqŒ6�ZÒÐÝ˜dØI×PÒPÐQ[Ð]`ÐabÔ]cÑdÔdñfô fð fð  Ðr&   c                 ó  — d}d}t          | j        ¦  «        D ]a}	 | j                             |g¦  «        }||         }n # t          t
          f$ r}Y d}~ dS d}~ww xY w|\  }}	}
}
|\  }
}
}|	€|} n
||z  }|	}ŒbdS ||k    S )aß  Iterate back through the parent listing, looking for a fulltext.

        This is used when we want to decide whether to add a delta or a new
        fulltext. It searches for _max_delta_chain parents. When it finds a
        fulltext parent, it sees if the total size of the deltas leading up to
        it is large enough to indicate that we want a new full text anyway.

        Return True if we should create a new delta, False if we should use a
        full text.
        r   NF)rW  rÆ  rÄ  Úget_build_detailsr   ÚKeyError)r/   rñ  Ú
delta_sizeÚfulltext_sizer#  r£   Úparent_detailsr)  r·  rŒ   r—   rg   s               r'   rè  z&KnitVersionedFiles._check_should_deltaÆ  sÙ   € ð ˆ
ØˆÝ˜4Ô0Ñ1Ô1ð 	ð 	ˆEð	ð
 !%¤× =Ò =¸v¸hÑ GÔ G�Ø!.¨vÔ!6��øÝ&­Ð1ð ð ð à�u�u�u�u�u�uøøøøðøøøð 4BÑ0ˆJÐ*¨A¨qØ#‰JˆAˆq�$Ø!Ð)Ø $�Ø�Ø˜$ÑˆJð (ˆFˆFð �5ð ˜zÒ)Ð)s   œ#A Á AÁAc                 ó0   — |d         |d         |d         fS )z2Convert a build_details tuple to a position tuple.rZ   r   r   r%   )r/   r£   s     r'   Ú_build_details_to_componentsz/KnitVersionedFiles._build_details_to_componentsî  s    € ð ˜QÔ ¨qÔ!1°=ÀÔ3CÐCÐCr&   c                 ó¤  — i }|}|rÉ| j                              |¦  «        }t          |¦  «        }t          ¦   «         }|                     ¦   «         D ];\  }}|\  }	}
}}|
�|                     |
¦  «         |                      |¦  «        ||<   Œ<|                     |¦  «        }|r)|s't          j        | 	                    ¦   «         | ¦  «        ‚|°É|S )a‰  Produce a map of position data for the components of keys.

        This data is intended to be used for retrieving the knit records.

        A dict of key to (record_details, index_memo, next, parents) is
        returned.

        * method is the way referenced data should be applied.
        * index_memo is the handle to pass to the data access to actually get
          the data
        * next is the build-parent of the version, or None for fulltexts.
        * parents is the version_ids of the parents of this version

        :param allow_missing: If True do not raise an error on a missing
            component, just ignore it.
        )
rÄ  r  r¸  Úitemsr¹  r  Ú
differencer   r   Úpop)r/   r¼  Úallow_missingÚcomponent_dataÚpending_componentsr£   Úcurrent_componentsr6   Údetailsr·  rŒ   r…   r;  Úmissings                 r'   Ú_get_components_positionsz,KnitVersionedFiles._get_components_positionsó  s  € ð" ˆØ!ÐØ ð 	EØ œK×9Ò9Ð:LÑMÔMˆMÝ!$Ð%7Ñ!8Ô!8ÐÝ!$¡¤ÐØ -× 3Ò 3Ñ 5Ô 5ð ð ‘��Wà#*ñ!�Ð/°ØØ%Ð1Ø&×*Ò*Ð+=Ñ>Ô>Ð>Ø&*×&GÒ&GØñ'ô '�˜sÑ#Ð#à(×3Ò3°MÑBÔBˆGØð E˜}ð EÝÔ/°·²±´¸tÑDÔDÐDð !ð 	Eð Ðr&   c                 óÎ   — |                      |d¦  «        }|�(|                      |g¦  «        st          || ¦  «        ‚|S t          | |g¦  «        }|                     |¦  «        S )zEReturns a content object that makes up the specified
        version.N)r¾   rç  r   Ú_VFContentMapGeneratorrs  )r/   r6   rÚ  Úcached_versionrÍ   s        r'   rs  zKnitVersionedFiles._get_content  sr   € ð &×)Ò)¨#¨tÑ4Ô4ˆØÐ%à×&Ò&¨ uÑ-Ô-ð 4Ý(¨¨dÑ3Ô3Ð3Ø!Ð!Ý*¨4°#°Ñ7Ô7ˆ	Ø×%Ò% cÑ*Ô*Ð*r&   c                 ó8   — |                       |¦  «        d         S )zÍGet a map of the graph parents of keys.

        :param keys: The keys to look up parents for.
        :return: A mapping from keys to parents. Absent keys are absent from
            the mapping.
        r   )Ú_get_parent_map_with_sources©r/   r¼  s     r'   rç  z!KnitVersionedFiles.get_parent_map"  s   € ð ×0Ò0°Ñ6Ô6°qÔ9Ð9r&   c                 ó$  — i }| j         g| j        z   }g }t          |¦  «        }|D ]g}|s nb|                     |¦  «        }|                     |¦  «         |                     |¦  «         |                     t          |¦  «        ¦  «         Œh||fS )a°  Get a map of the parents of keys.

        :param keys: The keys to look up parents for.
        :return: A tuple. The first element is a mapping from keys to parents.
            Absent keys are absent from the mapping. The second element is a
            list with the locations each key was found in. The first element
            is the in-this-knit parents, the second the first fallback source,
            and so on.
        )rÄ  rÈ  r¸  rç  rX  ÚupdateÚdifference_update)r/   r¼  rY  ÚsourcesÚsource_resultsr$  r  Ú
new_results           r'   r*  z/KnitVersionedFiles._get_parent_map_with_sources+  s§   € ð ˆØ”;�- $Ô">Ñ>ˆØˆÝ�d‘)”)ˆØð 	7ð 	7ˆFØð Ø�Ø×.Ò.¨wÑ7Ô7ˆJØ×!Ò! *Ñ-Ô-Ð-Ø�MŠM˜*Ñ%Ô%Ð%Ø×%Ò%¥c¨*¡o¤oÑ6Ô6Ð6Ð6Ø�~Ð%Ð%r&   c                 óZ   — |                       ||¬¦  «        }|                      |¦  «        S )a‘  Produce a dictionary of knit records.

        :return: {key:(record, record_details, digest, next)}

            * record: data returned from read_records (a KnitContentobject)
            * record_details: opaque information to pass to parse_record
            * digest: SHA1 digest of the full text after all steps are done
            * next: build-parent of the version, i.e. the leftmost ancestor.
                Will be None if the record is not a delta.

        :param keys: The keys to build a map for
        :param allow_missing: If some records are missing, rather than
            error, just return the data that could be generated.
        ©r  )Ú_get_record_map_unparsedÚ_raw_map_to_record_map)r/   r¼  r  Úraw_maps       r'   Ú_get_record_mapz"KnitVersionedFiles._get_record_mapB  s9   € ð ×/Ò/°Ø>Kð 0ñ Mô Mˆà×*Ò*¨7Ñ3Ô3Ð3r&   c                 ó|   — i }|D ]6}||         \  }}}|                       |d         |¦  «        \  }}||||f||<   Œ7|S )z_Parse the contents of _get_record_map_unparsed.

        :return: see _get_record_map.
        ry   )Ú_parse_record)	r/   r6  rY  r6   r÷  r;  r†   r7   rî  s	            r'   r5  z)KnitVersionedFiles._raw_map_to_record_mapU  s`   € ð
 ˆØð 	@ð 	@ˆCØ)0°¬Ñ&ˆD�. $Ø"×0Ò0°°R´¸$Ñ?Ô?‰OˆG�VØ! >°6¸4Ð?ˆF�3‰KˆKØˆr&   c                 ó”  — 	 	 |                       ||¬¦  «        }d„ |                     ¦   «         D ¦   «         }|                     t          j        d¦  «        ¬¦  «         i }|                      |¦  «        D ]\  }}||         \  }}	}
|||
f||<   Œ|S # t          j        $ r$}| j         	                    |¦  «         Y d}~nd}~ww xY wŒÈ)zÐGet the raw data for reconstructing keys without parsing it.

        :return: A dict suitable for parsing via _raw_map_to_record_map.
            key-> raw_bytes, (method, noeol), compression_parent
        Tr3  c                 ó$   — g | ]\  }\  }}}||f‘ŒS r%   r%   )r²   r6   ÚrÚi_mr  s        r'   râ   z?KnitVersionedFiles._get_record_map_unparsed.<locals>.<listcomp>t  s3   € ð 4ð 4ð 4Ñ*:¨#©{°°3¸˜C ˜:ð 4ð 4ð 4r&   r   ©r6   N)
r%  r  ÚsortÚoperatorÚ
itemgetterÚ_read_records_iter_uncheckedr§  ÚRetryWithNewPacksrÅ  Úreload_or_raise)r/   r¼  r  Úposition_mapÚrecordsÚraw_record_mapr6   r÷  r;  r·  r†   r)  s               r'   r4  z+KnitVersionedFiles._get_record_map_unparseda  s  € ð	0ð0Ø#×=Ò=¸dØLYð  >ñ  [ô  [�ð4ð 4Ø*×0Ò0Ñ2Ô2ð4ñ 4ô 4�ð —’¥Ô!4°QÑ!7Ô!7�Ñ8Ô8Ð8Ø!#�Ø!%×!BÒ!BÀ7Ñ!KÔ!Kð Eð E‘I�C˜Ø9EÀcÔ9JÑ6�^ Z°Ø*.°ÀÐ*D�N 3Ñ'Ð'Ø%Ð%øÝÔ.ð 0ð 0ð 0Ø”×,Ò,¨QÑ/Ô/Ð/Ð/Ð/Ð/Ð/Ð/øøøøð0øøøð!	0s   ƒBB ÂCÂ"CÃCc                 óÎ   — i }g }|D ][}t          |¦  «        dk    rd}n|d         }||v r||                              |¦  «         Œ@|g||<   |                     |¦  «         Œ\||fS )a  For the given keys, split them up based on their prefix.

        To keep memory pressure somewhat under control, split the
        requests back into per-file-id requests, otherwise "bzr co"
        extracts the full tree into memory before writing it to disk.
        This should be revisited if _get_content_maps() can ever cross
        file-id boundaries.

        The keys for a given file_id are kept in the same relative order.
        Ordering between file_ids is not, though prefix_order will return the
        order that the key was first seen.

        :param keys: An iterable of key tuples
        :return: (split_map, prefix_order)
            split_map       A dictionary mapping prefix => keys
            prefix_order    The order that we saw the various prefixes
        r   r&   r   )r  rX  )Úclsr¼  Úsplit_by_prefixÚprefix_orderr6   ru  s         r'   Ú_split_by_prefixz#KnitVersionedFiles._split_by_prefix�  s‘   € ð& ˆØˆØð 
	,ð 
	,ˆCÝ�3‰xŒx˜1Š}ˆ}Ø��à˜Qœ�à˜Ð(Ð(Ø Ô'×.Ò.¨sÑ3Ô3Ð3Ð3à+.¨%� Ñ'Ø×#Ò# FÑ+Ô+Ð+Ð+Ø Ð,Ð,r&   c                 ón  — t          |¦  «        }|                      |¦  «        \  }}|                      |¦  «        \  }}	g }
t          ¦   «         }d}g }g }|D ]®}||         }|                     |g ¦  «        }| j                             ||¦  «        }||z  }|
                     |¦  «         |                     |¦  «         ||k    r>|                     |
|f¦  «         |                     |¦  «         g }
t          ¦   «         }d}Œ¯|
r,|                     |
|f¦  «         |                     |¦  «         |S )a   For the given keys, group them into 'best-sized' requests.

        The idea is to avoid making 1 request per file, but to never try to
        unpack an entire 1.5GB source tree in a single pass. Also when
        possible, we should try to group requests to the same pack file
        together.

        :return: list of (keys, non_local) tuples that indicate what keys
            should be fetched next.
        r   )	r  rL  r¸  r¾   rÄ  rÁ  rm  r-  rX  )r/   r¼  Únon_local_keysr½  Ú_min_buffer_sizeÚ
total_keysÚprefix_split_keysrK  Úprefix_split_non_local_keysr—   Úcur_keysÚcur_non_localÚcur_sizerY  Úsizesru  Ú	non_localÚ	this_sizes                     r'   Ú_group_keys_for_ioz%KnitVersionedFiles._group_keys_for_io£  sR  € õ  ˜‘Y”Yˆ
Ø*.×*?Ò*?ÀÑ*EÔ*EÑ'Ð˜<Ø)-×)>Ò)>¸~Ñ)NÔ)NÑ&Ð# QØˆÝ™œˆØˆØˆØˆØ"ð 	ð 	ˆFØ$ VÔ,ˆDØ3×7Ò7¸ÀÑCÔCˆIàœ×9Ò9¸$À	ÑJÔJˆIØ˜	Ñ!ˆHØ�OŠO˜DÑ!Ô!Ð!Ø× Ò  Ñ+Ô+Ð+ØÐ*Ò*Ð*Ø—’˜x¨Ð7Ñ8Ô8Ð8Ø—’˜XÑ&Ô&Ð&Ø�Ý #¡¤�Ø�øØð 	#Ø�MŠM˜8 ]Ð3Ñ4Ô4Ð4Ø�LŠL˜Ñ"Ô"Ð"Øˆr&   c              #   óP  K  — t          |¦  «        }|sdS | j        j        sd}|}	 	 t          |¦  «        }|                      |||¦  «        D ] }|                     |j        ¦  «         |V — Œ!dS # t          j        $ r$}| j         	                    |¦  «         Y d}~nd}~ww xY wŒ�)a  Get a stream of records for keys.

        :param keys: The keys to include.
        :param ordering: Either 'unordered' or 'topological'. A topologically
            sorted stream has compression parents strictly before their
            children.
        :param include_delta_closure: If True then the closure across any
            compression parents will be included (in the opaque data).
        :return: An iterator of ContentFactory objects, each of which is only
            valid until the iterator is advanced.
        Nrƒ   )
r¸  rÄ  Ú	has_graphÚ_get_remaining_record_streamÚdiscardr6   r§  rC  rÅ  rD  )r/   r¼  ÚorderingÚinclude_delta_closureÚremaining_keysrá  r)  s          r'   r‡   z$KnitVersionedFiles.get_record_streamÎ  sî   è è € õ �4‰yŒyˆØð 	ØˆFØŒ{Ô$ð 	#à"ˆHàˆð		0ð0Ý˜>Ñ*Ô*�Ø'+×'HÒ'HÈØIQÐShñ(jô (jð *ð *�Oà"×*Ò*¨?Ô+>Ñ?Ô?Ð?Ø)Ð)Ð)Ð)Ð)Ø�øÝÔ.ð 0ð 0ð 0Ø”×,Ò,¨QÑ/Ô/Ð/Ð/Ð/Ð/Ð/Ð/øøøøð0øøøð		0s   ¨AA1 Á1B$Â BÂB$c              #   óÜ  ‡ ‡K  — |r‰                       |d¬¦  «        Šn:‰ j                             |¦  «        }ˆ fd„|                     ¦   «         D ¦   «         Š|                     t          ‰¦  «        ¦  «        }|röt          ¦   «         }i }|D ]ã}	 |‰|         d         g}	n%# t          $ r |                     |¦  «         Y Œ5w xY wd}
|	d         �w|	d         |v r||	d                  }
n^	 |	                     ‰|	d                  d         ¦  «         n-# t          $ r  |                     |	d         ¦  «         d}
Y nw xY w|	d         ­w|	dd…         D ]}|
||<   Œ|
s|                     |¦  «         Œä‰  	                    |¦  «        \  }}|dv r…|dk    rt                               |¦  «        }nt          |¦  «        }g }d}|D ]M}|D ]
}||v r|} nŒ||ur|                     |g f¦  «         |}|d         d	                              |¦  «         ŒNn­|d
k    rt          d|›�¦  «        ‚g }g }t          |¦  «        D ]T}|                     |g f¦  «         |D ]8}|                     |¦  «         |d         d	                              |¦  «         Œ9ŒU|D ]*\  }}||d         u r‰ j                             |‰¦  «         Œ+|t          |¦  «        z
  }|D ]}t!          |¦  «        V — Œ|rR||z
  }‰                      ||‰¦  «        D ]3\  }}t%          ‰ ||||¬¦  «        }|                     ¦   «         E d{V —† Œ4dS |D ]¬\  }}||d         u r]ˆfd„|D ¦   «         }‰                      |¦  «        D ]8\  }}‰|         \  }}}t+          |||         |d|‰ j        j        d¦  «        V — Œ9Œl‰ j        |                     |¦  «        d	z
           }|                     |||¦  «        E d{V —† Œ­dS )z;This function is the 'retry' portion for get_record_stream.Tr3  c                 óB   •— i | ]\  }}|‰                      |¦  «        “ŒS r%   )r  )r²   r6   r#  r/   s      €r'   ú
<dictcomp>zCKnitVersionedFiles._get_remaining_record_stream.<locals>.<dictcomp>ø  sC   ø€ ð Hð Hð HÙ!-  gð ˜d×?Ò?ÀÑHÔHð Hð Hð Hr&   r   ry   N)ÚtopologicalÚgroupcompressrd  r   rƒ   zRvalid values for ordering are: "unordered", "groupcompress" or "topological" not: r   ©r^  c                 ó0   •— g | ]}|‰|         d          f‘ŒS ©r   r%   )r²   r6   r½  s     €r'   râ   zCKnitVersionedFiles._get_remaining_record_stream.<locals>.<listcomp>Z  s'   ø€ ÐHÐHÐH¸C  Y¨s¤^°AÔ%6Ð7ÐHÐHÐHr&   )r%  rÄ  r  r  r  r¸  r  r¹  rX  r*  ÚtsortÚ	topo_sortr   ÚAssertionErrorÚreversedÚ_sort_keys_by_ior   rY  r'  r‡   rB  r™   rÇ  r¥   rÈ  r   )r/   r¼  r^  r_  r£   Úabsent_keysÚneeded_from_fallbackÚreconstructable_keysr6   ÚchainrY  Ú	chain_keyÚ
global_mapÚparent_mapsÚpresent_keysÚsource_keysÚcurrent_sourcer  Ú
key_sourcer  Úsub_keysrN  rÍ   rF  Úraw_datar;  r·  r—   Úvfr½  s   `                            @r'   r\  z/KnitVersionedFiles._get_remaining_record_streamî  sÞ  øøè è € ð !ð 	HØ×6Ò6Ø Dð 7ñ *ô *ˆIˆIð !œK×9Ò9¸$Ñ?Ô?ˆMðHð Hð Hð HØ1>×1DÒ1DÑ1FÔ1FðHñ Hô HˆIà—o’o¥c¨)¡n¤nÑ5Ô5ˆð
 !ð 	2Ý#&¡5¤5Ð ð $&Ð Øð 2ð 2�ðØ  )¨C¤.°Ô"3Ð4�E�EøÝð ð ð Ø(×,Ò,¨SÑ1Ô1Ð1Ø�Hðøøøð �Ø˜B”iÐ+Ø˜R”yÐ$8Ð8Ð8Ø!5°e¸B´iÔ!@˜Øð"Ø!ŸLšL¨°5¸´9Ô)=¸aÔ)@ÑAÔAÐAÐAøÝ'ð "ð "ð "à0×4Ò4°U¸2´YÑ?Ô?Ð?Ø%)˜FØ!˜Eð	"øøøð ˜B”iÐ+ð "' s¨ s¤ð =ð =�IØ6<Ð(¨Ñ3Ð3Øð 2Ø(×,Ò,¨SÑ1Ô1Ð1øà"&×"CÒ"CÀDÑ"IÔ"IÑˆ
�KØÐ7Ð7Ð7Ø˜=Ò(Ð(å$Ÿš¨zÑ:Ô:��å1°*Ñ=Ô=�àˆKØ!ˆNØ#ð /ð /�Ø"-ð ð �JØ˜jÐ(Ð(Ø%/˜
Ø˜ð )ð "¨Ð3Ð3Ø×&Ò&¨
°BÐ'7Ñ8Ô8Ð8Ø%/�NØ˜B” Ô"×)Ò)¨#Ñ.Ô.Ð.Ð.ð/ð ˜;Ò&Ð&Ý$�nà(0¨ð&3ñ 4ô 4ð 4ð ˆLØˆKÝ& {Ñ3Ô3ð 3ð 3�
Ø×"Ò" J°Ð#3Ñ4Ô4Ð4Ø%ð 3ð 3�CØ ×'Ò'¨Ñ,Ô,Ð,Ø ”O AÔ&×-Ò-¨cÑ2Ô2Ð2Ð2ð3ð %0ð Fð FÑ �˜Ø˜[¨œ^Ð+Ð+à”K×0Ò0°¸9ÑEÔEÐEøØ�S ™_œ_Ñ,ˆØð 	,ð 	,ˆCÝ& sÑ+Ô+Ð+Ð+Ð+Ð+ð
 !ð 	Nð 2°KÑ?ˆNØ(,×(?Ò(?ÀØ@NØ@Iñ)Kô )Kð 9ð 9Ñ$��nõ 3°4¸¸~Ø3=Ø<DðFñ Fô F�	ð %×6Ò6Ñ8Ô8Ð8Ð8Ð8Ð8Ð8Ð8Ð8Ð8ð9ð 9ð !,ð Nð N‘�˜Ø˜[¨œ^Ð+Ð+àHÐHÐHÐHÀ4ÐHÑHÔH�GØ)-×)JÒ)JÈ7Ñ)SÔ)Sð pð p™˜˜XØ:CÀC¼.Ñ7˜¨°QÝ0°°jÀ´oØ1?ÀÀxÐQUÔQ^ÔQhÐjnñpô pð pð pð pð pðpð
 Ô5°k×6GÒ6GØñ7 ô 7 Ø"#ñ7$ô %�Bà!×3Ò3°D¸(Ø7Lñ Nô  Nð Nð Nð Nð Nð Nð Nð Nð NðNð Ns$   ÂB#Â#CÃCÃ,'DÄ'D>Ä=D>c                 ó¢  — t          |¦  «        }|                      |d¬¦  «        }i }|                     ¦   «         D ]\  }}||vrŒ
|d         ||<   Œ|                     t          |¦  «        ¦  «         | j        D ]R}|s nM|                     |¦  «        }|                     |¦  «         |                     t          |¦  «        ¦  «         ŒS|S )zSee VersionedFiles.get_sha1s().Tr3  r   )r¸  r7  r  r.  rÈ  Ú	get_sha1sr-  )	r/   r¼  r$  Ú
record_maprY  r6   r#  r  r1  s	            r'   r}  zKnitVersionedFiles.get_sha1se  sæ   € å�d‘)”)ˆØ×)Ò)¨'ÀÐ)ÑFÔFˆ
ØˆØ&×,Ò,Ñ.Ô.ð 	%ð 	%‰LˆC�Ø˜'Ð!Ð!Øà! !œ*ˆF�3‰KˆKØ×!Ò!¥# f¡+¤+Ñ.Ô.Ð.ØÔ2ð 	7ð 	7ˆFØð Ø�Ø×)Ò)¨'Ñ2Ô2ˆJØ�MŠM˜*Ñ%Ô%Ð%Ø×%Ò%¥c¨*¡o¤oÑ6Ô6Ð6Ð6Øˆr&   c                 óÎ  ‡ ‡— ˆˆ fd„}t          ¦   «         }‰ j        j        rd}g }n6d}dh}‰ j        r*|                     d¦  «         |                     d¦  «         t          ¦   «         }‰ j        r0|                     d|z  ¦  «         |                     d|z  ¦  «         |                     d|z  ¦  «         |                     |¦  «        }i Ši }|D �]I}	|	j        }
|
                     d¦  «        rN|
                     d	¦  «        r9|	j	        }‰  
                    |	j        |¦  «        \  }}|                     ¦   «          d
}|	j        }|	j        |v r	|d         }nd}|	j        dk    rt          |	j        g‰ ¦  «        ‚|	j        |v �rS|�‰ j        r|‰ j        v s|‰ v�r<|	j        |vrW	 |	j        df} ||¦  «        }n$# t"          $ r |	j        df} ||¦  «        }Y nw xY w|                     |	|d         ¦  «        }n|	j	        }|	j        d                              d¦  «        g}|	j        d         r|                     d¦  «         ‰ j                             |	j        t1          |¦  «        |g¦  «        }|	j        |||f}d|vr6|‰ j        vr-|                     |g ¦  «        }|                     |¦  «         d}|s‰ j                             |g¦  «         nÖ|	j        dv r0‰                      |	j        ||	                     d¦  «        ¦  «         n�‰ j                             ¦   «          	 |	                     d¦  «        }n:# t<          $ r- |	j        df} ||¦  «        }|                     |	d¦  «        }Y nw xY w	 ‰                      |	j        ||¦  «         n# t>          j         $ r Y nw xY w|si|	j        g}|r_| !                    d¦  «        }||v rD||         }‰ j                             |¦  «         | "                    d„ |D ¦   «         ¦  «         ||= |°_�ŒK|rBg }|D ]}||         }| "                    |¦  «         Œ ‰ j                             |d¬¦  «         dS dS )z´Insert a record stream into this container.

        :param stream: A stream of records to insert.
        :return: None
        :seealso VersionedFiles.get_record_stream:
        c                 ó‚   •— 	 ‰|          S # t           $ r) t          j        | ¦  «        } |‰¦  «        }|‰| <   |cY S w xY wr+   )r  r   r¾   )rÁ   rÂ   rÃ   Úadaptersr/   s      €€r'   Úget_adapterz<KnitVersionedFiles.insert_record_stream.<locals>.get_adapter  s`   ø€ ðØ Ô,Ð,øÝð ð ð Ý"2Ô"6°{Ñ"CÔ"C�Ø)˜/¨$Ñ/Ô/�Ø(/�˜Ñ%Ø���ð	øøøs   ƒ ‹0>½>r�   rž   zknit-annotated-ft-gzzknit-annotated-delta-gzzknit-%sdelta-gzzknit-%sft-gzzknit-z-gzFr   Nr„   ro   rY   r   r¶   rä  ræ  T)r|   Úfiler}   c                 ó   — g | ]
}|d          ‘ŒS )r   r%   )r²   Úindex_entrys     r'   râ   z;KnitVersionedFiles.insert_record_stream.<locals>.<listcomp>  s   € ÐMÐMÐM°˜[¨œ^ÐMÐMÐMr&   )Úmissing_compression_parents)#r¸  rÇ  r¥   rÆ  r¹  Úunionr[   Ú
startswithré  r\   Ú_parse_record_headerr6   r²  r…   r   rÈ  rÄ  r  ri   r   r·   rX  rÅ  rì  r  rI  rí  rß  rˆ   Úflushr   r   ÚRevisionAlreadyPresentr  rm  )r/   rª  r‚  Údelta_typesr¥   ÚconvertiblesÚnative_typesÚ
knit_typesÚbuffered_index_entriesr:  r¨   rz  Údfre   Úbufferedr…   rŒ   rÁ   rÃ   rÖ   rG   rù  r…  Úpendingr}   Ú
added_keysr6   Úindex_entriesÚall_entriesr�  s   `                            @r'   Úinsert_record_streamz'KnitVersionedFiles.insert_record_streamx  s‡  øø€ ð	ð 	ð 	ð 	ð 	ð 	õ ‘e”eˆØŒ=Ô"ð 
	<à$ˆIØˆLˆLð ˆIØ2Ð3ˆLØÔ$ð <Ø—’Ð 9Ñ:Ô:Ð:Ø× Ò Ð!:Ñ;Ô;Ð;å‘u”uˆØÔ ð 	;Ø×ÒÐ.°Ñ:Ñ;Ô;Ð;Ø�OŠOÐ-°	Ñ9Ñ:Ô:Ð:Ø×Ò˜¨)Ñ3Ñ4Ô4Ð4Ø!×'Ò'¨Ñ5Ô5ˆ
Øˆð "$ÐØð l	8ñ l	8ˆFØÔ&ˆDØ�Š˜wÑ'Ô'ð ¨D¯MªM¸%Ñ,@Ô,@ð ð "Ô-�Ø×3Ò3°F´JÀÑIÔI‘��CØ—’‘
”
�
ØˆHØ”nˆGØÔ" kÐ1Ð1ð &-¨Q¤ZÐ"Ð"à%)Ð"àÔ" hÒ.Ð.Ý(¨&¬*¨°tÑ<Ô<Ð<ØÔ&¨*Ð4Ñ4Ø%Ð-ØÔ3ð .à%¨¬Ð4Ð4Ø%¨TÐ1Ñ1ð Ô&¨lÐ:Ð:ð;Ø'-Ô':¸OÐ&L˜Ø"- +¨kÑ":Ô":˜˜øÝ#ð ;ð ;ð ;Ø'-Ô':¸LÐ&I˜Ø"- +¨kÑ":Ô":˜˜˜ð;øøøð $×-Ò-¨f°kÀ!´nÑEÔE�E�Eð #Ô.�EØ!Ô0°Ô3×:Ò:¸7ÑCÔCÐD�ØÔ(¨Ô+ð .Ø—N’N 9Ñ-Ô-Ð-ð #œl×9Ò9Ø”J¥ E¡
¤
¨U¨Gñ5ô 5�à%œz¨7°KÀÐI�Ø gÐ-Ð-ð *°´Ð<Ð<Ø"8×"CÒ"CØ.°ñ#4ô #4˜àŸš {Ñ3Ô3Ð3Ø#'˜Øð ;Ø”K×+Ò+¨[¨MÑ:Ô:Ð:øØÔ$Ð(;Ð;Ð;Ø—’˜vœz¨7°F×4GÒ4GÈÑ4PÔ4PÑQÔQÐQÐQð ”×"Ò"Ñ$Ô$Ð$ð?à"×/Ò/°Ñ8Ô8�E�EøÝ0ð ?ð ?ð ?Ø"(Ô"5°wÐ">�KØ)˜k¨+Ñ6Ô6�GØ#×-Ò-¨f°gÑ>Ô>�E�E�Eð?øøøðØ—N’N 6¤:¨w¸Ñ>Ô>Ð>Ð>øÝÔ4ð ð ð Ø�Dðøøøð ð 	8Ø$œj˜\�
Ø ð 8Ø$Ÿ.š.¨Ñ+Ô+�CØÐ4Ð4Ð4Ø(>¸sÔ(C˜Øœ×/Ò/°Ñ>Ô>Ð>Ø"×)Ò)ØMÐM¸}ÐMÑMÔMñOô Oð Oà2°3Ð7ð !ð 8ùð "ð 		?ð ˆKØ-ð 2ð 2�Ø 6°sÔ ;�Ø×"Ò" =Ñ1Ô1Ð1Ð1ØŒK×#Ò#Ø¸ð $ñ ?ô ?ð ?ð ?ð ?ð		?ð 		?s6   Æ,GÇG"Ç!G"Ì1MÍ4M>Í=M>ÎNÎN1Î0N1c                 ó4   — | j                              ¦   «         S )a  Return an iterable of keys of missing compression parents.

        Check this after calling insert_record_stream to find out if there are
        any missing compression parents.  If there are, the records that
        depend on them are not able to be inserted safely. For atomic
        KnitVersionedFiles built on packs, the transaction should be aborted or
        suspended - commit will fail at this point. Nonatomic knits will error
        earlier because they have no staging area to put pending entries into.
        )rÄ  Úget_missing_compression_parentsrë   s    r'   Ú#get_missing_compression_parent_keysz6KnitVersionedFiles.get_missing_compression_parent_keys   s   € ð Œ{×:Ò:Ñ<Ô<Ð<r&   c              #   óˆ  K  — |€t           j                             ¦   «         }t          |¦  «        }t	          |¦  «        }d}|�sK	 g }| j                             |¦  «        }|                     ¦   «         D ]&\  }}||v r|                     ||d         f¦  «         Œ't          |  
                    |¦  «        ¦  «        }	|	D ]’\  }
\  }}}|                     t          d¦  «        |
|¦  «         ||         d         }|€| j                             |¦  «        }n| j                             |¦  «        }|                     |¦  «         |D ]}||fV — Œ	Œ“d}n6# t"          j        $ r$}| j                             |¦  «         Y d}~nd}~ww xY w|�¯K|r$| j        st-          |t/          | ¦  «        ¦  «        ‚| j        D ]_}|s nZt          ¦   «         }|                     |¦  «        D ] \  }}|                     |¦  «         ||fV — Œ!|                     |¦  «         Œ`|                     t          d¦  «        ||¦  «         dS )a½  Iterate over the lines in the versioned files from keys.

        This may return lines from other keys. Each item the returned
        iterator yields is a tuple of a line and a text version that that line
        is present in (not introduced in).

        Ordering of results is in whatever order is most suitable for the
        underlying storage format.

        If a progress bar is supplied, it may be used to indicate progress.
        The caller is responsible for cleaning up progress bars (because this
        is an iterator).

        NOTES:
         * Lines are normalised by the underlying store: they will all have \n
           terminators.
         * Lines are returned in arbitrary order.
         * If a requested key did not change any lines (or didn't have any
           lines), it may not be mentioned at all in the result.

        :param pb: Progress bar supplied by caller.
        :return: An iterator over (line, key).
        NFr   zWalking contentr   T)ÚuiÚ
ui_factoryÚnested_progress_barr¸  r  rÄ  r  r  rX  Ú	enumerateÚ_read_records_iterr-  ÚgettextrÇ  r^  rb  Úremover§  rC  rÅ  rD  rÈ  r   ÚreprÚ#iter_lines_added_or_present_in_keysr¹  r.  )r/   r¼  ÚpbÚtotalÚdoneÚkey_recordsr£   r6   r#  Úrecords_iterÚkey_idxr÷  Ú	sha_valuerŒ   Úline_iteratorr3  r)  r  rv  s                      r'   r¤  z6KnitVersionedFiles.iter_lines_added_or_present_in_keys,  s²  è è € ð0 ˆ:Ý”×2Ò2Ñ4Ô4ˆBÝ�4‰yŒyˆÝ�D‘	”	ˆØˆØñ !	0ð 0ð !�Ø $¤× =Ò =¸dÑ CÔ C�Ø$1×$7Ò$7Ñ$9Ô$9ð >ð >‘L�C˜Ø˜d�{�{Ø#×*Ò*¨C°¸´Ð+<Ñ=Ô=Ð=øÝ(¨×)@Ò)@ÀÑ)MÔ)MÑNÔN�Ø9Eð (ð (Ñ5�WÑ4˜s D¨)Ø—I’I�gÐ&7Ñ8Ô8¸'À5ÑIÔIÐIØ)6°sÔ);¸AÔ)>Ð&Ø)Ð1à(,¬×(JÒ(JØ ñ)"ô )"˜˜ð )-¬×(KÒ(KØ ñ)"ô )"˜ð —K’K Ñ$Ô$Ð$ð
 !.ð (ð (˜Ø" C˜i˜˜˜˜ð(à��øÝÔ.ð 0ð 0ð 0Ø”×,Ò,¨QÑ/Ô/Ð/Ð/Ð/Ð/Ð/Ð/øøøøð0øøøðA ñ !	0ðL ð 	7˜Ô4ð 	7õ % T­4°©:¬:Ñ6Ô6Ð6ØÔ2ð 	0ð 	0ˆFØð Ø�Ý™%œ%ˆKØ#×GÒGÈÑMÔMð  ð  ‘	��cØ—’ Ñ$Ô$Ð$Ø˜C�i����Ø×"Ò" ;Ñ/Ô/Ð/Ð/Ø
�	Š	•'Ð+Ñ,Ô,¨e°UÑ;Ô;Ð;Ð;Ð;s   ÁDE ÅFÅ'FÆFc           
      óì   — g }|                      ¦   «         D ]\}|d         dk    rŒ|                     |d         |d         |d         |d         z
  |j        |d         |d         …         f¦  «         Œ]|S )z5Generate a line delta from delta_seq and new_content.r   rñ   r   r   é   rZ   )rô   rX  rõ   )r/   Ú	delta_seqÚnew_contentÚ
diff_hunksÚops        r'   Ú_make_line_deltaz#KnitVersionedFiles._make_line_delta}  s‘   € àˆ
Ø×'Ò'Ñ)Ô)ð 	Pð 	PˆBØ�!Œu˜ÒÐØØ×ÒØ�A”˜˜1œ˜r !œu r¨!¤u™}¨kÔ.@ÀÀAÄÀrÈ!ÄuÀÔ.MÐNñPô Pð Pð PàÐr&   c                 óX  — |�t                                |¦  «        }nd}|�r|D ]ª}|                      ||¦  «        }	||d         k    r|�|}
n@t                               d|	                     ¦   «         |                     ¦   «         ¦  «        }
|
                     ¦   «         D ],\  }}}|dk    rŒ|	j        |||z   …         |j        |||z   …<   Œ-Œ«|j        rY|j        d         d                              d¦  «        s3|j        d         d         dz   }|j        d         d         |f|j        d<   |rx|€`|                      |d         |¦  «        }|                     ¦   «         }|                     ¦   «         }t                               d||¦  «        }|  	                    ||¦  «        S dS )a  Merge annotations for content and generate deltas.

        This is done by comparing the annotations based on changes to the text
        and generating a delta on the resulting full texts. If annotations are
        not being created then a simple delta is created.
        Nr   ry   r   rÚ   )
ÚdiffÚ_PrematchedMatcherrs  rò   ró   r`   Úget_matching_blocksrõ   ré  r³  )r/   r7   r…   rÚ  rt   r¥   rÛ  r¯  Ú
parent_keyÚmerge_contentÚseqÚiÚjr  r3  Úreference_contentr÷   rø   s                     r'   rë  z%KnitVersionedFiles._merge_annotations‡  så  € ð  Ð+Ý×/Ò/Ð0DÑEÔEˆIˆIàˆIØñ 	CØ%ð Lð L�
Ø $× 1Ò 1°*¸lÑ KÔ K�Ø '¨!¤*Ò,Ð,°Ð1FØ#�C�Cå&×>Ò>Ø˜m×0Ò0Ñ2Ô2°G·L²L±N´NñDô D�Cà"×6Ò6Ñ8Ô8ð Lð L‘G�A�q˜!Ø˜A’v�vØ ð /<Ô.BÀ1ÀQÈÁUÀ7Ô.K�G”N 1 Q¨¡U 7Ñ+Ð+ðLð Œ~ð C g¤n°RÔ&8¸Ô&;×&DÒ&DÀUÑ&KÔ&Kð Cð ”~ bÔ)¨!Ô,¨uÑ4�Ø&-¤n°RÔ&8¸Ô&;¸TÐ%B�”˜rÑ"Øð 	=ØÐ Ø$(×$5Ò$5°g¸a´jÀ,Ñ$OÔ$OÐ!Ø#ŸLšL™NœN�	Ø-×2Ò2Ñ4Ô4�	Ý(×@Ò@Ø˜) Yñ0ô 0�	à×(Ò(¨°GÑ<Ô<Ð<ð	=ð 	=r&   c                 ór   — |                       |¦  «        \  }}|                      ||¦  «         ||d         fS )zParse an original format knit record.

        These have the last element of the key only present in the stored data.
        rZ   )r]   r  )r/   r0  r÷  re   Úrecord_contentss        r'   r9  z KnitVersionedFiles._parse_record´  sA   € ð
  $×;Ò;¸DÑAÔAÑˆˆ_Ø×"Ò" 3¨
Ñ3Ô3Ð3Ø  A¤Ð&Ð&r&   c                 ó6  — t                                dt          |¦  «        ¬¦  «        }	 |                      ||                     ¦   «         ¦  «        }nC# t
          $ r6}t          | d|›d|j        j        ›dt          |¦  «        ›d�¦  «        ‚d}~ww xY w||fS )z•Parse a record header for consistency.

        :return: the header and the decompressor stream.
                 as (stream, header_record)
        Úrb©ÚmodeÚfileobjzWhile reading {z} got ú(ú)N)
ÚgzipÚGzipFiler   r  ÚreadlineÚ	Exceptionr)   rÍ  r!   Ústr)r/   r6   rz  r‘  re   r)  s         r'   r‰  z'KnitVersionedFiles._parse_record_header½  s³   € õ �]Š] ­g°hÑ.?Ô.?ˆ]Ñ@Ô@ˆð	Eà×$Ò$ S¨"¯+ª+©-¬-Ñ8Ô8ˆCˆCøÝð 	Eð 	Eð 	EÝ˜d˜dà!$   a¤kÔ&:Ð&:Ð&:½CÀ¹F¼F¸F¸FðDñEô Eð Eøøøøð	Eøøøð �3ˆwˆs   «(A Á
BÁ1BÂBc                 óâ  — t                                dt          |¦  «        ¬¦  «        5 }	 |                     ¦   «         }nC# t          $ r6}t          | d|›d|j        j        ›dt          |¦  «        ›d�¦  «        ‚d }~ww xY w| 	                    d¦  «        }|  
                    |¦  «        }| 	                    ¦   «         }t          |¦  «        t          |d         ¦  «        k    rBt          | d	t          |¦  «        ›d
t          |d         ¦  «        ›d|d         ›d|›�¦  «        ‚|d|d         z  k    rt          | d|›d|d         ›�¦  «        ‚	 d d d ¦  «         n# 1 swxY w Y   ||fS )NrÁ  rÂ  zCorrupt compressed record z, got rÅ  rÆ  r   r   zincorrect number of lines z != z for version {r   z} s   end %s
zunexpected version end line z	, wanted )rÇ  rÈ  r   Ú	readlinesrÊ  r)   rÍ  r!   rË  r  r  r  rN  )r/   r÷  r‘  r¿  r)  rZ  re   r  s           r'   r]   z*KnitVersionedFiles._parse_record_uncheckedÍ  sÞ  € õ
 �]Š] ­g°d©m¬mˆ]Ñ<Ô<ð 	9ÀðHØ"$§,¢,¡.¤.��øÝð Hð Hð HÝ! $ $Ø#' 4 4¨¬Ô)=Ð)=Ð)=½sÀ1¹v¼v¸v¸vð)Gñ Hô Hð HøøøøðHøøøð %×(Ò(¨Ñ+Ô+ˆFØ×$Ò$ VÑ,Ô,ˆCØ'×+Ò+Ñ-Ô-ˆIÝ�?Ñ#Ô#¥s¨3¨q¬6¡{¤{Ò2Ð2Ý! $ $õ &)¨Ñ%9Ô%9Ð%9Ð%9½3¸sÀ1¼v¹;¼;¸;¸;Ø%(¨¤V V V¨_¨_ð#>ñ?ô ?ð ?ð
 ˜K¨#¨a¬&Ñ0Ò0Ð0Ý! $ $à%. Y Y°°A´°ð#8ñ9ô 9ð 9ð 1ð	9ð 	9ð 	9ñ 	9ô 	9ð 	9ð 	9ð 	9ð 	9ð 	9ð 	9øøøð 	9ð 	9ð 	9ð 	9ð& �OÐ#Ð#s5   ªE"¬AÁ E"Á
BÁ1A<Á<BÂCE"Å"E&Å)E&c              #   ó@  K  — |sdS t          t          |¦  «        t          j        d¦  «        ¬¦  «        }|sdS | j                             d„ |D ¦   «         ¦  «        }t          ||¦  «        D ].\  \  }}}|                      |d         |¦  «        \  }}|||fV — Œ/dS )a¢  Read text records from data file and yield result.

        The result will be returned in whatever is the fastest to read.
        Not by the order requested. Also, multiple requests for the same
        record will only yield 1 response.

        :param records: A list of (key, access_memo) entries
        :return: Yields (key, contents, digest) in the order
                 read, not the order requested
        Nr   r>  c                 ó   — g | ]\  }}|‘ŒS r%   r%   ©r²   r6   r·  s      r'   râ   z9KnitVersionedFiles._read_records_iter.<locals>.<listcomp>ý  s   € Ð>Ð>Ð>™O˜C ˆZÐ>Ð>Ð>r&   ry   )Úsortedr¸  r@  rA  rÅ  Úget_raw_recordsr@  r9  )	r/   rF  Úneeded_recordsrz  r6   r·  r÷  r7   rî  s	            r'   r   z%KnitVersionedFiles._read_records_iterç  sÕ   è è € ð ð 	ØˆFõ  ¥ G¡¤µ(Ô2EÀaÑ2HÔ2HÐIÑIÔIˆØð 	ØˆFð ”<×/Ò/Ø>Ð>¨~Ð>Ñ>Ô>ñ@ô @ˆõ (+¨>¸8Ñ'DÔ'Dð 	'ð 	'Ñ#ÑˆS�*˜tØ"×0Ò0°°R´¸$Ñ?Ô?‰OˆG�VØ�w Ð&Ð&Ð&Ð&Ð&ð	'ð 	'r&   c              #   ó´   K  — |                       |¦  «        D ]?\  }}|                      ||¦  «        \  }}|                     ¦   «          |||d         fV — Œ@dS )a  Read text records from data file and yield raw data.

        This unpacks enough of the text record to validate the id is
        as expected but thats all.

        Each item the iterator yields is (key, bytes,
            expected_sha1_of_full_text).
        rZ   N)rB  r‰  r²  )r/   rF  r6   r÷  r‘  re   s         r'   Ú_read_records_iter_rawz)KnitVersionedFiles._read_records_iter_raw  su   è è € ð ×:Ò:¸7ÑCÔCð 	$ð 	$‰IˆC�ð ×/Ò/°°TÑ:Ô:‰GˆB�Ø�HŠH‰JŒJˆJØ�t˜S œVÐ#Ð#Ð#Ð#Ð#ð	$ð 	$r&   c              #   ó®   K  — t          |¦  «        r&d„ |D ¦   «         }| j                             |¦  «        }|D ]\  }}t          |¦  «        }||fV — ŒdS )z„Read text records from data file and yield raw data.

        No validation is done.

        Yields tuples of (key, data).
        c                 ó   — g | ]\  }}|‘ŒS r%   r%   rÐ  s      r'   râ   zCKnitVersionedFiles._read_records_iter_unchecked.<locals>.<listcomp>  s(   € ð *ð *ð *©_¨S°*˜jð *ð *ð *r&   N)r  rÅ  rÒ  r†   )r/   rF  Úneeded_offsetsÚraw_recordsr6   r·  r÷  s          r'   rB  z/KnitVersionedFiles._read_records_iter_unchecked  sƒ   è è € õ ˆw‰<Œ<ð 	Gð*ð *Ø!(ð*ñ *ô *ˆNàœ,×6Ò6°~ÑFÔFˆKà&ð 	ð 	‰OˆC�Ý˜Ñ$Ô$ˆDØ�t�)ˆOˆOˆOˆOð	ð 	r&   c                 óö  — d|d         t          |¦  «        |fz  g}|                     |p|¦  «         |                     d|d         z   dz   ¦  «         |D ]6}t          |t          ¦  «        st          dt          |¦  «        z  ¦  «        ‚Œ7|r-|d                              d¦  «        st          d|z  ¦  «        ‚t           
                    |¦  «        }t          t          t           |¦  «        ¦  «        |fS )a¹  Convert key, digest, lines into a raw data block.

        :param key: The key of the record. Currently keys are always serialised
            using just the trailing component.
        :param dense_lines: The bytes of lines but in a denser form. For
            instance, if lines is a list of 1000 bytestrings each ending in
            \n, dense_lines may be a list with one line in it, containing all
            the 1000's lines and their \n's. Using dense_lines if it is
            already known is a win because the string join to create bytes in
            this function spends less time resizing the final string.
        :return: (len, chunked bytestring with compressed data)
        s   version %s %d %s
ry   s   end rÚ   údata must be plain bytes was %szcorrupt lines value %r)r  rm  rX  rt  rÖ   rk  Útyperé  r(  Ú
tuned_gzipÚchunks_to_gziprº  Úmap)r/   r6   rî  r}   rø  rh   ÚchunkÚcompressed_chunkss           r'   r_   z"KnitVersionedFiles._record_to_data&  s  € ð (¨3¨r¬7µC¸±J´JÀÐ*GÑGÐHˆØ�Š�kÐ* UÑ+Ô+Ð+Ø�Š�g  B¤Ñ'¨%Ñ/Ñ0Ô0Ð0Øð 	Eð 	EˆEÝ˜e¥UÑ+Ô+ð EÝ$Ø5½¸U¹¼ÑCñEô Eð EðEð ð 	?˜˜rœ×+Ò+¨EÑ2Ô2ð 	?ÝÐ5¸Ñ=Ñ>Ô>Ð>Ý&×5Ò5°fÑ=Ô=ÐÝ•3•sÐ-Ñ.Ô.Ñ/Ô/Ð1BÐBÐBr&   c                 ót   — |                      ¦   «         }t          |¦  «        dk    rt          | d¦  «        ‚|S )Nr®  z.unexpected number of elements in record header)rß   r  r)   )r/   r3  re   s      r'   r  z KnitVersionedFiles._split_header?  s=   € Ø�jŠj‰lŒlˆÝˆs‰8Œ8�qŠ=ˆ=Ý˜dØNñPô Pð Pàˆ
r&   c                 óì   — dt           j        v rt                               dd¦  «         | j        g| j        z   }t          ¦   «         }|D ])}|                     |                     ¦   «         ¦  «         Œ*|S )zSee VersionedFiles.keys.Úevilr   z keys scales with size of history)	ÚdebugÚdebug_flagsÚtraceÚmutter_callsiterÄ  rÈ  r¸  r-  r¼  )r/   r/  rY  r  s       r'   r¼  zKnitVersionedFiles.keysF  sr   € à•UÔ&Ð&Ð&Ý×!Ò! !Ð%GÑHÔHÐHØ”;�- $Ô">Ñ>ˆÝ‘”ˆØð 	)ð 	)ˆFØ�MŠM˜&Ÿ+š+™-œ-Ñ(Ô(Ð(Ð(Øˆr&   )r–  FN)NNNFT)NNNFrÇ   rw  r+   )0r!   r"   r#   rH   r,   rÎ  rÐ  rÓ  rß  râ  rÙ  r   rý  r  rÿ  rØ  r  r  rè  r  r%  rs  rç  r*  r7  r5  r4  ÚclassmethodrL  Ú_STREAM_MIN_BUFFER_SIZErY  r‡   r\  r}  r—  rš  r¤  r³  rë  r9  r‰  r]   r   rÕ  rB  r_   r  r¼  r%   r&   r'   rL   rL   À  s=  € € € € € ðð ð <?Ø.2ð(ð (ð (ð (ð2ð ð ð5ð 5ð 5ð?ð ?ð ?ð ;?ØINØ $ð0ð 0ð 0ð 0ð  9=Ø;?Ø#ð0ð 0ð 0ð 0ð&k,ð k,ð k,ðZ1ð 1ð 1ð$ð $ð $ðCð Cð Cð Cð!ð !ð !ð"/ð /ð /ð"ð ð ð
fð fð fð&*ð &*ð &*ðPDð Dð Dð
!ð !ð !ð !ðF .0ð 
+ð 
+ð 
+ð 
+ð:ð :ð :ð&ð &ð &ð.4ð 4ð 4ð 4ð&
ð 
ð 
ð0ð 0ð 0ð 0ð@ ð-ð -ñ „[ð-ðD -Dð)ð )ð )ð )ðV0ð 0ð 0ð@uNð uNð uNðnð ð ð&f?ð f?ð f?ðP
=ð 
=ð 
=ðO<ð O<ð O<ð O<ðbð ð ð ACØ!%°Ø04ð+=ð +=ð +=ð +=ðZ'ð 'ð 'ðð ð ð $ð $ð $ð4'ð 'ð 'ð8$ð $ð $ð ð ð ð&Cð Cð Cð Cð2ð ð ðð ð ð ð r&   rL   c                   ó8   — e Zd ZdZd
d„Zd„ Zd„ Zd„ Zd„ Zd„ Z	d	S )Ú_ContentMapGeneratorz7Generate texts or expose raw deltas for a set of texts.rƒ   c                 ó   — || _         d S r+   )Ú	_ordering)r/   r^  s     r'   r,   z_ContentMapGenerator.__init__T  s   € Ø!ˆŒˆˆr&   c                 óÔ   — || j         v rKt          |                      ¦   «         ¦  «        }|                     d¦  «        }t	          ||j        ¦  «        S |                      |¦  «        S )zGet the content object for key.r}   )Únonlocal_keysr†   r‡   rˆ   r‰   r6   rÑ   )r/   r6   r:  r}   s       r'   rs  z!_ContentMapGenerator._get_contentW  sf   € ð �$Ô$Ð$Ð$Ý˜$×0Ò0Ñ2Ô2Ñ3Ô3ˆFà×'Ò'¨Ñ0Ô0ˆEÝ# E¨6¬:Ñ6Ô6Ð6ð ×%Ò% cÑ*Ô*Ð*r&   c              #   ó>   K  — |                       ¦   «         E d{V —† dS )z;Get a record stream for the keys requested during __init__.N)Ú_workrë   s    r'   r‡   z&_ContentMapGenerator.get_record_streamd  s,   è è € à—:’:‘<”<ÐÐÐÐÐÐÐÐÐr&   c              #   óÞ  K  — | j         €$| j                             | j        ¦  «        | _         | j        }t          |¦  «        }| j        j        D ]O}|s nJ|                     || j        d¦  «        D ],}|j	        dk    rŒ| 
                    |j        ¦  «         |V — Œ-ŒP| j        €t          d¦  «        ‚d}| j        D ]-}|| j        v rŒt          || j         |         | |¦  «        V — d}Œ.dS )zÖProduce maps of text and KnitContents as dicts.

        :return: (text_map, content_map) where text_map contains the texts for
            the requested versions and content_map contains the KnitContents.
        NTr„   z'_raw_record_map should have been filledF)rs  r{  rç  r¼  rð  r¸  rÈ  r‡   rî  r[   r¢  r6   Ú_raw_record_maprk  rÉ   )r/   rð  Úmissing_keysr  r:  rÎ   r6   s          r'   rò  z_ContentMapGenerator._workh  s7  è è € ð Œ?Ð"Ø"œg×4Ò4°T´YÑ?Ô?ˆDŒOØÔ*ˆå˜=Ñ)Ô)ˆà”gÔ5ð 	ð 	ˆFØð Ø�ð !×2Ò2°<Ø37´>À4ñIô Ið ð �àÔ&¨(Ò2Ð2ð Ø×#Ò# F¤JÑ/Ô/Ð/Ø����ðð ÔÐ'Ý Ð!JÑKÔKÐKØˆØ”9ð 	ð 	ˆCØ�dÔ(Ð(Ð(ØÝ(¨¨d¬o¸cÔ.BÀDÈ%ÑPÔPÐPÐPÐPØˆEˆEð		ð 	r&   c           	      ó6  — || j         v r| j         |         S t          | j        ¦  «        dk    }| j        €$| j                             | j        ¦  «        | _        | j        }| j        D �] }|| j        v rŒg }|}|�m	 ||         \  }}}	}
n# t          $ r t          || ¦  «        ‚w xY w| 
                    ||||	f¦  «         |
}|| j         v r| 
                    |d d d f¦  «         n|­md }t          |¦  «        D ]R\  }}}}	|| j         v r| j         |         }Œ| j                             |d         ||||¬¦  «        \  }}|r
|| j         |<   ŒS|                     ¦   «         }t          |¦  «        }||	k    rt!          | ||	||¦  «        ‚�Œ"|r| j         |         S |S )Nr   ry   ©r=  )Ú_contents_mapr  r¼  Ú_record_mapr{  r5  rô  rð  r  r   rX  rl  rÇ  r~   r`   r   r2   )r/   Úrequested_keyÚmultiple_versionsr~  r6   Ú
componentsÚcursorr:  r;  rî  r†   r7   Úcomponent_idrt   r`   Ú
actual_shas                   r'   rÑ   z"_ContentMapGenerator._get_one_workŽ  s)  € ð ˜DÔ.Ð.Ð.ØÔ% mÔ4Ð4õ   ¤	™NœN¨aÒ/ÐØÔÐ#Ø#œw×=Ò=ØÔ$ñ &ô  &ˆDÔàÔ%ˆ
ð ”9ð "	Kñ "	KˆCØ�dÔ(Ð(Ð(àØˆJØˆFØÐ$ð;Ø;EÀfÔ;MÑ8�F˜N¨F°D°DøÝð ;ð ;ð ;Ý,¨V°TÑ:Ô:Ð:ð;øøøà×!Ò! 6¨6°>À6Ð"JÑKÔKÐKØ�Ø˜TÔ/Ð/Ð/à×%Ò% v¨t°T¸4Ð&@ÑAÔAÐAØð Ð$ð ˆGå$ ZÑ0Ô0ð	Cð 	Cñ �˜v ~ØØ 4Ô#5Ð5Ð5Ø"Ô0°Ô>�G�Gà%)¤]×%?Ò%?Ø˜Bœ ¨¸Ø*;ð &@ñ &=ô &=‘N�G˜Uð )ð CØ;B˜Ô*¨<Ñ8øð —<’<‘>”>ˆDÝ$ TÑ*Ô*ˆJØ˜VÒ#Ð#Ý% d¨J¸ÀÀTÑJÔJÐJñ $àð 	ØÔ% mÔ4Ð4àˆNs   Á<B
Â
B%c                 ó€  ‡ — g }|                      d¦  «         ‰ j        j        j        r|                      d¦  «         n|                      d¦  «         |                      d                     ˆ fd„‰ j        D ¦   «         ¦  «        ¦  «         g }‰ j                             ¦   «         D ]Õ\  }\  }\  }}}d                     |¦  «        }‰ j         	                    |d¦  «        }	|	€d}
nd                     d	„ |	D ¦   «         ¦  «        }
| 
                    d
¦  «        }|rd}nd}|rd                     |¦  «        }nd}|                      d                     ||
|||dt          |¦  «        z  |g¦  «        ¦  «         ŒÖd                     |¦  «        }|                      |¦  «         d                     |¦  «        }|S )aý  Get the bytes to put on the wire for 'key'.

        The first collection of bytes asked for returns the serialised
        raw_record_map and the additional details (key, parent) for key.
        Subsequent calls return just the additional details (key, parent).
        The wire storage_kind given for the first key is 'knit-delta-closure',
        For subsequent keys it is 'knit-delta-closure-ref'.

        :param key: A key from the content generator.
        :return: Bytes to put on the wire.
        s   knit-delta-closureó	   annotatedr&   r­   c              3   óT   •K  — | ]"}|‰j         v¯d                      |¦  «        V — Œ#dS r¯   )rð  ra   )r²   r6   r/   s     €r'   r³   z3_ContentMapGenerator._wire_bytes.<locals>.<genexpr>Ý  sL   øè è € ð  Bð  B°cØ#&¨dÔ.@Ð#@Ð#@ð !(§¢¨SÑ 1Ô 1Ø#@Ð#@Ð#@Ð#@ð Bð  Br&   r«   Nr¬   c              3   ó@   K  — | ]}d                       |¦  «        V — ŒdS r¯   r°   r±   s     r'   r³   z3_ContentMapGenerator._wire_bytes.<locals>.<genexpr>ð  s.   è è € Ð)OÐ)OÀ¨'¯,ª,°sÑ*;Ô*;Ð)OÐ)OÐ)OÐ)OÐ)OÐ)Or&   r¶   ó   Tó   FrÚ   ó   %d)rX  r{  rÇ  r¥   ra   r¼  rô  r  rs  r¾   r·   r  )r/   r}   Úmap_byte_listr6   Úrecord_bytesræ   rº   r†   r¸   r…   r¹   Úmethod_bytesÚnoeol_bytesÚ
next_bytesÚ	map_bytesrÖ   s   `               r'   rÐ   z _ContentMapGenerator._wire_bytesÈ  s  ø€ ð ˆà�ŠÐ*Ñ+Ô+Ð+àŒ7ÔÔ%ð 	Ø�LŠL˜Ñ&Ô&Ð&Ð&à�LŠL˜ÑÔÐà�Š�U—Z’Zð  Bð  Bð  Bð  B¸T¼Yð  Bñ  Bô  Bñ Bô Bñ 	Cô 	Cð 	Cð ˆð Ô$×*Ò*Ñ,Ô,ð	<ð 	<Ñ6ˆCÑ6�,¡ ¨°àŸš SÑ)Ô)ˆIØ”o×)Ò)¨#¨tÑ4Ô4ˆGØˆØ'��à$ŸzšzÐ)OÐ)OÀwÐ)OÑ)OÔ)OÑOÔO�Ø!Ÿ=š=¨Ñ1Ô1ˆLØð #Ø"��à"�Øð !Ø$Ÿ\š\¨$Ñ/Ô/�
�
à �
Ø× Ò  §¢Ø˜L¨,¸ÀZØ�˜\Ñ*Ô*Ñ*¨Lð:ñ";ô ";ñ <ô <ð <ð <ð —H’H˜]Ñ+Ô+ˆ	Ø�Š�YÑÔÐØ—
’
˜5Ñ!Ô!ˆØˆr&   N)rƒ   )
r!   r"   r#   rH   r,   rs  r‡   rò  rÑ   rÐ   r%   r&   r'   rì  rì  Q  s{   € € € € € ØAÐAð"ð "ð "ð "ð+ð +ð +ð ð  ð  ð$ð $ð $ðL8ð 8ð 8ðt8ð 8ð 8ð 8ð 8r&   rì  c                   ó   — e Zd ZdZ	 	 dd„ZdS )r'  z;Content map generator reading from a VersionedFiles object.Nrƒ   c                 óx  — t                                | |¬¦  «         || _        t          |¦  «        | _        |€t          ¦   «         | _        nt          |¦  «        | _        || _        i | _	        i | _
        d| _        |€"| j                             |d¬¦  «        | _        n|| _        | j        j        | _        dS )ay  Create a _ContentMapGenerator.

        :param versioned_files: The versioned files that the texts are being
            extracted from.
        :param keys: The keys to produce content maps for.
        :param nonlocal_keys: An iterable of keys(possibly intersecting keys)
            which are known to not be in this knit, but rather in one of the
            fallback knits.
        :param global_map: The result of get_parent_map(keys) (or a supermap).
            This is required if get_record_stream() is to be used.
        :param raw_record_map: A unparsed raw record map to use for answering
            contents.
        rf  NTr3  )rì  r,   r{  r  r¼  r¸  rð  Ú	frozensetrs  Ú	_text_maprø  rù  r4  rô  rÇ  )r/   r³  r¼  rð  rs  rG  r^  s          r'   r,   z_VFContentMapGenerator.__init__	  sÀ   € õ 	×%Ò% d°XÐ%Ñ>Ô>Ð>à!ˆŒå˜‘J”JˆŒ	àÐ Ý!$¡¤ˆDÔÐå!*¨=Ñ!9Ô!9ˆDÔà$ˆŒàˆŒàˆÔð  ˆÔØÐ!Ø#'¤7×#CÒ#CÀDØRVð $Dñ $Xô $XˆDÔ Ð ð $2ˆDÔ àœÔ(ˆŒˆˆr&   )NNNrƒ   rT   r%   r&   r'   r'  r'  	  s4   € € € € € ØEÐEà<@Ø@Kð()ð ()ð ()ð ()ð ()ð ()r&   r'  c                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )rÕ   z4Content map generator sourced from a network stream.c                 ój  — || _         i | _        i | _        i | _        d| _        g | _        t          dd¦  «        | _        |}|                     d|¦  «        }|||…         }|dz   }|dk    rt          ¦   «         | _
        nt          ¦   «         | _
        |                     d|¦  «        }|||…         }|dz   }d„ |                     d¦  «        D ¦   «         | _        t          |¦  «        }||k     �rÀ|                     d|¦  «        }t          |||…                              d¦  «        ¦  «        }|dz   }|                     d|¦  «        }|||…         }|dk    rd}n,t          d	„ |                     d¦  «        D ¦   «         ¦  «        }|| j        |<   |dz   }|                     d|¦  «        }|||…         }|                     d
¦  «        }|dz   }|                     d|¦  «        }|||…         }|dk    }	|dz   }|                     d|¦  «        }|||…         }|sd}
n*t          |||…                              d¦  «        ¦  «        }
|dz   }|                     d|¦  «        }|||…         }t#          |¦  «        }|dz   }||||z   …         }||z   }|||	f|
f| j        |<   ||k     �°¾dS dS )z;Construct a _NetworkContentMapGenerator from a bytes block.NrÚ   r   r  c                 óV   — g | ]&}|¯t          |                     d ¦  «        ¦  «        ‘Œ'S rÜ   rÝ   rà   s     r'   râ   z8_NetworkContentMapGenerator.__init__.<locals>.<listcomp>K	  sB   € ð ð ð Ø.5ØðÝ�'—-’- Ñ(Ô(Ñ)Ô)ðð ð r&   r­   r«   r¬   c              3   ó^   K  — | ](}|¯t          |                     d ¦  «        ¦  «        V — Œ)dS r¯   rÝ   rà   s     r'   r³   z7_NetworkContentMapGenerator.__init__.<locals>.<genexpr>]	  sP   è è € ð   ð   Ø6=Øð  Ý˜'Ÿ-š-¨Ñ0Ô0Ñ1Ô1ð  ð   ð   ð   ð   ð   r&   r¶   r  )Ú_bytesrs  rô  rø  rù  rð  rL   r{  rã   rN   rÇ  rP   rß   r¼  r  rÞ   ÚdecoderN  )r/   rÖ   r×   rä   r3  r"  r6   r…   ræ   rº   r†   r#  r  s                r'   r,   z$_NetworkContentMapGenerator.__init__4	  s  € àˆŒØˆŒØ!ˆÔØˆÔØˆÔØˆÔå$ T¨4Ñ0Ô0ˆŒØˆà—:’:˜e UÑ+Ô+ˆØ�U˜8�^Ô$ˆØ˜1‘ˆØ�<ÒÐÝ/Ñ1Ô1ˆDŒMˆMå,Ñ.Ô.ˆDŒMà—:’:˜e UÑ+Ô+ˆØ�U˜8�^Ô$ˆØ˜1‘ˆðð Ø9=¿ºÀEÑ9JÔ9Jðñ ô ˆŒ	õ �%‰jŒjˆØ�cŠk‰kà—z’z %¨Ñ/Ô/ˆHÝ˜˜e H˜nÔ-×3Ò3°GÑ<Ô<Ñ=Ô=ˆCØ˜q‘LˆEà—z’z %¨Ñ/Ô/ˆHØ˜˜x˜Ô(ˆDØ�xÒÐØ��åð   ð   ØAEÇÂÈEÑARÔARð  ñ   ô   ñ  ô  �ð $+ˆDŒO˜CÑ Ø˜q‘LˆEà—z’z %¨Ñ/Ô/ˆHØ˜˜x˜Ô(ˆDØ—[’[ Ñ)Ô)ˆFØ˜q‘LˆEà—z’z %¨Ñ/Ô/ˆHØ˜˜x˜Ô(ˆDØ˜D’LˆEØ˜q‘LˆEà—z’z %¨Ñ/Ô/ˆHØ˜˜x˜Ô(ˆDØð CØ��å˜U 5¨ >Ô2×8Ò8¸ÑAÔAÑBÔB�Ø˜q‘LˆEà—z’z %¨Ñ/Ô/ˆHØ˜˜x˜Ô(ˆDÝ˜‘I”IˆEØ˜q‘LˆEà   u¨u¡}Ð!4Ô5ˆLØ˜E‘MˆEà)5¸À°ÈÐ(MˆDÔ  Ñ%ðW �cŠk‰kˆkˆkˆkˆkr&   c              #   ód   K  — d}| j         D ]#}t          || j        |         | |¦  «        V — d}Œ$dS )z=Get a record stream for for keys requested by the bytestream.TFN)r¼  rÉ   rs  )r/   rÎ   r6   s      r'   r‡   z-_NetworkContentMapGenerator.get_record_stream	  sN   è è € àˆØ”9ð 	ð 	ˆCÝ(¨¨d¬o¸cÔ.BÀDÈ%ÑPÔPÐPÐPÐPØˆEˆEð	ð 	r&   c                 ó   — | j         S r+   )r  rë   s    r'   rÐ   z'_NetworkContentMapGenerator._wire_bytes†	  s
   € ØŒ{Ðr&   N)r!   r"   r#   rH   r,   r‡   rÐ   r%   r&   r'   rÕ   rÕ   1	  sN   € € € € € Ø>Ð>ðINð INð INðVð ð ðð ð ð ð r&   rÕ   c                   óÀ   — e Zd ZdZdZd„ Zdd„Zd„ Zd„ Zd„ Z	d	„ Z
d
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zej        Zg fd„Zd„ Zd„ Zej        Zd„ Zd„ Zd„ Zd„ ZeZd„ Z dS )r�  aF  Manages knit index files

    The index is kept in memory and read on startup, to enable
    fast lookups of revision information.  The cursor of the index
    file is always pointing to the end, making it easy to append
    entries.

    _cache is a cache for fast mapping from version id to a Index
    object.

    _history is a cache for fast mapping from indexes to version ids.

    The index data format is dictionary compressed when it comes to
    parent references; a index entry may only have parents that with a
    lover index number.  As a result, the index is topological sorted.

    Duplicate entries may be written to the index for a single version id
    if this is done then the latter one completely replaces the former:
    this allows updates to correct version and parent information.
    Note that the two entries may share the delta, and that successive
    annotations and references MUST point to the first entry.

    The index file on disc contains a header, followed by one line per knit
    record. The same revision can be present in an index file more than once.
    The first occurrence gets assigned a sequence number starting from 0.

    The format of a single line is
    REVISION_ID FLAGS BYTE_OFFSET LENGTH( PARENT_ID|PARENT_SEQUENCE_ID)* :

    REVISION_ID is a utf8-encoded revision id
    FLAGS is a comma separated list of flags about the record. Values include
        no-eol, line-delta, fulltext.
    BYTE_OFFSET is the ascii representation of the byte offset in the data file
        that the compressed data starts at.
    LENGTH is the ascii representation of the length of the data file.
    PARENT_ID a utf-8 revision id prefixed by a '.' that is a parent of
        REVISION_ID.
    PARENT_SEQUENCE_ID the ascii representation of the sequence number of a
        revision id already in the knit that is a parent of REVISION_ID.
    The ' :' marker is the end of record marker.

    partial writes:
    when a write is interrupted to the index file, it will result in a line
    that does not end in ' :'. If the ' :' is not present at the end of a line,
    or at the end of the file, then the record that is missing it will be
    ignored by the parser.

    When writing new records to the index file, the data is preceded by '
'
    to ensure that records always start on new lines even if the last write was
    interrupted. As a result its normal for the last line in the index to be
    missing a trailing newline. One can be added with no harmful effects.

    :ivar _kndx_cache: dict from prefix to the old state of KnitIndex objects,
        where prefix is e.g. the (fileid,) for .texts instances or () for
        constant-mapped things like .revisions, and the old state is
        tuple(history_vector, cache_dict).  This is used to prevent having an
        ABI change with the C extension that reads .kndx files.
    s   # bzr knit index 8
c                 ó‚   — || _         || _        || _        || _        || _        |                      ¦   «          d| _        dS )z.Create a _KndxIndex on transport using mapper.TN)Ú
_transportÚ_mapperÚ
_get_scopeÚ_allow_writesÚ
_is_lockedÚ_reset_cacher[  )r/   r	   r’  Ú	get_scopeÚallow_writesÚ	is_lockeds         r'   r,   z_KndxIndex.__init__Ç	  sC   € à#ˆŒØˆŒØ#ˆŒØ)ˆÔØ#ˆŒØ×ÒÑÔÐØˆŒˆˆr&   Fc                 óÌ  — |r.t          d„ |D ¦   «         ¦  «        }t          j        || ¦  «        ‚i }|D ]d}|d         }|dd…         }| j                             |¦  «        dz   }	|                     |	|g f¦  «        }
|
d                              |¦  «         Œet          |¦  «        D �]¹}	||	         \  }}
|                      |g¦  «         g }| j        |         d         dd…         }| j        |         d          	                    ¦   «         }	 |
D ]é\  }}\  }}}}t          d„ |D ¦   «         ¦  «        st          |¦  «        ‚|€d}d	                     d
|d         z   d                     |¦  «        d|z  d|z  |                      |¦  «        dg¦  «        }t          |t          ¦  «        st!          dt#          |¦  «        z  ¦  «        ‚|                     |¦  «         |                      |||||¦  «         Œêt'          |¦  «        r/| j                             |	d                     |¦  «        ¦  «         n|                      |	|¦  «         �Œ©#  ||f| j        |<   ‚ xY wdS )a?  Add multiple records to the index.

        :param records: a list of tuples:
                         (key, options, access_memo, parents).
        :param random_id: If True the ids being added were randomly generated
            and no check for existence will be performed.
        :param missing_compression_parents: If True the records being added are
            only compressed against texts already in the index (or inside
            records). If False the records all refer to unavailable texts (or
            texts inside records) as compression parents.
        c              3   ó&   K  — | ]}|d          V — ŒdS )r   Nr%   )r²   r:  s     r'   r³   z)_KndxIndex.add_records.<locals>.<genexpr>à	  s&   è è € Ð:Ð:¨˜& œ)Ð:Ð:Ð:Ð:Ð:Ð:r&   r   Nry   r   r   c              3   ó@   K  — | ]}t          |t          ¦  «        V — Œd S r+   r  )r²   Úoptions     r'   r³   z)_KndxIndex.add_records.<locals>.<genexpr>ò	  s,   è è € ÐOÐO¸V�z¨&µ%Ñ8Ô8ÐOÐOÐOÐOÐOÐOr&   r%   rµ   rÚ   rQ  r  ó   :zdata must be utf8 was %sr&   )rÑ  r   r   r  rß  rI  rX  Ú_load_prefixesÚ_kndx_cacher+  r
  rê  ra   Ú_dictionary_compressrt  rÖ   rk  rÜ  Ú
_cache_keyr  r  Úappend_bytesÚ_init_index)r/   rF  rÝ  r†  r¼  Úpathsr:  r6   ru  ÚpathÚ	path_keysr}   Úorig_historyÚ
orig_cacherG   r—   Úposrg   r…   r3  s                       r'   rí  z_KndxIndex.add_recordsÑ	  s»  € ð 'ð 	8õ Ð:Ð:°'Ð:Ñ:Ô:Ñ:Ô:ˆDÝÔ+¨D°$Ñ7Ô7Ð7ØˆØð 	(ð 	(ˆFØ˜”)ˆCØ˜˜"˜”XˆFØ”<×#Ò# CÑ(Ô(¨7Ñ2ˆDØ×(Ò(¨°¸¨|Ñ<Ô<ˆIØ�aŒL×Ò Ñ'Ô'Ð'Ð'Ý˜5‘M”Mð 	ñ 	ˆDØ % d¤ÑˆF�IØ×Ò  Ñ)Ô)Ð)ØˆEØÔ+¨FÔ3°AÔ6°q°q°qÔ9ˆLØÔ)¨&Ô1°!Ô4×9Ò9Ñ;Ô;ˆJðØ=Fð Fð FÑ9�C˜¡. 1 c¨4°'ÝÐOÐOÀwÐOÑOÔOÑOÔOð 1Ý'¨Ñ0Ô0Ð0Ø�à"$˜ØŸ9š9ØØ˜bœ'ñ"Ø#'§9¢9¨WÑ#5Ô#5°u¸s±{ÀEÈDÁLØ×1Ò1°'Ñ:Ô:¸Dð&Bñ Cô C�Dõ & d­EÑ2Ô2ð EÝ,Ø6½¸d¹¼ÑCñEô Eð Eà—L’L Ñ&Ô&Ð&Ø—O’O C¨°#°t¸WÑEÔEÐEÐEÝ�|Ñ$Ô$ð 2Ø”O×0Ò0°°s·x²xÀ±´ÑGÔGÐGÐGà×$Ò$ T¨5Ñ1Ô1Ð1ùøðà,6¸Ð+E�Ô  Ñ(Øøøøð=	ð 	s   ÄE IÉI!c                 ó*   — t          | j        ¦  «        ‚)z+See _KnitGraphIndex.scan_unvalidated_index.)rî   Úscan_unvalidated_index)r/   r­  s     r'   r6  z!_KndxIndex.scan_unvalidated_index	
  s   € õ " $Ô"=Ñ>Ô>Ð>r&   c                 ó*   — t          | j        ¦  «        ‚)z4See _KnitGraphIndex.get_missing_compression_parents.)rî   r™  rë   s    r'   r™  z*_KndxIndex.get_missing_compression_parents
  s   € õ " $Ô"FÑGÔGÐGr&   c                 ól  — |dd…         }|d         }t          d„ |D ¦   «         ¦  «        }|D ]3}	|	dd…         |k    r#t          d                     ||¦  «        ¦  «        ‚Œ4| j        |         \  }
}||
vr%t	          |¦  «        }|                     |¦  «         n|
|         d         }||||||f|
|<   dS )zêCache a version record in the history array and index cache.

        This is inlined into _load_data for performance. KEEP IN SYNC.
        (It saves 60ms, 25% of the __init__ overhead on local 4000 record
         indexes).
        Nry   c              3   ó&   K  — | ]}|d          V — ŒdS )ry   Nr%   )r²   rñ  s     r'   r³   z(_KndxIndex._cache_key.<locals>.<genexpr>
  s&   è è € Ð=Ð= v˜˜rœ
Ð=Ð=Ð=Ð=Ð=Ð=r&   z"mismatched prefixes for {!r}, {!r}é   )rÞ   r(  r    r*  r  rX  )r/   r6   rG   r4  rg   Úparent_keysru  r0  r…   rñ  rJ  Úhistoryr   s                r'   r,  z_KndxIndex._cache_key
  sú   € ð �S�b�S”ˆØ˜”Wˆ
åÐ=Ð=°Ð=Ñ=Ô=Ñ=Ô=ˆØ!ð 	'ð 	'ˆFØ�c�r�cŒ{˜fÒ$Ð$Ý Ð!E×!LÒ!LØ˜ñ"&ô "&ñ 'ô 'ð 'ð %ð Ô)¨&Ô1‰ˆˆwð ˜UÐ"Ð"Ý˜‘L”LˆEØ�NŠN˜:Ñ&Ô&Ð&Ð&à˜*Ô% aÔ(ˆEØ'Ø$Ø Ø!Ø$Ø"ð$ˆˆjÑÐÐr&   c                 óš   — |                      ¦   «         }|dk    rt          j        | ¦  «        ‚|| j        k    rt	          || ¬¦  «        ‚d S )Nr&   )rC   r-   )rÉ  Ú_mod_transportr   ÚHEADERrA   )r/   Úfpr3  s      r'   Úcheck_headerz_KndxIndex.check_header3
  sS   € Ø�{Š{‰}Œ}ˆØ�3Š;ˆ;õ !Ô+¨DÑ1Ô1Ð1Ø�4”;ÒÐÝ!¨$¸Ð>Ñ>Ô>Ð>ð Ðr&   c                 ó¼   — |                       ¦   «         st          j        | ¦  «        ‚|                      ¦   «         | j        k    r|                      ¦   «          d S d S r+   )r  r   ÚObjectNotLockedr  Ú_scoper   rë   s    r'   Ú_check_readz_KndxIndex._check_read<
  s\   € Ø�ŠÑ Ô ð 	/ÝÔ(¨Ñ.Ô.Ð.Ø�?Š?ÑÔ ¤Ò+Ð+Ø×ÒÑÔÐÐÐð ,Ð+r&   c                 óö   — |                       ¦   «         st          j        | ¦  «        ‚|                      ¦   «         | j        k    r|                      ¦   «          | j        dk    rt          j        | ¦  «        ‚dS )z#Assert if not writes are permitted.ÚwN)r  r   rC  r  rD  r   Ú_modeÚReadOnlyObjectDirtiedErrorrë   s    r'   r×  z_KndxIndex._check_write_okB
  st   € à�ŠÑ Ô ð 	/ÝÔ(¨Ñ.Ô.Ð.Ø�?Š?ÑÔ ¤Ò+Ð+Ø×ÒÑÔÐØŒ:˜ÒÐÝÔ3°DÑ9Ô9Ð9ð Ðr&   c                 óZ  — |                       |¦  «        }i }|D ]�}||vrŒ|                      |¦  «        }t          |t          ¦  «        st	          |¦  «        ‚||         }|dk    rd}n|d         }d|                      |¦  «        v }|                      |¦  «        }	|	||||ff||<   Œ‘|S )a®  Get the method, index_memo and compression parent for keys.

        Ghosts are omitted from the result.

        :param keys: An iterable of keys.
        :return: A dict of key:(index_memo, compression_parent, parents,
            record_details).
            index_memo
                opaque structure to pass to read_records to extract the raw
                data
            compression_parent
                Content that this record is built upon, may be None
            parents
                Logical parents of this node
            record_details
                extra information about the content which needs to be passed to
                Factory.parse_record
        rz   Nr   rä  )rç  r  rt  rË  rê  Úget_optionsÚget_position)
r/   r¼  r  rY  r6   ræ   r…   rŒ   rº   r·  s
             r'   r  z_KndxIndex.get_build_detailsK
  sÝ   € ð& ×(Ò(¨Ñ.Ô.ˆ
ØˆØð 	5ð 	5ˆCØ˜*Ð$Ð$ØØ—_’_ SÑ)Ô)ˆFÝ˜f¥cÑ*Ô*ð (Ý Ñ'Ô'Ð'Ø  ”oˆGØ˜Ò#Ð#Ø%)Ð"Ð"à%,¨Q¤ZÐ"Ø ×!1Ò!1°#Ñ!6Ô!6Ð6ˆEØ×*Ò*¨3Ñ/Ô/ˆJØ%Ð'9Ø" V¨U Oð5ˆF�3‰KˆKàˆr&   c                 ód   — |                       |¦  «        }d|v rdS d|v rdS t          | |¦  «        ‚)ú+Return compression method of specified key.ræ  rz   rå  r›   )rK  rE   )r/   r6   rG   s      r'   r  z_KndxIndex.get_methodq
  sE   € à×"Ò" 3Ñ'Ô'ˆØ˜'Ð!Ð!Ø�:Ø˜gÐ%Ð%Ø�<å(¨¨wÑ7Ô7Ð7r&   c                 óÚ   — |                       |¦  «        \  }}|                      |g¦  «         	 | j        |         d         |         d         S # t          $ r t	          || ¦  «        ‚w xY w)úIReturn a list representing options.

        e.g. ['foo', 'bar']
        r   r   )Ú
_split_keyr)  r*  r  r   )r/   r6   ru  Úsuffixs       r'   rK  z_KndxIndex.get_options{
  s|   € ð
 Ÿš¨Ñ-Ô-‰ˆ�Ø×Ò˜V˜HÑ%Ô%Ð%ð	0ØÔ# FÔ+¨AÔ.¨vÔ6°qÔ9Ð9øÝð 	0ð 	0ð 	0Ý$ S¨$Ñ/Ô/Ð/ð	0øøøs   °A ÁA*c                 óú  ‡	‡
— d„ |D ¦   «         }|                       |¦  «         i }i Š	t          ¦   «         }t          |¦  «        }|r²|                     ¦   «         }|‰	v rŒ|dd…         Š
	 | j        ‰
         d         |d                  d         }t          ˆ
fd„|D ¦   «         ¦  «        }|‰	|<   |                     ˆ	fd„|D ¦   «         ¦  «         n%# t          $ r |                     |¦  «         Y nw xY w|°²‰	|fS )ú&See CombinedGraphIndex.find_ancestry()c                 ó"   — h | ]}|d d…         ’ŒS rr  r%   r±   s     r'   ú	<setcomp>z+_KndxIndex.find_ancestry.<locals>.<setcomp>‰
  ó    € Ð-Ð-Ð- �C˜˜˜”HÐ-Ð-Ð-r&   Nry   r   r®  c                 ó   •— g | ]}‰|fz   ‘Œ	S r%   r%   ©r²   rR  ru  s     €r'   râ   z,_KndxIndex.find_ancestry.<locals>.<listcomp>›
  s6   ø€ ð %Cð %Cð %CØ)/ð &,¨v¨iÑ%7ð %Cð %Cð %Cr&   c                 ó   •— g | ]}|‰v¯|‘Œ	S r%   r%   )r²   Úpr  s     €r'   râ   z,_KndxIndex.find_ancestry.<locals>.<listcomp>ž
  s-   ø€ ð %=ð %=ð %=¨1Ø()°Ð(;Ð(;ð &'Ø(;Ð(;Ð(;r&   )	r)  r¸  r  r  r*  rÞ   rm  r  r¹  )r/   r¼  ÚprefixesrY  rõ  Úpending_keysr6   Úsuffix_parentsr;  r  ru  s            @@r'   Úfind_ancestryz_KndxIndex.find_ancestry‡
  s}  øø€ à-Ð-¨Ð-Ñ-Ô-ˆØ×Ò˜HÑ%Ô%Ð%ØˆØˆ
Ý‘u”uˆÝ˜D‘z”zˆð ð 	>Ø×"Ò"Ñ$Ô$ˆCØ�jÐ Ð ØØ˜˜"˜”XˆFð	>Ø!%Ô!1°&Ô!9¸!Ô!<¸SÀ¼WÔ!EÀaÔ!H�õ $ð %Cð %Cð %Cð %CØ3Að%Cñ %Cô %Cñ Dô D�à"-�
˜3‘Ø×#Ò#ð %=ð %=ð %=ð %=°ð %=ñ %=ô %=ñ >ô >ð >ð >øõ ð &ð &ð &Ø× Ò  Ñ%Ô%Ð%Ð%Ð%ð&øøøð ð 	>ð ˜<Ð'Ð's   Á+%C ÃC4Ã3C4c                 ó  ‡— d„ |D ¦   «         }|                       |¦  «         i }|D ]`}|dd…         Š	 | j        ‰         d         |d                  d         }t          ˆfd„|D ¦   «         ¦  «        ||<   ŒQ# t          $ r Y Œ]w xY w|S )úÇGet a map of the parents of keys.

        :param keys: The keys to look up parents for.
        :return: A mapping from keys to parents. Absent keys are absent from
            the mapping.
        c                 ó"   — h | ]}|d d…         ’ŒS rr  r%   r±   s     r'   rV  z,_KndxIndex.get_parent_map.<locals>.<setcomp>¬
  rW  r&   Nry   r   r®  c              3   ó$   •K  — | ]
}‰|fz   V — Œd S r+   r%   rY  s     €r'   r³   z,_KndxIndex.get_parent_map.<locals>.<genexpr>¶
  s>   øè è € ð $>ð $>Ø$*ð %+¨f¨YÑ$6ð $>ð $>ð $>ð $>ð $>ð $>r&   )r)  r*  rÞ   r  )r/   r¼  r\  rY  r6   r^  ru  s         @r'   rç  z_KndxIndex.get_parent_map¢
  sØ   ø€ ð .Ð-¨Ð-Ñ-Ô-ˆØ×Ò˜HÑ%Ô%Ð%ØˆØð 	>ð 	>ˆCØ˜˜"˜”XˆFð>Ø!%Ô!1°&Ô!9¸!Ô!<¸SÀ¼WÔ!EÀaÔ!H�õ $ð $>ð $>ð $>ð $>Ø.<ð$>ñ $>ô $>ñ >ô >��s‘�øõ ð ð ð Ø�ðøøøð
 ˆs   ´%A8Á8
BÂBc                 ó²   — |                       |¦  «        \  }}|                      |g¦  «         | j        |         d         |         }||d         |d         fS )z¥Return details needed to access the version.

        :return: a tuple (key, data position, size) to hand to the access
            logic to get the record.
        r   r   rZ   )rQ  r)  r*  )r/   r6   ru  rR  Úentrys        r'   rL  z_KndxIndex.get_positionº
  s[   € ð Ÿš¨Ñ-Ô-‰ˆ�Ø×Ò˜V˜HÑ%Ô%Ð%ØÔ  Ô(¨Ô+¨FÔ3ˆØ�E˜!”H˜e AœhÐ&Ð&r&   c                 óä   — t          ¦   «         }|                     | j        ¦  «         |                     |¦  «         |                     d¦  «         | j                             ||d¬¦  «         dS )zInitialize an index.r   T)Úcreate_parent_dirN)r   r£  r?  Ú
writelinesÚseekr  Úput_file_non_atomic)r/   r0  Úextra_linesÚsios       r'   r.  z_KndxIndex._init_indexÇ
  su   € å‰iŒiˆØ�	Š	�$”+ÑÔÐØ�Š�{Ñ#Ô#Ð#Ø�Š�‰ŒˆØŒ×+Ò+¨D°#Ø>Bð 	,ñ 	Dô 	Dð 	Dð 	Dð 	Dr&   c                 óÐ  ‡ — t          ¦   «         }t          ‰ j        t          ¦  «        rdg}not          ¦   «         }‰ j                             ¦   «         D ]9}t          j                             |¦  «        \  }}| 	                    |¦  «         Œ:ˆ fd„|D ¦   «         }‰  
                    |¦  «         |D ]1}‰ j        |         d         D ]}| 	                    ||fz   ¦  «         ŒŒ2|S )úOGet all the keys in the collection.

        The keys are not ordered.
        r%   c                 óD   •— g | ]}‰j                              |¦  «        ‘ŒS r%   )r  Úunmap)r²   r0  r/   s     €r'   râ   z#_KndxIndex.keys.<locals>.<listcomp>â
  s)   ø€ ÐFÐFÐF°T˜œ×*Ò*¨4Ñ0Ô0ÐFÐFÐFr&   r   )r¸  rt  r  r   r  Úiter_files_recursiveÚosr0  Úsplitextr¹  r)  r*  )	r/   rY  r\  ÚrelpathsÚquoted_relpathr0  Úextru  rR  s	   `        r'   r¼  z_KndxIndex.keysÓ
  s   ø€ õ
 ‘”ˆõ �d”l¥NÑ3Ô3ð 	GØ�tˆHˆHå‘u”uˆHØ"&¤/×"FÒ"FÑ"HÔ"Hð #ð #�ÝœG×,Ò,¨^Ñ<Ô<‘	��cØ—’˜TÑ"Ô"Ð"Ð"ØFÐFÐFÐF¸XÐFÑFÔFˆHØ×Ò˜HÑ%Ô%Ð%Øð 	/ð 	/ˆFØÔ*¨6Ô2°1Ô5ð /ð /�Ø—
’
˜6 V IÑ-Ñ.Ô.Ð.Ð.ð/àˆr&   c                 ó  — |                       ¦   «          |D ]î}|| j        vrãi | _        g | _        || _        	 | j                             |¦  «        dz   }| j                             |¦  «        5 }t          | |¦  «         ddd¦  «         n# 1 swxY w Y   | j        | j        f| j        |<   | `| `| `Œ�# t          $ rD i g f| j        |<   t          | j        t          ¦  «        r|                      |¦  «         | `| `| `Y Œêw xY wŒïdS )zLoad the indices for prefixes.r   N)rE  r*  Ú_cacheÚ_historyÚ	_filenamer  rß  r  r¾   Ú
_load_datar   rt  r   r.  )r/   r\  ru  r0  r@  s        r'   r)  z_KndxIndex._load_prefixesé
  s~  € à×ÒÑÔÐØð 	&ð 	&ˆFØ˜TÔ-Ð-Ð-à �”Ø "�”Ø!'�”ð&Øœ<×+Ò+¨FÑ3Ô3°gÑ=�DØœ×,Ò,¨TÑ2Ô2ð -°bõ # 4¨Ñ,Ô,Ð,ð-ð -ð -ñ -ô -ð -ð -ð -ð -ð -ð -øøøð -ð -ð -ð -ð 15´¸T¼]Ð/K�DÔ$ VÑ,Ø˜Ø˜Ø˜˜øÝ!ð &ð &ð &Ø02°B¨x�DÔ$ VÑ,Ý! $¤,µÑ?Ô?ð /à×(Ò(¨Ñ.Ô.Ð.Ø˜Ø˜Ø˜˜˜ð&øøøð .ð	&ð 	&s6   ¸7B4Á/BÂ B4ÂB	ÂB4ÂB	ÂB4Â4ADÄDc                 ó†   — i }|D ];}|                      |dd…         g ¦  «        }|                     |d         ¦  «         Œ<|S )z,Turn keys into a dict of prefix:suffix_list.Nry   )rI  rX  )r/   r¼  rY  r6   Úprefix_keyss        r'   Ú_partition_keysz_KndxIndex._partition_keys  sS   € àˆØð 	(ð 	(ˆCØ ×+Ò+¨C°°°¬H°bÑ9Ô9ˆKØ×Ò˜s 2œwÑ'Ô'Ð'Ð'Øˆr&   c                 ón  — |sdS g }|d         dd…         }| j         |         d         }|D ]u}|dd…         |k    rt          d|z  ¦  «        ‚|d         |v r+|                     d||d                  d         z  ¦  «         ŒW|                     d|d         z   ¦  «         Œvd	                     |¦  «        S )
a  Dictionary compress keys.

        :param keys: The keys to generate references to.
        :return: A string representation of keys. keys which are present are
            dictionary compressed, and others are emitted as fulltext with a
            '.' prefix.
        r&   r   Nry   zmismatched prefixes for %rr  r:  ó   .rµ   )r*  r(  rX  ra   )r/   r¼  Úresult_listru  rJ  r6   s         r'   r+  z_KndxIndex._dictionary_compress  sÚ   € ð ð 	Ø�3ØˆØ�a”˜˜"˜”ˆØÔ  Ô(¨Ô+ˆØð 		3ð 		3ˆCØ�3�B�3Œx˜6Ò!Ð!å Ð!=ÀÑ!DÑEÔEÐEØ�2Œw˜%ÐÐà×"Ò" 5¨5°°R´¬>¸!Ô+<Ñ#<Ñ=Ô=Ð=Ð=ð ×"Ò" 4¨#¨b¬'¡>Ñ2Ô2Ð2Ð2Ø�yŠy˜Ñ%Ô%Ð%r&   c                 ó’   — i | _         |                      ¦   «         | _        |                      ¦   «         }|r	d| _        d S d| _        d S )NrG  r<  )r*  r  rD  r  rH  )r/   r"  s     r'   r   z_KndxIndex._reset_cache(  sL   € ð ˆÔØ—o’oÑ'Ô'ˆŒØ×)Ò)Ñ+Ô+ˆØð 	ØˆDŒJˆJˆJàˆDŒJˆJˆJr&   c                 ó:   ‡— ˆfd„}|                      |¬¦  «        S )áu  Figure out an optimal order to read the records for the given keys.

        Sort keys, grouped by index and sorted by position.

        :param keys: A list of keys whose records we want to read. This will be
            sorted 'in-place'.
        :param positions: A dict, such as the one returned by
            _get_components_positions()
        :return: None
        c                 óP   •— ‰|          d         }|d         d d…         |d         fS )Nr   r   ry   r%   )r6   r·  r½  s     €r'   Úget_sort_keyz1_KndxIndex._sort_keys_by_io.<locals>.get_sort_key>  s/   ø€ Ø" 3œ¨Ô*ˆJð
 ˜a”=  " Ô% z°!¤}Ð4Ð4r&   r>  ©r?  )r/   r¼  r½  r†  s     ` r'   rm  z_KndxIndex._sort_keys_by_io3  s2   ø€ ð	5ð 	5ð 	5ð 	5ð 	5ð �yŠy˜\ˆyÑ*Ô*Ð*r&   c                 óx   — t          |t          ¦  «        r|dd…         |dd…         fS |dd…         |d         fS )z#Split key into a prefix and suffix.Nry   r  rû  s     r'   rQ  z_KndxIndex._split_keyI  sH   € õ �c�5Ñ!Ô!ð 	&Ø�s˜�s”8˜S   œXÐ%Ð%Ø�3�B�3Œx˜˜RœÐ Ð r&   N©FF)!r!   r"   r#   rH   r?  r,   rí  r6  r™  r,  rA  rE  r×  r  r  rK  r_  rç  rL  rž  Ú_has_key_from_parent_mapÚ__contains__r.  r¼  r)  Ú_missing_keys_from_parent_maprõ  r~  r+  r   rm  rÁ  rQ  r%   r&   r'   r�  r�  Š	  s¢  € € € € € ð8ð 8ðt %€Fðð ð ð6ð 6ð 6ð 6ðp?ð ?ð ?ðHð Hð Hð$ð $ð $ð<?ð ?ð ?ð ð  ð  ð:ð :ð :ð$ð $ð $ðL8ð 8ð 8ð
0ð 
0ð 
0ð(ð (ð (ð6ð ð ð0	'ð 	'ð 	'ð Ô6€Là,.ð Dð Dð Dð Dðð ð ð,&ð &ð &ð8 Ô;€Lðð ð ð&ð &ð &ð2	ð 	ð 	ð+ð +ð +ð( 2Ðð!ð !ð !ð !ð !r&   r�  c                   ó¾   — e Zd ZdZ	 	 dd„Zd„ Z	 	 dd„Zd„ Zd	„ Zd
„ Z	d„ Z
d„ Zd„ Zd„ Zdd„Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zej        Zd„ Zej        Zd„ Zd„ ZeZdS )r¥  z1A KnitVersionedFiles index layered on GraphIndex.FTNc                 óä   — || _         || _        || _        || _        |r|st	          | d¦  «        ‚|| _        || _        t          ¦   «         | _        |rt          ¦   «         | _
        dS d| _
        dS )an  Construct a KnitGraphIndex on a graph_index.

        :param graph_index: An implementation of breezy.index.GraphIndex.
        :param is_locked: A callback to check whether the object should answer
            queries.
        :param deltas: Allow delta-compressed records.
        :param parents: If True, record knits parents, if not do not record
            parents.
        :param add_callback: If not None, allow additions to the index and call
            this callback with a list of added GraphIndex nodes:
            [(node, value, node_refs), ...]
        :param is_locked: A callback, returns True if the index is locked and
            thus usable.
        :param track_external_parent_refs: If True, record all external parent
            references parents from added records.  These can be retrieved
            later by calling get_missing_parents().
        z4Cannot do delta compression without parent tracking.N)Ú_add_callbackÚ_graph_indexÚ_deltasÚ_parentsr)   r[  r  r¸  Ú_missing_compression_parentsr   Ú_key_dependencies)r/   r­  r#  r›  r…   rœ  Útrack_external_parent_refss          r'   r,   z_KnitGraphIndex.__init__T  sŽ   € ð& *ˆÔØ'ˆÔØˆŒØˆŒØð 	2˜'ð 	2õ ˜dð %1ñ 2ô 2ð 2à ˆŒØ#ˆŒÝ,/©E¬EˆÔ)Ø%ð 	*Ý%-¡Z¤ZˆDÔ"Ð"Ð"à%)ˆDÔ"Ð"Ð"r&   c                 óL   — d                      | j        j        | j        ¦  «        S )Nz{}({!r}))r    rÍ  r!   r�  rë   s    r'   rÎ  z_KnitGraphIndex.__repr__x  s    € Ø× Ò  ¤Ô!8¸$Ô:KÑLÔLÐLr&   c                 ó  — | j         st          j        | ¦  «        ‚i }t          ¦   «         }| j        }|D ]È\  }}}	}
| j        r't          |
¦  «        }
|�|                     ||
¦  «         |	\  }}}d|v rd}nd}|d||fz  z  }| j        sd|v rt          | d¦  «        ‚| j        r=| j        r2d|v r)|
|
d         ff}|r| 
                    |
d         ¦  «         n|
d	f}n|
f}n|
rt          | d
¦  «        ‚d	}||f||<   ŒÉ|s¶|                      |¦  «        }|D ]ž\  }}}}|dd…         }
t                               ||         ¦  «        }|d         dd…         }|dd…         ||         d         dd…         k    s|
|k    r2t                               |¦  «        }t          | d||f›d|›�¦  «        ‚||= ŒŸg }| j        r6|                     ¦   «         D ] \  }\  }}|                     |||f¦  «         Œ!n4|                     ¦   «         D ]\  }\  }}|                     ||f¦  «         Œ |                       |¦  «         |r/|                     |¦  «         | j                             |¦  «         | j                             |¦  «         dS )aY  Add multiple records to the index.

        This function does not insert data into the Immutable GraphIndex
        backing the KnitGraphIndex, instead it prepares data for insertion by
        the caller and checks that it is safe to insert then calls
        self._add_callback with the prepared GraphIndex nodes.

        :param records: a list of tuples:
                         (key, options, access_memo, parents).
        :param random_id: If True the ids being added were randomly generated
            and no check for existence will be performed.
        :param missing_compression_parents: If True the records being added are
            only compressed against texts already in the index (or inside
            records). If False the records all refer to unavailable texts (or
            texts inside records) as compression parents.
        Nrä  r´   rµ   s   %d %drå  z+attempt to add line-delta in non-delta knitr   r%   z5attempt to add node with parents in parentless index.r   z%inconsistent details in add_records: ú )r�  r   ÚReadOnlyErrorr¸  r”  r’  rÞ   Úadd_referencesr‘  r)   r¹  Ú_get_entriesÚstatic_tupleÚ	as_tuplesr  rX  r.  r“  r-  )r/   rF  rÝ  r†  r¼  Úcompression_parentsÚkey_dependenciesr6   rG   rù  r…   r   r4  rg   ÚvalueÚ	node_refsÚpresent_nodesÚpassedÚpassed_parentsrY  s                       r'   rí  z_KnitGraphIndex.add_records{  s_  € ð$ Ô!ð 	-ÝÔ& tÑ,Ô,Ð,ð ˆÝ!™eœeÐØÔ1ÐØ4;ð 	+ð 	+Ñ0ˆS�'˜;¨ØŒ}ð BÝ ™.œ.�Ø#Ð/Ø$×3Ò3°C¸ÑAÔAÐAØ*ÑˆE�3˜Ø˜GÐ#Ð#Ø��à�Ø�X  d Ñ+Ñ+ˆEØ”<ð MØ  GÐ+Ð+Ý%ØÐKñMô Mð MàŒ}ð Ø”<ð ,Ø$¨Ð/Ð/Ø%,¨w°q¬z¨mÐ$<˜	Ø6ð @Ø/×3Ò3°G¸A´JÑ?Ô?Ð?øà%,¨b M˜	˜	à!( �I�Iàð >Ý% dð -=ñ >ô >ð >à�	Ø 	Ð*ˆD�‰IˆIàð 	Ø ×-Ò-¨dÑ3Ô3ˆMØ2?ð 
ð 
Ñ.�˜˜U IØ# B Q Bœ-�å%×/Ò/°°S´	Ñ:Ô:�Ø!'¨¤¨2¨A¨2¤�Ø˜!˜A˜#”J $ s¤)¨A¤,¨q°¨sÔ"3Ò3Ð3Ø" nÒ4Ð4Ý ,× 6Ò 6°yÑ AÔ A�IÝ% d dØ49¸9Ð3EÐ3EÐ3EÀvÀvð-Oñ Pô Pð Pà˜�I�IØˆØŒ=ð 	,Ø+/¯:ª:©<¬<ð 7ð 7Ñ'�Ñ'�e˜YØ—’˜s E¨9Ð5Ñ6Ô6Ð6Ð6ð7ð ,0¯:ª:©<¬<ð ,ð ,Ñ'�Ñ'�e˜YØ—’˜s E˜lÑ+Ô+Ð+Ð+Ø×Ò˜6Ñ"Ô"Ð"Ø&ð 	Jð  ×1Ò1°$Ñ7Ô7Ð7ØÔ-×4Ò4Ð5HÑIÔIÐIàÔ)×;Ò;¸DÑAÔAÐAÐAÐAr&   c                 ó^  — | j         rX|                     d¬¦  «        }|                     |                      |¦  «        ¦  «         | j                             |¦  «         | j        �D|                     ¦   «         D ]1}| j                             |d         |d         d         ¦  «         Œ0dS dS )a  Inform this _KnitGraphIndex that there is an unvalidated index.

        This allows this _KnitGraphIndex to keep track of any missing
        compression parents we may want to have filled in to make those
        indices valid.

        :param graph_index: A GraphIndex
        r   )Úref_list_numNrZ   r   )	r‘  Úexternal_referencesr.  rç  r“  r-  r”  Úiter_all_entriesrš  )r/   r­  Únew_missingÚnodes       r'   r6  z&_KnitGraphIndex.scan_unvalidated_indexÖ  sÂ   € ð Œ<ð 	BØ%×9Ò9ÀqÐ9ÑIÔIˆKØ×)Ò)¨$×*=Ò*=¸kÑ*JÔ*JÑKÔKÐKØÔ-×4Ò4°[ÑAÔAÐAØÔ!Ð-ð $×4Ò4Ñ6Ô6ð Kð K�ØÔ&×5Ò5°d¸1´g¸tÀA¼wÀq¼zÑJÔJÐJÐJð	 .Ð-ðKð Kr&   c                 ó*   — t          | j        ¦  «        S )zÎReturn the keys of missing compression parents.

        Missing compression parents occur when a record stream was missing
        basis texts, or a index was scanned that had missing basis texts.
        )r  r“  rë   s    r'   r™  z/_KnitGraphIndex.get_missing_compression_parentsé  s   € õ ˜Ô:Ñ;Ô;Ð;r&   c                 óÖ   — | j                              |                      | j                              ¦   «         ¦  «        ¦  «         t	          | j                              ¦   «         ¦  «        S )z#Return the keys of missing parents.)r”  Úsatisfy_refs_for_keysrç  Úget_unsatisfied_refsr  rë   s    r'   Úget_missing_parentsz#_KnitGraphIndex.get_missing_parentsñ  s_   € ð
 	Ô×4Ò4Ø×Ò Ô 6× KÒ KÑ MÔ MÑNÔNñ	Pô 	Pð 	På˜Ô/×DÒDÑFÔFÑGÔGÐGr&   c                 óV   — |                       ¦   «         st          j        | ¦  «        ‚dS )z!raise if reads are not permitted.N©r  r   rC  rë   s    r'   rE  z_KnitGraphIndex._check_readú  ó/   € à�ŠÑ Ô ð 	/ÝÔ(¨Ñ.Ô.Ð.ð	/ð 	/r&   c                 óV   — |                       ¦   «         st          j        | ¦  «        ‚dS )z#Assert if writes are not permitted.Nr±  rë   s    r'   r×  z_KnitGraphIndex._check_write_okÿ  r²  r&   c                 ó€   — |d         d         }|sd S t          |¦  «        dk    rt          d|z  ¦  «        ‚|d         S )NrZ   r   z Too many compression parents: %rr   )r  rk  )r/   Úan_entryrž  s      r'   Ú_compression_parentz#_KnitGraphIndex._compression_parent  s\   € ð ' qœk¨!œnÐØ"ð 	Ø�4ÝÐ"Ñ#Ô# qÒ(Ð(Ý Ø2Ð5HÑHñJô Jð Jà" 1Ô%Ð%r&   c                 óX  — |                       ¦   «          i }|                      |d¦  «        }|D ]z}|d         }| j        sd}n|d         d         }| j        sd}n|                      |¦  «        }|d         dd…         dk    }|rd	}	nd
}	|                      |¦  «        |||	|ff||<   Œ{|S )a¶  Get the method, index_memo and compression parent for version_ids.

        Ghosts are omitted from the result.

        :param keys: An iterable of keys.
        :return: A dict of key:
            (index_memo, compression_parent, parents, record_details).
            index_memo
                opaque structure to pass to read_records to extract the raw
                data
            compression_parent
                Content that this record is built upon, may be None
            parents
                Logical parents of this node
            record_details
                extra information about the content which needs to be passed to
                Factory.parse_record
        Fr   r%   rZ   r   Nr   r´   r›   rz   )rE  r›  r’  r‘  r¶  Ú_node_to_position)
r/   r¼  rY  Úentriesre  r6   r…   Úcompression_parent_keyrº   ræ   s
             r'   r  z!_KnitGraphIndex.get_build_details  sé   € ð& 	×ÒÑÔÐØˆØ×#Ò# D¨%Ñ0Ô0ˆØð 	,ð 	,ˆEØ˜”(ˆCØ”=ð &Ø��à œ( 1œ+�Ø”<ð IØ)-Ð&Ð&à)-×)AÒ)AÀ%Ñ)HÔ)HÐ&Ø˜1”X˜a ˜c”] dÒ*ˆEØ%ð $Ø%��à#�Ø×1Ò1°%Ñ8Ô8Ø1°7Ø" E˜?ð,ˆF�3‰KˆKð ˆr&   c              #   óê  K  — t          |¦  «        }t          ¦   «         }| j        r=| j                             |¦  «        D ]!}|V — |                     |d         ¦  «         Œ"nR| j                             |¦  «        D ]7}|d         |d         |d         dfV — |                     |d         ¦  «         Œ8|r9|                     |¦  «        }|r$t          |                     ¦   «         | ¦  «        ‚dS dS )zYGet the entries for keys.

        :param keys: An iterable of index key tuples.
        r   r   r   r%   N)r¸  r’  r�  Úiter_entriesr¹  r  r   r  )r/   r¼  Úcheck_presentÚ
found_keysrª  rõ  s         r'   r›  z_KnitGraphIndex._get_entries9  s   è è € õ
 �4‰yŒyˆÝ‘U”Uˆ
ØŒ=ð 	(ØÔ)×6Ò6°tÑ<Ô<ð (ð (�Ø�
�
�
Ø—’˜t AœwÑ'Ô'Ð'Ð'ð(ð
 Ô)×6Ò6°tÑ<Ô<ð (ð (�Ø˜1”g˜t Aœw¨¨Q¬°Ð3Ð3Ð3Ð3Ø—’˜t AœwÑ'Ô'Ð'Ð'Øð 	CØŸ?š?¨:Ñ6Ô6ˆLØð CÝ(¨×)9Ò)9Ñ);Ô);¸TÑBÔBÐBð	Cð 	CðCð Cr&   c                 óR   — |                       |                      |¦  «        ¦  «        S )rN  )Ú_get_methodÚ	_get_noderû  s     r'   r  z_KnitGraphIndex.get_methodN  s"   € à×Ò §¢¨sÑ 3Ô 3Ñ4Ô4Ð4r&   c                 óF   — | j         sdS |                      |¦  «        rdS dS )Nrz   r›   )r‘  r¶  )r/   rª  s     r'   rÀ  z_KnitGraphIndex._get_methodR  s1   € ØŒ|ð 	Ø�:Ø×#Ò# DÑ)Ô)ð 	Ø�<à�:r&   c                 ó’   — 	 t          |                      |g¦  «        ¦  «        d         S # t          $ r t          || ¦  «        ‚w xY w)Nr   )r  r›  Ú
IndexErrorr   rû  s     r'   rÁ  z_KnitGraphIndex._get_nodeZ  sU   € ð	0Ý˜×)Ò)¨3¨%Ñ0Ô0Ñ1Ô1°!Ô4Ð4øÝð 	0ð 	0ð 	0Ý$ S¨$Ñ/Ô/Ð/ð	0øøøs	   ‚(+ «Ac                 óÔ   — |                       |¦  «        }|                      |¦  «                             d¦  «        g}|d         dd…         dk    r|                     d¦  «         |S )rP  r¶   r   r   r   r´   rä  )rÁ  rÀ  r·   rX  )r/   r6   rª  rG   s       r'   rK  z_KnitGraphIndex.get_options`  sg   € ð
 �~Š~˜cÑ"Ô"ˆØ×#Ò# DÑ)Ô)×0Ò0°Ñ9Ô9Ð:ˆØ�Œ7�1�Q�3Œ<˜4ÒÐØ�NŠN˜9Ñ%Ô%Ð%Øˆr&   c                 ó8   — | j                              |d¦  «        S )rT  r   )r�  r_  r+  s     r'   r_  z_KnitGraphIndex.find_ancestryk  s   € àÔ ×.Ò.¨t°QÑ7Ô7Ð7r&   c                 óÄ   — |                       ¦   «          |                      |¦  «        }i }| j        r|D ]}|d         d         ||d         <   Œn|D ]}d||d         <   Œ|S )ra  rZ   r   r   N)rE  r›  r’  )r/   r¼  ÚnodesrY  rª  s        r'   rç  z_KnitGraphIndex.get_parent_mapo  sˆ   € ð 	×ÒÑÔÐØ×!Ò! $Ñ'Ô'ˆØˆØŒ=ð 	'Øð -ð -�Ø"& q¤'¨!¤*��t˜A”w‘�ð-ð ð 'ð '�Ø"&��t˜A”w‘�Øˆr&   c                 óV   — |                       |¦  «        }|                      |¦  «        S )z§Return details needed to access the version.

        :return: a tuple (index, data position, size) to hand to the access
            logic to get the record.
        )rÁ  r¸  )r/   r6   rª  s      r'   rL  z_KnitGraphIndex.get_position�  s)   € ð �~Š~˜cÑ"Ô"ˆØ×%Ò% dÑ+Ô+Ð+r&   c                 óp   — |                       ¦   «          d„ | j                             ¦   «         D ¦   «         S )rn  c                 ó   — g | ]
}|d          ‘ŒS rh  r%   )r²   rª  s     r'   râ   z(_KnitGraphIndex.keys.<locals>.<listcomp>’  s   € ÐIÐIÐI˜D��Q”ÐIÐIÐIr&   )rE  r�  r¨  rë   s    r'   r¼  z_KnitGraphIndex.keysŒ  s9   € ð
 	×ÒÑÔÐØIÐI DÔ$5×$FÒ$FÑ$HÔ$HÐIÑIÔIÐIr&   c                 óª   — |d         dd…                               d¦  «        }|d         t          |d         ¦  «        t          |d         ¦  «        fS )z+Convert an index value to position details.r   r   Nrµ   r   )rß   rN  )r/   rª  Úbitss      r'   r¸  z!_KnitGraphIndex._node_to_position–  sF   € à�AŒw�q�r�rŒ{× Ò  Ñ&Ô&ˆØ�AŒw�˜D œG™œ¥c¨$¨q¬'¡l¤lÐ2Ð2r&   c                 ó:   ‡— ˆfd„}|                      |¬¦  «        S )r„  c                 ó    •— ‰|          d         S )Nr   r%   )r6   r½  s    €r'   Úget_index_memoz8_KnitGraphIndex._sort_keys_by_io.<locals>.get_index_memo¦  s   ø€ ð ˜S”> !Ô$Ð$r&   r>  r‡  )r/   r¼  r½  rÐ  s     ` r'   rm  z _KnitGraphIndex._sort_keys_by_io›  s2   ø€ ð	%ð 	%ð 	%ð 	%ð 	%ð �yŠy˜^ˆyÑ,Ô,Ð,r&   )FTNFr‰  rw  )r!   r"   r#   rH   r,   rÎ  rí  r6  r™  r¯  rE  r×  r¶  r  r›  r  rÀ  rÁ  rK  r_  rç  rL  rž  rŠ  r‹  r¼  rŒ  rõ  r¸  rm  rÁ  r%   r&   r'   r¥  r¥  Q  s¥  € € € € € Ø;Ð;àEIØ?Dð"*ð "*ð "*ð "*ðHMð Mð Mð .3Ø05ðYBð YBð YBð YBðvKð Kð Kð&<ð <ð <ðHð Hð Hð/ð /ð /ð
/ð /ð /ð
	&ð 	&ð 	&ð(ð (ð (ðTCð Cð Cð Cð*5ð 5ð 5ðð ð ð0ð 0ð 0ð	ð 	ð 	ð8ð 8ð 8ðð ð ð$,ð ,ð ,ð Ô6€LðJð Jð Jð Ô;€Lð3ð 3ð 3ð
-ð -ð -ð( 2ÐÐÐr&   r¥  c                   ó0   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ ZdS )r�  z!Access to records in .knit files.c                 ó"   — || _         || _        dS )zÇCreate a _KnitKeyAccess with transport and mapper.

        :param transport: The transport the access object is rooted at.
        :param mapper: The mapper used to map keys to .knit files.
        N)r  r  )r/   r	   r’  s      r'   r,   z_KnitKeyAccess.__init__µ  s   € ð $ˆŒØˆŒˆˆr&   c                 óŠ  — | j                              |¦  «        }	 | j                             |dz   d                     |¦  «        ¦  «        }nr# t
          j        $ r` | j                             t          j	        |¦  «        ¦  «         | j                             |dz   d                     |¦  «        ¦  «        }Y nw xY w|||fS )aí  Add raw knit bytes to a storage area.

        The data is spooled to the container writer in one bytes-record per
        raw data item.

        :param key: The key of the raw data segment
        :param size: The size of the raw data segment
        :param raw_data: A chunked bytestring containing the data.
        :return: opaque index memo to retrieve the record later.
            For _KnitKeyAccess the memo is (key, pos, length), where the key is
            the record key.
        r   r&   )
r  rß  r  r-  ra   r>  r   Úmkdirr   Údirname)r/   r6   rg   rz  r0  Úbases         r'   rì  z_KnitKeyAccess.add_raw_record¾  sÄ   € ð Œ|×Ò Ñ$Ô$ˆð	TØ”?×/Ò/°°w±ÀÇÂÈÑ@RÔ@RÑSÔSˆDˆDøÝÔ(ð 	Tð 	Tð 	TØŒO×!Ò!¥'¤/°$Ñ"7Ô"7Ñ8Ô8Ð8Ø”?×/Ò/°°w±ÀÇÂÈÑ@RÔ@RÑSÔSˆDˆDˆDð	Tøøøð
 �T˜4Ð Ð s   œ1A ÁA,B=Â<B=c                 ó*  — d                      |¦  «        }t          |t          ¦  «        st          dt	          |¦  «        z  ¦  «        ‚g }d}|D ]B\  }}||||z   …         g}|                     |                      |||¦  «        ¦  «         ||z  }ŒC|S )a  Add raw knit bytes to a storage area.

        The data is spooled to the container writer in one bytes-record per
        raw data item.

        :param sizes: An iterable of tuples containing the key and size of each
            raw data segment.
        :param raw_data: A chunked bytestring containing the data.
        :return: A list of memos to retrieve the record later. Each memo is an
            opaque index memo. For _KnitKeyAccess the memo is (key, pos,
            length), where the key is the record key.
        r&   rÛ  r   )ra   rt  rÖ   rk  rÜ  rX  rì  )r/   Ú	key_sizesrz  rY  r!  r6   rg   r  s           r'   Úadd_raw_recordsz_KnitKeyAccess.add_raw_recordsÕ  s´   € ð —8’8˜HÑ%Ô%ˆÝ˜(¥EÑ*Ô*ð 	DÝ Ø1µD¸±N´NÑBñDô Dð DàˆØˆð #ð 	ð 	‰IˆC�Ø$ V¨F°T©MÐ%9Ô:Ð;ˆLØ�MŠM˜$×-Ò-¨c°4¸ÑFÔFÑGÔGÐGØ�d‰NˆFˆFØˆr&   c                 ó   — dS )z^Flush pending writes on this access object.

        For .knit files this is a no-op.
        Nr%   rë   s    r'   rŠ  z_KnitKeyAccess.flushñ  s	   € ð
 	ˆr&   c              #   ó†  K  — g }d}|D ]T\  }}}||dd…         k    r|                      ||f¦  «         Œ,|�|                      ||f¦  «         |dd…         }||fg}ŒU|�|                      ||f¦  «         |D ]G\  }}	| j                             |¦  «        dz   }
| j                             |
|	¦  «        D ]	\  }}|V — Œ
ŒHdS )z×Get the raw bytes for a records.

        :param memos_for_retrieval: An iterable containing the access memo for
            retrieving the bytes.
        :return: An iterator over the bytes of the records.
        Nry   r   )rX  r  rß  r  Úreadv)r/   Úmemos_for_retrievalÚrequest_listsÚcurrent_prefixr6   r!  ÚlengthÚcurrent_listru  Úread_vectorr0  r4  r÷  s                r'   rÒ  z_KnitKeyAccess.get_raw_recordsø  s  è è € ð ˆØˆØ%8ð 	2ð 	2Ñ!ˆS�&˜&Ø  S b S¤Ò)Ð)Ø×#Ò# V¨VÐ$4Ñ5Ô5Ð5Ð5à!Ð-Ø!×(Ò(¨.¸,Ð)GÑHÔHÐHØ!$ S b S¤�Ø!'¨Ð 0Ð1��àÐ%Ø× Ò  .°,Ð!?Ñ@Ô@Ð@Ø#0ð 	ð 	ÑˆF�KØ”<×#Ò# FÑ+Ô+¨gÑ5ˆDØ!œ_×2Ò2°4¸ÑEÔEð ð ‘	��TØ�
�
�
�
ðð	ð 	r&   N)	r!   r"   r#   rH   r,   rì  rÙ  rŠ  rÒ  r%   r&   r'   r�  r�  ²  se   € € € € € Ø+Ð+ðð ð ð!ð !ð !ð.ð ð ð8ð ð ðð ð ð ð r&   r�  c                 ód   — t          | ¦  «        }t          |                     |¦  «        ¦  «        S )zÇAnnotate a knit with no cached annotations.

    This implementation is for knits with no cached annotations.
    It will work for knits with cached annotations, but this is not
    recommended.
    )r…  rÅ   r†  )r¦   Úrevision_idr‡  s      r'   Úannotate_knitrå    s-   € õ ˜tÑ$Ô$€IÝ�	×'Ò'¨Ñ4Ô4Ñ5Ô5Ð5r&   c                   óJ   — e Zd ZdZd„ Zd„ Zdd„Zd„ Zd„ Zd„ Z	d	„ Z
d
„ Zd„ ZdS )r…  z$Build up the annotations for a text.c                 óš   — t           j                             | |¦  «         i | _        i | _        i | _        i | _        i | _        i | _        d S r+   )	r   Ú	Annotatorr,   Ú_matching_blocksÚ_content_objectsÚ_num_compression_childrenÚ_pending_deltasÚ_pending_annotationÚ_all_build_details)r/   r{  s     r'   r,   z_KnitAnnotator.__init__!  sY   € ÝÔ×#Ò# D¨"Ñ-Ô-Ð-ð !#ˆÔð !#ˆÔà)+ˆÔ&ð  "ˆÔð $&ˆÔ à"$ˆÔÐÐr&   c                 ó  ‡ — |h}g }t          ¦   «         }d‰ j        |<   |�rÊ|}‰ j        j                             |¦  «        }‰ j                             |¦  «         t          ¦   «         }|                     ¦   «         D ]°\  }}|\  }}	}
}|
‰ j        |<   d‰ _	        | 
                    ||f¦  «         |                     ˆ fd„|
D ¦   «         ¦  «         |
r.|
D ]+}|‰ j        v r‰ j        |xx         dz  cc<   Œ!d‰ j        |<   Œ,|	r)|	‰ j        v r‰ j        |	xx         dz  cc<   Œ¦d‰ j        |	<   Œ±|                     |¦  «        }|r¢|D ]Ÿ}|‰ j        v r{|‰ j        v rr|                     |¦  «         ‰ j        |         }
|
D ]+}|‰ j        v r‰ j        |xx         dz  cc<   Œ!d‰ j        |<   Œ,|                     ˆ fd„|
D ¦   «         ¦  «         Œ†t          j        |‰ j        ¦  «        ‚|�°Ê|                     ¦   «          ||fS )aä  Get the graphs for building texts and annotations.

        The data you need for creating a full text may be different than the
        data you need to annotate that text. (At a minimum, you need both
        parents to create an annotation, but only need 1 parent to generate the
        fulltext.)

        :return: A list of (key, index_memo) records, suitable for
            passing to read_records_iter to start reading in the raw data from
            the pack file.
        r   Nc                 ó&   •— g | ]}|‰j         v¯|‘ŒS r%   ©rî  ©r²   r[  r/   s     €r'   râ   z3_KnitAnnotator._get_build_graph.<locals>.<listcomp>U  s3   ø€ ð  Eð  Eð  E aØ#$¨DÔ,CÐ#CÐ#Cð !"Ø#CÐ#CÐ#Cr&   c                 ó&   •— g | ]}|‰j         v¯|‘ŒS r%   rñ  rò  s     €r'   râ   z3_KnitAnnotator._get_build_graph.<locals>.<listcomp>p  s3   ø€ ð (Mð (Mð (M¨aØ+,°DÔ4KÐ+KÐ+Kð )*Ø+KÐ+KÐ+Kr&   )r¸  Ú_num_needed_childrenÚ_vfrÄ  r  rî  r-  r  Ú_parent_mapÚ_heads_providerrX  rë  r  Ú_text_cacher¹  r   r   Úreverse)r/   r6   r“  rF  Úann_keysÚthis_iterationr£   r#  r·  rŒ   r;  r;  r¸  Úmissing_versionss   `             r'   Ú_get_build_graphz_KnitAnnotator._get_build_graph7  sú  ø€ ð �%ˆØˆÝ‘5”5ˆØ)*ˆÔ! #Ñ&Øñ ,	Gà$ˆNØ œHœO×=Ò=¸nÑMÔMˆMØÔ#×*Ò*¨=Ñ9Ô9Ð9å‘e”eˆGØ -× 3Ò 3Ñ 5Ô 5ð Oð O‘��Wà#*ñ!�Ð/°ØØ(3�Ô  Ñ%Ø'+�Ô$Ø—’  ZÐ0Ñ1Ô1Ð1à—’ð  Eð  Eð  Eð  E¨;ð  Eñ  Eô  Eñ Fô Fð Fàð FØ&1ð Fð F˜
Ø%¨Ô)BÐBÐBØ Ô5°jÐAÐAÔAÀQÑFÐAÐAÑAÐAàDE˜DÔ5°jÑAÐAØ%ð OØ)¨TÔ-KÐKÐKØÔ6Ð7IÐJÐJÔJÈaÑOÐJÐJÑJÐJàMN˜Ô6Ð7IÑJøà-×8Ò8¸ÑGÔGÐØð GØ+ð Gð G�CØ˜dÔ.Ð.Ð.°3¸$Ô:JÐ3JÐ3Jð !Ÿš SÑ)Ô)Ð)Ø&*Ô&6°sÔ&;˜Ø*5ð Jð J˜JØ)¨TÔ-FÐFÐFØ $Ô 9¸*Ð EÐ EÔ EÈÑ JÐ EÐ EÑ EÐ EàHI Ô 9¸*Ñ EÐ EØŸšð (Mð (Mð (Mð (M°;ð (Mñ (Mô (Mñ Nô Nð Nð Nõ %Ô7¸¸T¼XÑFÔFÐFðY ñ ,	Gð^ 	�ŠÑÔÐØ˜Ð Ð r&   Nc              #   ó’  K  — t          | j        j        ¦  «        dk    r*t          j                             | ||¬¦  «        E d {V —† d S 	 	 |                      |¦  «        \  }}t          |                      |¦  «        ¦  «        D ]C\  }\  }}}|�1| 	                    t          d¦  «        |t          |¦  «        ¦  «         |||fV — ŒD|D ]%}| j        |         }t          |¦  «        }|||fV — Œ&d S # t          j        $ rB}	| j        j                             |	¦  «         | j                             ¦   «          Y d }	~	nd }	~	ww xY wŒþ)Nr   )r¥  TÚ
annotating)r  rõ  rÈ  r   rè  Ú_get_needed_textsrý  rŸ  Ú_extract_textsr-  r¡  rø  r§  rC  rÅ  rD  rî  Úclear)
r/   r6   r¥  rF  rú  ÚidxÚsub_keyr`   rA  r)  s
             r'   r   z _KnitAnnotator._get_needed_textsy  s�  è è € åˆtŒxÔ/Ñ0Ô0°1Ò4Ð4åÔ)×;Ò;¸DÀ#È"Ð;ÑMÔMÐMÐMÐMÐMÐMÐMÐMØˆFð	0ð0Ø$(×$9Ò$9¸#Ñ$>Ô$>Ñ!�˜Ý7@Ø×+Ò+¨GÑ4Ô4ñ86ô 86ð 3ð 3Ñ3�CÑ3˜' 4¨à�~ØŸ	š	¥'¨,Ñ"7Ô"7¸½cÀ'¹l¼lÑKÔKÐKØ! 4¨Ð2Ð2Ð2Ð2Ð2Ø'ð 3ð 3�GØÔ+¨GÔ4�DÝ # D¡	¤	�IØ! 4¨Ð2Ð2Ð2Ð2Ð2Ø�øÝÔ.ð 0ð 0ð 0Ø”Ô ×0Ò0°Ñ3Ô3Ð3àÔ'×-Ò-Ñ/Ô/Ð/Ð/Ð/Ð/Ð/Ð/øøøøð0øøøð	0s   ÁB&C4 Ã4EÄ8E Å Ec                 óŠ   — | j         |         }t          t                               |||¦  «        ¦  «        }|| j        ||f<   d S r+   )rø  r  ré   r  ré  )r/   r6   rŒ   rt   r}   Úparent_linesÚblockss          r'   Ú_cache_delta_blocksz"_KnitAnnotator._cache_delta_blocks‘  sQ   € ØÔ'Ð(:Ô;ˆÝ•k×7Ò7Ø�< ñ(ô (ñ )ô )ˆà;AˆÔ˜sÐ$6Ð7Ñ8Ð8Ð8r&   c                 ó¬  — d }|rÉ|| j         vr4| j                             |g ¦  «                             ||||f¦  «         d S | j        |         }|dz  }|dk    r5| j                              |¦  «        }| j                             |¦  «         n|| j        |<   | j         |         }| j        j                             ||||d¬¦  «        \  }	}n%| j        j                             |||d ¦  «        \  }	}
| j         	                    |d¦  «        dk    r
|	| j         |<   |	 
                    ¦   «         }|| j        |<   |�|                      ||||¦  «         |S )Nr   r   Tr÷  )rê  rì  rI  rX  rë  r  rõ  rÇ  r~   r¾   r`   rø  r  )r/   r6   r;  rŒ   r:  r;  rt   Únumr<  r7   r—   r}   s               r'   Ú_expand_recordz_KnitAnnotator._expand_record—  s’  € àˆØð 	3Ø!¨Ô)>Ð>Ð>àÔ$×/Ò/Ð0BÀBÑGÔG×NÒNØ˜+ v¨~Ð>ñ@ô @ð @à�tàÔ0Ð1CÔDˆCØ�1‰HˆCØ�aŠxˆxØ#Ô4×8Ò8Ð9KÑLÔL�ØÔ.×2Ò2Ð3EÑFÔFÐFÐFàEH�Ô.Ð/AÑBØ#Ô4Ð5GÔH�ð "œXÔ.×;Ò;Ø�V˜^¨\Ø"&ð <ñ (ô (‰NˆG�U�Uð
 œÔ*×7Ò7Ø�V˜^¨Tñ3ô 3‰JˆG�QàÔ)×-Ò-¨c°1Ñ5Ô5¸Ò9Ð9Ø)0ˆDÔ! #Ñ&Ø—’‘”ˆØ %ˆÔ˜ÑØÐØ×$Ò$ SÐ*<¸eÀUÑKÔKÐKØˆr&   c                 ó¶   — ||f}|| j         v r+| j                              |¦  «        }| j        |         }||fS t          j                             | |||¦  «        S )aí  Get the list of annotations for the parent, and the matching lines.

        :param text: The opaque value given by _get_needed_texts
        :param parent_key: The key for the parent text
        :return: (parent_annotations, matching_blocks)
            parent_annotations is a list as long as the number of lines in
                parent
            matching_blocks is a list of (parent_idx, text_idx, len) tuples
                indicating which lines match between the two texts
        )ré  r  Ú_annotations_cacher   rè  Ú#_get_parent_annotations_and_matches)r/   r6   r`   r¸  Ú	block_keyr  Úparent_annotationss          r'   r  z2_KnitAnnotator._get_parent_annotations_and_matches¾  ss   € ð ˜*Ð%ˆ	Ø˜Ô-Ð-Ð-ØÔ*×.Ò.¨yÑ9Ô9ˆFØ!%Ô!8¸Ô!DÐØ% vÐ-Ð-ÝÔ!×EÒEÀdØFIÈ4ÐQ[ñ]ô ]ð 	]r&   c                 óz  ‡ — g }|‰ j         v rj|}‰ j                              |¦  «        }|D ]K\  }}}}‰                      |||||¦  «        }	‰                      ||¦  «        r|                     |¦  «         ŒL|‰ j        v r;‰ j                             |¦  «        }|                     ˆ fd„|D ¦   «         ¦  «         |S )zxThe content for 'key' was just processed.

        Determine if there is any more pending work to be processed.
        c                 óF   •— g | ]\  }}‰                      ||¦  «        ¯|‘ŒS r%   )Ú_check_ready_for_annotations)r²   rp  Úp_keysr/   s      €r'   râ   z3_KnitAnnotator._process_pending.<locals>.<listcomp>ä  sH   ø€ ð Oð Oð O¡I A vØ!%×!BÒ!BÀ1ÀfÑ!MÔ!MðO˜að Oð Oð Or&   )rì  r  r  r  rX  rí  rm  )
r/   r6   Ú	to_returnrŒ   ÚchildrenÚ	child_keyr;  r:  r;  r}   s
   `         r'   Ú_process_pendingz_KnitAnnotator._process_pendingÑ  s  ø€ ð
 ˆ	Ø�$Ô&Ð&Ð&Ø!$ÐØÔ+×/Ò/°Ñ4Ô4ˆHØBJð 0ð 0Ñ>�	˜;¨°Ø×+Ò+¨I°{Ø,>Ø,2°NñDô D�ð ×4Ò4°YÀÑLÔLð 0Ø×$Ò$ YÑ/Ô/Ð/øð �$Ô*Ð*Ð*ØÔ/×3Ò3°CÑ8Ô8ˆHØ×Òð Oð Oð Oð O°ð Oñ Oô Oñ Pô Pð PàÐr&   c                 óˆ   — |D ]>}|| j         vr3| j                             |g ¦  «                             ||f¦  «          dS Œ?dS )zžreturn true if this text is ready to be yielded.

        Otherwise, this will return False, and queue the text into
        self._pending_annotation
        FT)r  rí  rI  rX  )r/   r6   r;  r¸  s       r'   r  z+_KnitAnnotator._check_ready_for_annotationsè  sf   € ð &ð 	ð 	ˆJØ Ô!8Ð8Ð8ð Ô(×3Ò3°JØ46ñ8ô 8ß8>ºÀÀ[Ð?QÑ8RÔ8RÐ8RØ�u�uð 9ð ˆtr&   c              #   óÞ  K  — i }| j                              |¦  «        D ]Í\  }}}| j        |         }|\  }}}	}
|                      ||	|||
¦  «        }|€Œ6|                      ||	¦  «        }|r||t          |¦  «        fV — |                      |¦  «        }|rT|}g }|D ]K}| j        |         }||t          |¦  «        fV — |                     |                      |¦  «        ¦  «         ŒL|°TŒÎdS )z1Extract the various texts needed based on recordsN)	rõ  r   rî  r  r  r  r  rø  rm  )r/   rF  Úpending_deltasr6   r:  rî  r#  r—   rŒ   r;  r;  r}   Úyield_this_textÚ
to_processÚthis_processs                  r'   r  z_KnitAnnotator._extract_textsø  sU  è è € ð> ˆØ%)¤X×%@Ò%@ÀÑ%IÔ%Ið 	Bð 	BÑ!ˆS�&˜&àÔ-¨cÔ2ˆGØCJÑ@ˆQÐ" K°Ø×'Ò'¨¨[Ð:LØ(.°ñ@ô @ˆEàˆ}àð #×?Ò?ÀØ@KñMô MˆOàð -à˜5¥# e¡*¤*Ð,Ð,Ð,Ð,Ø×.Ò.¨sÑ3Ô3ˆJØð BØ)�Ø�
Ø'ð Bð B�CØ Ô,¨SÔ1�EØ˜u¥c¨%¡j¤jÐ0Ð0Ð0Ð0Ø×%Ò% d×&;Ò&;¸CÑ&@Ô&@ÑAÔAÐAÐAð ð Bøð#	Bð 	Br&   r+   )r!   r"   r#   rH   r,   rý  r   r  r  r  r  r  r  r%   r&   r'   r…  r…    s¶   € € € € € Ø.Ð.ð%ð %ð %ð,@!ð @!ð @!ðD0ð 0ð 0ð 0ð0Bð Bð Bð%ð %ð %ðN]ð ]ð ]ð&ð ð ð.ð ð ð 7Bð 7Bð 7Bð 7Bð 7Br&   r…  )Ú_load_data_c)Ú_load_data_py)RrH   r@  Úior   rr  r   Úglobalsrž   r   r   r   r	   r>  r
   r   r   r   r   r   r   r   Úbzr.versionedfiler   r   r   r   r   r   r   r   r   r   rž  ÚDATA_SUFFIXÚINDEX_SUFFIXrê  r    r)   r2   r9   r>   rA   rE   rJ   rV   rl   rv   r�   r‘   r•   r™   rÉ   rØ   rç   ré   r  r‰   r8  rN   rP   r“  r°  r´  rÁ  rL   rì  r'  rÕ   r�  r¥  r�  rå  rè  r…  Ú_knit_load_data_pyxr  r{  ÚImportErrorr)  Úfailed_to_load_extensionÚ_knit_load_data_pyr   r%   r&   r'   ú<module>r*     s%  ðð"#ð #ðJ €€€Ø Ð Ð Ð Ð Ð Ø 	€	€	€	à %Ð %Ð %Ð %Ð %Ð %Ø €ˆGˆG‰IŒIð ñ ô ð ð(ð ð ð ð ð ð ð ð ð ð ð ðð ð ð ð ð ð ð ð ð ð
ð ð ð ð ð ð ð ð ð ð ð ðð ð ð ð ð ð
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ðð ð ð ð ð ð$ €Ø€Ø)Ð ðð ð ð ð Ð ñ ô ð ð
ð ð ð ð �)ñ ô ð ðð ð ð ð �kñ ô ð ð+ð +ð +ð +ð + ñ +ô +ð +ð+ð +ð +ð +ð +˜Iñ +ô +ð +ð!ð !ð !ð !ð !�iñ !ô !ð !ðð ð ð ð ˜Yñ ô ð ð"ð "ð "ð "ð "ñ "ô "ð "ð ð  ð  ð  ð  ˜{ñ  ô  ð  ð  ð  ð  ð  ð   +ñ  ô  ð  ð"Dð Dð Dð Dð D˜Kñ Dô Dð Dð"Dð Dð Dð Dð D˜{ñ Dô Dð Dð:Dð Dð Dð Dð D˜ñ Dô Dð Dð"Dð Dð Dð Dð D˜;ñ Dô Dð Dð8N5ð N5ð N5ð N5ð N5˜ñ N5ô N5ð N5ðb1Bð 1Bð 1Bð 1Bð 1B˜^ñ 1Bô 1Bð 1Bðh)ð )ð )ð@ð @ð @ð@5:ð 5:ð 5:ð 5:ð 5:ñ 5:ô 5:ð 5:ðp&1ð &1ð &1ð &1ð &1˜;ñ &1ô &1ð &1ðR"ð "ð "ð "ð "�{ñ "ô "ð "ðJ ð  ð  ð  ð  ñ  ô  ð  ðDu&ð u&ð u&ð u&ð u&˜,ñ u&ô u&ð u&ðp:,ð :,ð :,ð :,ð :,�|ñ :,ô :,ð :,ðzð ð ð""ð "ð "ðJ!ð !ð !ð
Að Að Að:Nð Nð Nð Nð NÐ4ñ Nô Nð Nðb$oð oð oð oð oñ oô oð oðd+)ð +)ð +)ð +)ð +)Ð1ñ +)ô +)ð +)ð\Vð Vð Vð Vð VÐ"6ñ Vô Vð VðrD!ð D!ð D!ð D!ð D!ñ D!ô D!ð D!ðN^2ð ^2ð ^2ð ^2ð ^2ñ ^2ô ^2ð ^2ðB^ð ^ð ^ð ^ð ^ñ ^ô ^ð ^ðB6ð 6ð 6ðQBð QBð QBð QBð QB�XÔ'ñ QBô QBð QBðh@Ø?Ð?Ð?Ð?Ð?Ð?Ð?Ð?øØð @ð @ð @Ø$€GÔ$ QÑ'Ô'Ð'Ø?Ð?Ð?Ð?Ð?Ð?Ð?Ð?Ð?Ð?Ð?Ð?øøøøð@øøøs   È-H5 È5IÈ:IÉI