§
    cÌcu� ã                   ó  — d Z ddlm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  G d	„ d
ej        ¦  «        Z G d„ dej        ¦  «        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¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        ZeeeedœZd,d!„Zd"„ Z ej        d#¦  «        Zd$„ Zd%„ Zd&„ Z d'„ Z!d(„ Z"d)„ Z#d*„ Z$d+„ Z%d S )-s	   TREE_ROOTé    )Údequeé   )Úlazy_importz@

from breezy.bzr import (
    chk_map,
    generate_ids,
    )
)ÚerrorsÚ
lazy_regexÚosutilsÚtraceé   )ÚStaticTuplec                   ó   — e Zd ZdZd„ ZdS )ÚInvalidEntryNamezInvalid entry name: %(name)sc                 óR   — t           j                             | ¦  «         || _        d S ©N)r   ÚBzrErrorÚ__init__Úname)Úselfr   s     ú6/usr/lib/python3/dist-packages/breezy/bzr/inventory.pyr   zInvalidEntryName.__init__7   s#   € ÝŒ× Ò  Ñ&Ô&Ð&ØˆŒ	ˆ	ˆ	ó    N©Ú__name__Ú
__module__Ú__qualname__Ú_fmtr   © r   r   r   r   3   s(   € € € € € à)€Dðð ð ð ð r   r   c                   ó   — e Zd ZdZd„ ZdS )ÚDuplicateFileIdz>File id {%(file_id)s} already exists in inventory as %(entry)sc                 ó`   — t           j                             | ¦  «         || _        || _        d S r   )r   r   r   Úfile_idÚentry)r   r   r    s      r   r   zDuplicateFileId.__init__@   s*   € ÝŒ× Ò  Ñ&Ô&Ð&ØˆŒØˆŒ
ˆ
ˆ
r   Nr   r   r   r   r   r   <   s(   € € € € € àK€Dðð ð ð ð r   r   c                   óÔ   — e Zd ZdZdZdZg 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ed„ ¦   «         Zd„ Zd„ Zd„ Zed„ ¦   «         Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z d„ Z!dS )ÚInventoryEntryaÈ  Description of a versioned file.

    An InventoryEntry has the following fields, which are also
    present in the XML inventory-entry element:

    file_id

    name
        (within the parent directory)

    parent_id
        file_id of the parent directory, or ROOT_ID

    revision
        the revision_id in which this variation of this file was
        introduced.

    executable
        Indicates that this file should be executable on systems
        that support it.

    text_sha1
        sha-1 of the text of the file

    text_size
        size in bytes of the text of the file

    (reading a version 4 tree created a text_id field.)

    >>> i = Inventory()
    >>> i.path2id('')
    b'TREE_ROOT'
    >>> i.add(InventoryDirectory(b'123', 'src', ROOT_ID))
    InventoryDirectory(b'123', 'src', parent_id=b'TREE_ROOT', revision=None)
    >>> i.add(InventoryFile(b'2323', 'hello.c', parent_id=b'123'))
    InventoryFile(b'2323', 'hello.c', parent_id=b'123', sha1=None, len=None, revision=None)
    >>> shouldbe = {0: '', 1: 'src', 2: 'src/hello.c'}
    >>> for ix, j in enumerate(i.iter_entries()):
    ...   print(j[0] == shouldbe[ix], j[1])
    ...
    True InventoryDirectory(b'TREE_ROOT', '', parent_id=None, revision=None)
    True InventoryDirectory(b'123', 'src', parent_id=b'TREE_ROOT', revision=None)
    True InventoryFile(b'2323', 'hello.c', parent_id=b'123', sha1=None, len=None, revision=None)
    >>> i.add(InventoryFile(b'2324', 'bye.c', b'123'))
    InventoryFile(b'2324', 'bye.c', parent_id=b'123', sha1=None, len=None, revision=None)
    >>> i.add(InventoryDirectory(b'2325', 'wibble', b'123'))
    InventoryDirectory(b'2325', 'wibble', parent_id=b'123', revision=None)
    >>> i.path2id('src/wibble')
    b'2325'
    >>> i.add(InventoryFile(b'2326', 'wibble.c', b'2325'))
    InventoryFile(b'2326', 'wibble.c', parent_id=b'2325', sha1=None, len=None, revision=None)
    >>> i.get_entry(b'2326')
    InventoryFile(b'2326', 'wibble.c', parent_id=b'2325', sha1=None, len=None, revision=None)
    >>> for path, entry in i.iter_entries():
    ...     print(path)
    ...
    <BLANKLINE>
    src
    src/bye.c
    src/hello.c
    src/wibble
    src/wibble/wibble.c
    >>> i.id2path(b'2326')
    'src/wibble/wibble.c'
    Úrenamedzmodified and renamed)r   ÚrevisionÚ	parent_idr   FNc                 ó   — dS )z·Return a (text_modified, meta_modified) from this to old_entry.

        _read_tree_state must have been called on self and old_entry prior to
        calling detect_changes.
        )FFr   )r   Ú	old_entrys     r   Údetect_changeszInventoryEntry.detect_changes¢   s	   € ð ˆ|r   c	                 ó   — dS )z4Perform a diff between two entries of the same kind.Nr   )	r   Ú	text_diffÚ
from_labelÚtreeÚto_labelÚto_entryÚto_treeÚ	output_toÚreverses	            r   Ú_diffzInventoryEntry._diffª   s   € € € r   c                 ó&  — i }|D ]‹}	 |                      | j        ¦  «        }|j        |v rF	 ||j                 j        |j        k    rd||j                 _        d|_        Œ\# t          $ r Y Œhw xY w|||j        <   Œw# t
          j        $ r Y Œˆw xY w|S )aT  Find possible per-file graph parents.

        This is currently defined by:
         - Select the last changed revision in the parent inventory.
         - Do deal with a short lived bug in bzr 0.8's development two entries
           that have the same last changed but different 'x' bit settings are
           changed in-place.
        F)Ú	get_entryr   r$   Ú
executableÚAttributeErrorr   ÚNoSuchId)r   Úprevious_inventoriesÚ
candidatesÚinvÚies        r   Úparent_candidatesz InventoryEntry.parent_candidates®   sÏ   € ð ˆ
à'ð 	1ð 	1ˆCð1Ø—]’] 4¤<Ñ0Ô0�ð ”; *Ð,Ð,ð
Ø% b¤kÔ2Ô=ÀÄÒNÐNØAF˜J r¤{Ô3Ô>Ø,1˜BœMøøÝ)ð ð ð Ø˜ðøøøð /1�J˜rœ{Ñ+Ð+øõ! ”?ð ð ð Ø�ðøøøð" Ðs"   ˆA<¬4A!Á!
A.Á-A.Á<BÂBc                 ó   — dS )aU  Return true if the object this entry represents has textual data.

        Note that textual data includes binary content.

        Also note that all entries get weave files created for them.
        This attribute is primarily used when upgrading from old trees that
        did not have the weave index for all inventory entries.
        Fr   ©r   s    r   Úhas_textzInventoryEntry.has_textÐ   s	   € ð ˆur   c                 ó®   — d|v rt          |¬¦  «        ‚t          |t          ¦  «        st          |¦  «        ‚|| _        d| _        || _        || _        dS )aæ  Create an InventoryEntry

        The filename must be a single component, relative to the
        parent directory; it cannot be a whole path or relative name.

        >>> e = InventoryFile(b'123', 'hello.c', ROOT_ID)
        >>> e.name
        'hello.c'
        >>> e.file_id
        b'123'
        >>> e = InventoryFile(b'123', 'src/hello.c', ROOT_ID)
        Traceback (most recent call last):
        breezy.bzr.inventory.InvalidEntryName: Invalid entry name: src/hello.c
        ú/©r   N)r   Ú
isinstanceÚbytesÚ	TypeErrorr   r$   r   r%   )r   r   r   r%   s       r   r   zInventoryEntry.__init__Û   s^   € ð �$ˆ;ˆ;Ý"¨Ð-Ñ-Ô-Ð-Ý˜'¥5Ñ)Ô)ð 	%Ý˜GÑ$Ô$Ð$ØˆŒØˆŒØˆŒ	Ø"ˆŒˆˆr   c                 ó:   — t          j        d| j        z  ¦  «        ‚)z<Return a short kind indicator useful for appending to names.úunknown kind %r)r   r   Úkindr>   s    r   Úkind_characterzInventoryEntry.kind_characteró   s   € åŒoÐ/°$´)Ñ;Ñ<Ô<Ð<r   )ÚfileÚ	directoryÚsymlinkc                 ó
   — | dv S )N)rJ   rK   rL   útree-referencer   )rH   s    r   Úversionable_kindzInventoryEntry.versionable_kindù   s   € àÐJÐJÐKr   c                 óú   — | j         �G|                     | j         ¦  «        s-t          j        d                     | j         |¦  «        ¦  «        ‚|                     || ¦  «         |                      ||¦  «         dS )a  Check this inventory entry is intact.

        This is a template method, override _check for kind specific
        tests.

        :param checker: Check object providing context for the checks;
             can be used to find out what parts of the repository have already
             been checked.
        :param rev_id: Revision id from which this InventoryEntry was loaded.
             Not necessarily the last-changed revision for this file.
        :param inv: Inventory from which the entry was loaded.
        Nz6missing parent {{{}}} in inventory for revision {{{}}})r%   Úhas_idr   ÚBzrCheckErrorÚformatÚ!_add_entry_to_text_key_referencesÚ_check)r   ÚcheckerÚrev_idr:   s       r   ÚcheckzInventoryEntry.checký   sƒ   € ð Œ>Ð%Ø—:’:˜dœnÑ-Ô-ð 1ÝÔ*ØL×SÒSØœ¨ñ0ô 0ñ1ô 1ð 1ð 	×1Ò1°#°tÑ<Ô<Ð<Ø�Š�G˜VÑ$Ô$Ð$Ð$Ð$r   c                 ól   — |j                              d                     | j        |¦  «        ¦  «         dS )z4Check this inventory entry for kind specific errors.z*unknown entry kind {!r} in revision {{{}}}N)Ú_report_itemsÚappendrS   rH   ©r   rV   rW   s      r   rU   zInventoryEntry._check  sA   € àÔ×$Ò$Ø8×?Ò?ÀÄ	È6ÑRÔRñ	Tô 	Tð 	Tð 	Tð 	Tr   c                 ó   — t           ‚)zClone this inventory entry.)ÚNotImplementedErrorr>   s    r   ÚcopyzInventoryEntry.copy  s   € å!Ð!r   c                 ó$  — | |u rdS | €dS |€dS | j         |j         k    rdS |                     | ¦  «        \  }}|s|rd}nd}| j        |j        k    rd}n| j        |j        k    rd}nd}|r|st          j        S |r|sdS |r|rt          j        S dS )a¬  Describe the change between old_entry and this.

        This smells of being an InterInventoryEntry situation, but as its
        the first one, we're making it a static method for now.

        An entry with a different parent, or different name is considered
        to be renamed. Reparenting is an internal detail.
        Note that renaming the parent does not trigger a rename for the
        child entry itself.
        Ú	unchangedNÚaddedÚremovedÚmodifiedTF)rH   r(   r%   r   r"   ÚRENAMEDÚMODIFIED_AND_RENAMED)r'   Ú	new_entryÚtext_modifiedÚmeta_modifiedrd   r#   s         r   Údescribe_changezInventoryEntry.describe_change  sí   € ð ˜	Ð!Ð!à�;ØÐØ�7ØÐØ�9ØŒ>˜Yœ^Ò+Ð+Ø�:Ø'0×'?Ò'?À	Ñ'JÔ'JÑ$ˆ�}Øð 	˜Mð 	ØˆHˆHàˆHàÔ )Ô"5Ò5Ð5ØˆGˆGØŒ^˜yœ~Ò-Ð-ØˆGˆGàˆGØð 	*˜8ð 	*Ý!Ô)Ð)Øð 	˜Gð 	Ø�:Øð 	7˜ð 	7Ý!Ô6Ð6Øˆ{r   c           
      ó`   — | j         j        ›d| j        ›d| j        ›d| j        ›d| j        ›d�
S )Nú(ú, ú, parent_id=ú, revision=ú))Ú	__class__r   r   r   r%   r$   r>   s    r   Ú__repr__zInventoryEntry.__repr__E  s>   € à”>Ô*Ð*Ð*Ø”<�<�<Ø”9�9�9Ø”>�>�>Ø”=�=�=ð"ð 	#r   c                 óL   — t          |dd ¦  «        }|€dS | j        |j        k    S )Nr$   F)Úgetattrr$   )r   ÚotherÚother_revisions      r   Úis_unmodifiedzInventoryEntry.is_unmodifiedM  s-   € Ý  ¨
°DÑ9Ô9ˆØÐ!Ø�5ØŒ} ¤Ò.Ð.r   c                 ó¦  — || u rdS t          |t          ¦  «        st          S | j        |j        k    oŸ| j        |j        k    o�|j        | j        k    o| j        |j        k    oo| j        |j        k    o_| j        |j        k    oO| j	        |j	        k    o?| j
        |j
        k    o/| j        |j        k    o| j        |j        k    o| j        |j        k    S ©NT)rC   r"   ÚNotImplementedr   r   Úsymlink_targetÚ	text_sha1Ú	text_sizeÚtext_idr%   rH   r$   r5   Úreference_revision©r   ru   s     r   Ú__eq__zInventoryEntry.__eq__S  s  € Ø�Dˆ=ˆ=à�4Ý˜%¥Ñ0Ô0ð 	"Ý!Ð!à” ¤Ò.ð 
FØ”˜eœjÒ(ð
FàÔ%¨Ô)<Ò<ð
Fð ” 5¤?Ò2ð
Fð ” 5¤?Ò2ð	
Fð
 ” ¤Ò.ð
Fð ” 5¤?Ò2ð
Fð ”˜eœjÒ(ð
Fð ” %¤.Ò0ð
Fð ” EÔ$4Ò4ð
Fð Ô(¨EÔ,DÒDð	r   c                 ó   — | |k     S r   r   r€   s     r   Ú__ne__zInventoryEntry.__ne__g  s   € Ø˜E’MÐ"Ð"r   c                 ó    — t          d¦  «        ‚©Nznot hashable©Ú
ValueErrorr>   s    r   Ú__hash__zInventoryEntry.__hash__j  ó   € Ý˜Ñ(Ô(Ð(r   c                 óz   — d}|j         | j         k    rd}n%|j        | j        k    rd}n|j        | j        k    rd}|S )ztHas this entry changed relative to previous_ie.

        This method should be overridden in child classes.
        TF)r%   r   rH   )r   Úprevious_ieÚ
compatibles      r   Ú
_unchangedzInventoryEntry._unchangedm  sR   € ð
 ˆ
àÔ  D¤NÒ2Ð2ØˆJˆJàÔ ¤Ò*Ð*ØˆJˆJØÔ ¤Ò*Ð*ØˆJØÐr   c                 ó   — dS )zÄPopulate fields in the inventory entry from the given tree.

        Note that this should be modified to be a noop on virtual trees
        as all entries created there are prepopulated.
        Nr   ©r   ÚpathÚ	work_trees      r   Ú_read_tree_statezInventoryEntry._read_tree_state}  s	   € ð 	ˆr   c                 ó   — d S r   r   r>   s    r   Ú_forget_tree_statez!InventoryEntry._forget_tree_stateˆ  s   € Øˆr   ©F)"r   r   r   Ú__doc__re   rf   Ú	__slots__r5   r|   r}   r~   r{   r   r(   r2   r<   r?   r   rI   Úknown_kindsÚstaticmethodrO   rX   rU   r_   rj   rr   rw   r�   rƒ   rˆ   r�   r’   r”   r   r   r   r"   r"   F   sª  € € € € € ð@ð @ðN €GØ1Ðà<Ð<Ð<€Ið €JØ€IØ€IØ€Gà€NàÐðð ð ð "'ðCð Cð Cð Cð ð  ð  ðD	ð 	ð 	ð#ð #ð #ð0=ð =ð =ð 3€KàðLð Lñ „\ðLð%ð %ð %ð*Tð Tð Tð
"ð "ð "ð ð'ð 'ñ „\ð'ðR#ð #ð #ð/ð /ð /ðð ð ð(#ð #ð #ð)ð )ð )ðð ð ð 	ð 	ð 	ðð ð ð ð r   r"   c                   óD   ‡ — e Zd ZdZdgZdZd„ Zd„ Zˆ fd„Zd„ Z	d„ Z
ˆ xZS )	ÚInventoryDirectoryúA directory in an inventory.ÚchildrenrK   c                 óx   — | j         dk    r	|j        sdS |                     |d| j        | j        fdd¦  «         dS )úSee InventoryEntry._checkÚ NÚtextsó   textó(   da39a3ee5e6b4b0d3255bfef95601890afd80709)r   Ú
rich_rootsÚadd_pending_itemr   r$   r\   s      r   rU   zInventoryDirectory._check“  sY   € ð Œ9˜Š?ˆ? 7Ô#5ˆ?ØˆFð 	× Ò  Ø")¨4¬<¸¼Ð!GÈØ!Lñ	Nô 	Nð 	Nð 	Nð 	Nr   c                 ó^   — t          | j        | j        | j        ¦  «        }| j        |_        |S r   )r›   r   r   r%   r$   r€   s     r   r_   zInventoryDirectory.copy   s)   € Ý" 4¤<°´¸D¼NÑKÔKˆØœˆŒð ˆr   c                 ó\   •— t          ¦   «                              |||¦  «         i | _        d S r   )Úsuperr   r�   ©r   r   r   r%   rq   s       €r   r   zInventoryDirectory.__init__§  s*   ø€ Ý‰Œ×Ò˜ $¨	Ñ2Ô2Ð2ØˆŒˆˆr   c                 óN   — t          | j                             ¦   «         ¦  «        S r   )Úsortedr�   Úitemsr>   s    r   Úsorted_childrenz"InventoryDirectory.sorted_children«  s   € Ý�d”m×)Ò)Ñ+Ô+Ñ,Ô,Ð,r   c                 ó   — dS )ú"See InventoryEntry.kind_character.rA   r   r>   s    r   rI   z!InventoryDirectory.kind_character®  ó   € àˆsr   )r   r   r   r–   r—   rH   rU   r_   r   r­   rI   Ú__classcell__©rq   s   @r   r›   r›   Œ  s‰   ø€ € € € € Ø&Ð&à�€Ià€DðNð Nð Nðð ð ðð ð ð ð ð-ð -ð -ðð ð ð ð ð ð r   r›   c                   ór   ‡ — e Zd ZdZg d¢ZdZˆ fd„Zd„ Zd„ Zd„ Z		 dd	„Z
d
„ Zd„ Zd„ Zd„ Zd„ Zˆ fd„Zˆ xZS )ÚInventoryFileúA file in an inventory.)r|   r}   r~   r5   rJ   c                 ó†   •— t          ¦   «                              |||¦  «         d | _        d | _        d | _        d| _        d S ©NF)r¨   r   r|   r}   r~   r5   r©   s       €r   r   zInventoryFile.__init__º  s?   ø€ Ý‰Œ×Ò˜ $¨	Ñ2Ô2Ð2ØˆŒØˆŒØˆŒØˆŒˆˆr   c                 óÒ   — |                      |d| j        | j        fd| j        ¦  «         | j        €5|j                             d                     | j        |¦  «        ¦  «         dS dS )rŸ   r¡   r¢   Nz.fileid {{{}}} in {{{}}} has None for text_size)r¥   r   r$   r|   r}   rZ   r[   rS   ©r   rV   Útree_revision_ids      r   rU   zInventoryFile._checkÁ  sŒ   € ð 	× Ò Ð!1Ø")¨4¬<¸¼Ð!GÈØ!%¤ñ	1ô 	1ð 	1ð Œ>Ð!ØÔ!×(Ò(Ø@×GÒGÈÌØ@PñRô RñSô Sð Sð Sð Sð "Ð!r   c                 ó¾   — t          | j        | j        | j        ¦  «        }| j        |_        | j        |_        | j        |_        | j        |_        | j        |_        |S r   )	r´   r   r   r%   r5   r~   r|   r}   r$   r€   s     r   r_   zInventoryFile.copyÌ  sL   € Ý˜dœl¨D¬I°t´~ÑFÔFˆØœ?ˆÔØœˆŒØœ.ˆŒØœ.ˆŒØœˆŒØˆr   c                 óJ   — | j         |j         k    }| j        |j        k    }||fS )ú"See InventoryEntry.detect_changes.)r|   r5   ©r   r'   rh   ri   s       r   r(   zInventoryFile.detect_changesÕ  s+   € àœ¨9Ô+>Ò>ˆØœ¨IÔ,@Ò@ˆØ˜mÐ+Ð+r   Fc	           	      ó  — ddl m}	 | j        }
|r|j        }|                     |¦  «        }nd}d}|
�|                     |
¦  «        }nd}|r|
|}
}||}}||}} |	|||ddd|¦  «        }|                     |||||
|¦  «        S )úSee InventoryEntry._diff.r   )ÚDiffTextNúutf-8r    )Úbreezy.diffrÁ   r   Úid2pathÚ	diff_text)r   r*   r+   r,   r-   r.   r/   r0   r1   rÁ   Úfrom_file_idÚ
to_file_idÚto_pathÚ	from_pathÚdiffers                  r   r2   zInventoryFile._diffÛ  sÐ   € ð 	)Ð(Ð(Ð(Ð(Ð(Ø”|ˆØð 	Ø!Ô)ˆJØ—o’o jÑ1Ô1ˆGˆGàˆJØˆGØÐ#ØŸš \Ñ2Ô2ˆIˆIàˆIØð 	8Ø'3°Z˜ˆJØ# T�'ˆDØ#+¨Z˜ˆJØ�˜$ ¨°G¸RÀØ#ñ%ô %ˆà×Ò 	¨7°JÀØ ,¨jñ:ô :ð 	:r   c                 ó   — dS )zSee InventoryEntry.has_text.Tr   r>   s    r   r?   zInventoryFile.has_textó  s   € àˆtr   c                 ó   — dS ©r¯   r    r   r>   s    r   rI   zInventoryFile.kind_character÷  ó   € àˆrr   c                 ón   — |                      |¦  «        | _        |                     |¦  «        | _        dS ©z$See InventoryEntry._read_tree_state.N)Úget_file_sha1r|   Úis_executabler5   r�   s      r   r’   zInventoryFile._read_tree_stateû  s2   € à"×0Ò0°Ñ6Ô6ˆŒð $×1Ò1°$Ñ7Ô7ˆŒˆˆr   c                 ó€   — | j         j        ›d| j        ›d| j        ›d| j        ›d| j        ›d| j        ›d| j        ›d�S )Nrl   rm   rn   z, sha1=z, len=ro   rp   )rq   r   r   r   r%   r|   r}   r$   r>   s    r   rr   zInventoryFile.__repr__  sP   € à”>Ô*Ð*Ð*Ø”<�<�<Ø”9�9�9Ø”>�>�>Ø”>�>�>Ø”>�>�>Ø”=�=�=ð"ð 	#r   c                 ó   — d | _         d S r   )r|   r>   s    r   r”   z InventoryFile._forget_tree_state  s   € ØˆŒˆˆr   c                 ó¬   •— t          ¦   «                              |¦  «        }| j        |j        k    rd}n|j        | _        | j        |j        k    rd}|S ©zSee InventoryEntry._unchanged.F)r¨   r�   r|   r}   r5   ©r   r‹   rŒ   rq   s      €r   r�   zInventoryFile._unchanged  sX   ø€ å‘W”W×'Ò'¨Ñ4Ô4ˆ
ØŒ>˜[Ô2Ò2Ð2ØˆJˆJð )Ô2ˆDŒNØŒ?˜kÔ4Ò4Ð4ØˆJØÐr   r•   )r   r   r   r–   r—   rH   r   rU   r_   r(   r2   r?   rI   r’   rr   r”   r�   r±   r²   s   @r   r´   r´   ³  sû   ø€ € € € € Ø!Ð!àCÐCÐC€Ià€Dð ð  ð  ð  ð  ð	Sð 	Sð 	Sðð ð ð,ð ,ð ,ð "'ð:ð :ð :ð :ð0ð ð ðð ð ð8ð 8ð 8ð#ð #ð #ðð ð ðð ð ð ð ð ð ð ð r   r´   c                   ód   ‡ — e Zd ZdZdgZdZˆ fd„Zd„ Zd„ Zd„ Z		 dd	„Z
d
„ Zd„ Zd„ Zˆ fd„Zˆ xZS )ÚInventoryLinkrµ   r{   rL   c                 ó\   •— t          ¦   «                              |||¦  «         d | _        d S r   )r¨   r   r{   r©   s       €r   r   zInventoryLink.__init__$  s-   ø€ Ý‰Œ×Ò˜ $¨	Ñ2Ô2Ð2Ø"ˆÔÐÐr   c                 óª   — | j         €&|j                             d| j        ›d|›d�¦  «         |                     |d| j        | j        fdd¦  «         dS )rŸ   Nz	symlink {z} has no target in revision {ú}r¡   r¢   r£   )r{   rZ   r[   r   r¥   r$   r¹   s      r   rU   zInventoryLink._check(  s   € àÔÐ&ØÔ!×(Ò(Ð(à”<�<�<Ð!1Ð!1Ð!1ð3ñ4ô 4ð 4ð 	× Ò Ð!1Ø")¨4¬<¸¼Ð!GÈØ!Lñ	Nô 	Nð 	Nð 	Nð 	Nr   c                 óv   — t          | j        | j        | j        ¦  «        }| j        |_        | j        |_        |S r   )rÙ   r   r   r%   r{   r$   r€   s     r   r_   zInventoryLink.copy3  s2   € Ý˜dœl¨D¬I°t´~ÑFÔFˆØ#Ô2ˆÔØœˆŒØˆr   c                 óZ   — | j         |j         k    }|rt          j        d¦  «         d}||fS )r½   z    symlink target changedF)r{   r	   Úmutterr¾   s       r   r(   zInventoryLink.detect_changes9  s=   € ð Ô,°	Ô0HÒHˆØð 	7ÝŒLÐ5Ñ6Ô6Ð6ØˆØ˜mÐ+Ð+r   Fc	                 ó˜   — ddl m}	 | j        }
|�|j        }nd}|s|}|}n|}|}|
|}
} |	|||¦  «        }|                     |
|¦  «        S )rÀ   r   )ÚDiffSymlinkN)rÃ   rá   r{   Údiff_symlink)r   r*   r+   r,   r-   r.   r/   r0   r1   rá   Ú
old_targetÚ
new_targetÚold_treeÚnew_treerÊ   s                  r   r2   zInventoryLink._diffB  sƒ   € ð 	,Ð+Ð+Ð+Ð+Ð+ØÔ(ˆ
ØÐØ!Ô0ˆJˆJàˆJØð 	<ØˆHØˆHˆHàˆHØˆHØ%/°˜
ˆJØ�˜X x°Ñ;Ô;ˆØ×"Ò" :¨zÑ:Ô:Ð:r   c                 ó   — dS rÍ   r   r>   s    r   rI   zInventoryLink.kind_characterU  rÎ   r   c                 óv   — |                      |                     | j        ¦  «        | j        ¦  «        | _        dS rÐ   )Úget_symlink_targetrÄ   r   r{   r�   s      r   r’   zInventoryLink._read_tree_stateY  s7   € à'×:Ò:Ø×Ò˜dœlÑ+Ô+¨T¬\ñ;ô ;ˆÔÐÐr   c                 ó   — d | _         d S r   )r{   r>   s    r   r”   z InventoryLink._forget_tree_state^  s   € Ø"ˆÔÐÐr   c                 ón   •— t          ¦   «                              |¦  «        }| j        |j        k    rd}|S rÖ   )r¨   r�   r{   r×   s      €r   r�   zInventoryLink._unchangeda  s6   ø€ å‘W”W×'Ò'¨Ñ4Ô4ˆ
ØÔ +Ô"<Ò<Ð<ØˆJØÐr   r•   )r   r   r   r–   r—   rH   r   rU   r_   r(   r2   rI   r’   r”   r�   r±   r²   s   @r   rÙ   rÙ     sÚ   ø€ € € € € Ø!Ð!à!Ð"€Ià€Dð#ð #ð #ð #ð #ð	Nð 	Nð 	Nðð ð ð,ð ,ð ,ð "'ð;ð ;ð ;ð ;ð&ð ð ð;ð ;ð ;ð
#ð #ð #ðð ð ð ð ð ð ð ð r   rÙ   c                   óL   ‡ — e Zd ZdgZdZ	 	 d
d„Zd„ Zd„ Zd„ Zˆ fd„Z	d	„ Z
ˆ xZS )ÚTreeReferencer   rN   Nc                 ó\   — t                                | |||¦  «         || _        || _        d S r   )r"   r   r$   r   )r   r   r   r%   r$   r   s         r   r   zTreeReference.__init__o  s1   € å×Ò  g¨t°YÑ?Ô?Ð?Ø ˆŒØ"4ˆÔÐÐr   c                 óZ   — t          | j        | j        | j        | j        | j        ¦  «        S r   )rí   r   r   r%   r$   r   r>   s    r   r_   zTreeReference.copyu  s-   € Ý˜Tœ\¨4¬9°d´nØ!œ]¨DÔ,CñEô Eð 	Er   c                 óF   — |                      || j        ¦  «        | _        dS )zDPopulate fields in the inventory entry from the given tree.
        N)Úget_reference_revisionr   r   r�   s      r   r’   zTreeReference._read_tree_statey  s)   € ð #,×"BÒ"BØ�$”,ñ# ô # ˆÔÐÐr   c                 ó   — d | _         d S r   )r   r>   s    r   r”   z TreeReference._forget_tree_state  s   € Ø"&ˆÔÐÐr   c                 ón   •— t          ¦   «                              |¦  «        }| j        |j        k    rd}|S rÖ   )r¨   r�   r   r×   s      €r   r�   zTreeReference._unchanged‚  s6   ø€ å‘W”W×'Ò'¨Ñ4Ô4ˆ
ØÔ" kÔ&DÒDÐDØˆJØÐr   c                 ó   — dS )r¯   ú+r   r>   s    r   rI   zTreeReference.kind_character‰  r°   r   ©NN)r   r   r   r—   rH   r   r_   r’   r”   r�   rI   r±   r²   s   @r   rí   rí   i  sž   ø€ € € € € à%Ð&€Ià€Dà:>Ø$(ð5ð 5ð 5ð 5ðEð Eð Eð ð  ð  ð'ð 'ð 'ðð ð ð ð ðð ð ð ð ð ð r   rí   c                   óf   — e Zd ZdZd„ Zd„ Zd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S )ÚCommonInventorya  Basic inventory logic, defined in terms of primitives like has_id.

    An inventory is the metadata about the contents of a tree.

    This is broadly a map from file_id to entries such as directories, files,
    symlinks and tree references. Each entry maintains its own metadata like
    SHA1 and length for files, or children for a directory.

    Entries can be looked up either by path or by file_id.

    InventoryEntry objects must not be modified after they are
    inserted, other than through the Inventory API.
    c                 óF   — t          |                      |¦  «        ¦  «        S r   )ÚboolÚpath2id)r   Úfilenames     r   Úhas_filenamezCommonInventory.has_filename�  s   € Ý�D—L’L Ñ*Ô*Ñ+Ô+Ð+r   c                 ó�   — d                      t          d„ |                      |¦  «        D ¦   «         dd…         ¦  «        ¦  «        S )aa  Return as a string the path to file_id.

        >>> i = Inventory()
        >>> e = i.add(InventoryDirectory(b'src-id', 'src', ROOT_ID))
        >>> e = i.add(InventoryFile(b'foo-id', 'foo.c', parent_id=b'src-id'))
        >>> print(i.id2path(b'foo-id'))
        src/foo.c

        :raises NoSuchId: If file_id is not present in the inventory.
        rA   c                 ó   — g | ]	}|j         ‘Œ
S r   rB   )Ú.0Úparents     r   ú
<listcomp>z+CommonInventory.id2path.<locals>.<listcomp>­  s&   € ð 2ð 2ð 2˜VˆVŒ[ð 2ð 2ð 2r   Néÿÿÿÿ)ÚjoinÚreversedÚ_iter_file_id_parents©r   r   s     r   rÄ   zCommonInventory.id2path   s\   € ð �xŠx�ð2ð 2Ø×'Ò'¨Ñ0Ô0ð2ñ 2ô 2Ø25°2°#ô7ñ8ô 8ñ 9ô 9ð 	9r   NTc              #   ó€  K  — |€| j         €dS | j         }d| j         fV — n*t          |t          ¦  «        r|                      |¦  «        }t	          |j                             ¦   «         ¦  «        }|s
|E d{V —† dS t          |¦  «        }d|fg}|r«|d         \  }}|r†|                     ¦   «         \  }}|dz   |z   }|dd…         |fV — |j	        dk    rŒ;t	          |j                             ¦   «         ¦  «        }	t          |	¦  «        }	| 
                    ||	f¦  «         n|                     ¦   «          |°©dS dS )zðReturn (path, entry) pairs, in order by name.

        :param from_dir: if None, start from the root,
          otherwise start from this directory (either file-id or entry)
        :param recursive: recurse into directories or not
        Nr    r  rA   r
   rK   )ÚrootrC   rD   r4   r«   r�   r¬   r   ÚpopleftrH   r[   Úpop)
r   Úfrom_dirÚ	recursiver�   ÚstackÚfrom_dir_relpathr   r;   r�   Únew_childrens
             r   Úiter_entrieszCommonInventory.iter_entries°  s’  è è € ð ÐØŒyÐ Ø�Ø”yˆHØ�d”i�-ÐÐÐÐÝ˜¥%Ñ(Ô(ð 	0Ø—~’~ hÑ/Ô/ˆHõ ˜(Ô+×1Ò1Ñ3Ô3Ñ4Ô4ˆØð 	ØÐÐÐÐÐÐÐØˆFÝ˜‘?”?ˆØ�h�Ð ˆØð 	Ø).¨r¬Ñ&Ð˜hàð Ø#×+Ò+Ñ-Ô-‘��bð (¨#Ñ-°Ñ4�à˜1˜2˜2”h �lÐ"Ð"Ð"à”7˜kÒ)Ð)Øõ  & b¤k×&7Ò&7Ñ&9Ô&9Ñ:Ô:�Ý$ \Ñ2Ô2�Ø—’˜d LÐ1Ñ2Ô2Ð2àð —	’	‘”�ð3 ð 	ð 	ð 	ð 	ð 	r   c                 ó   — dS )z§Populate any caches, we are about to access all items.

        The default implementation does nothing, because CommonInventory doesn't
        have a cache.
        Nr   r>   s    r   Ú_preload_cachezCommonInventory._preload_cacheâ  s	   € ð 	ˆr   c              #   ó
  ‡‡‡K  — |r$t          |t          ¦  «        st          |¦  «        }|€|€|                      ¦   «          |€Ÿ| j        €dS |�qt	          |¦  «        dk    r^t          |¦  «        d         }|�E	 |                      |¦  «        }||                      |¦  «        fV — n# t          j	        $ r Y nw xY wdS | j        }|�| j        j
        |v rd| j        fV — n:t          |t          ¦  «        r|                      |¦  «        }nt          |¦  «        ‚|�(t          ¦   «         Š| Šˆˆˆfd„Š|D ]} ‰|¦  «         ŒndŠd|fg}|r±|                     ¦   «         \  }}g }t          |j                             ¦   «         ¦  «        D ]K\  }	}
||	z   }|�	|
j
        |v r||
fV — |
j        dk    r%‰�	|
j
        ‰v r|                     |dz   |
f¦  «         ŒL|                     t)          |¦  «        ¦  «         |°¯dS dS )aV  Iterate over the entries in a directory first order.

        This returns all entries for a directory before returning
        the entries for children of a directory. This is not
        lexicographically sorted order, and is a hybrid between
        depth-first and breadth-first.

        :return: This yields (path, entry) pairs
        Nr
   r   r    c                 ó¾   •— ‰                      | ¦  «        sd S ‰                     | ¦  «        j        }|€d S |‰vr"‰                     |¦  «          ‰|¦  «         d S d S r   )rQ   r4   r%   Úadd)r   r%   Úadd_ancestorsÚbyidÚparentss     €€€r   r  z:CommonInventory.iter_entries_by_dir.<locals>.add_ancestors  sv   ø€ Ø—{’{ 7Ñ+Ô+ð Ø�FØ ŸNšN¨7Ñ3Ô3Ô=�	ØÐ$Ø�FØ GÐ+Ð+Ø—K’K 	Ñ*Ô*Ð*Ø!�M )Ñ,Ô,Ð,Ð,Ð,ð ,Ð+r   rK   rA   )rC   Úsetr  r	  ÚlenÚlistrÄ   r4   r   r7   r   rD   rE   r  r«   r�   r¬   rH   r[   Úextendr  )r   r  Úspecific_file_idsr   r�   r  Úcur_relpathÚcur_dirÚ
child_dirsÚ
child_nameÚchild_ieÚchild_relpathr  r  r  s               @@@r   Úiter_entries_by_dirz#CommonInventory.iter_entries_by_dirê  sÊ  øøøè è € ð ð 	7¥ZÐ0AÅ3Ñ%GÔ%Gð 	7Ý #Ð$5Ñ 6Ô 6Ðð ÐÐ 1Ð 9ð ×ÒÑ!Ô!Ð!ØÐØŒyÐ Ø�à!Ð-ÝÐ-Ñ.Ô.°!Ò3Ð3ÝÐ0Ñ1Ô1°!Ô4�ØÐ&ð<Ø#Ÿ|š|¨GÑ4Ô4˜ð # D§N¢N°7Ñ$;Ô$;Ð;Ð;Ð;Ð;Ð;øõ "œ?ð ð ð Ø˜ðøøøð �Ø”yˆHØ!Ð)Ø”yÔ(Ð,=Ð=Ð=Ø˜$œ)�mÐ#Ð#Ð#øÝ˜¥%Ñ(Ô(ð 	&Ø—~’~ hÑ/Ô/ˆHˆHå˜HÑ%Ô%Ð%àÐ(õ ‘e”eˆGØˆDð-ð -ð -ð -ð -ð -ð -ð -ð 'ð '�Ø�˜gÑ&Ô&Ð&Ð&ð'ð ˆGà�h�Ð ˆØð 	/Ø#(§9¢9¡;¤;Ñ ˆK˜àˆJÝ(.¨wÔ/?×/EÒ/EÑ/GÔ/GÑ(HÔ(Hð 
Kð 
KÑ$�
˜Hà +¨jÑ 8�à%Ð-Ø#Ô+Ð/@Ð@Ð@Ø'¨Ð1Ð1Ð1Ð1à”= KÒ/Ð/Ø�¨(Ô*:¸gÐ*EÐ*EØ"×)Ò)¨=¸3Ñ+>ÀÐ*IÑJÔJÐJøØ�LŠL� *Ñ-Ô-Ñ.Ô.Ð.ð ð 	/ð 	/ð 	/ð 	/ð 	/s   Á<B+ Â+B=Â<B=c           	      ó¼  — t          |                     ¦   «         ¦  «        }t          |                      ¦   «         ¦  «        }||z
  }||z
  }|                     |¦  «        }g }|D ].}|                     |                     |¦  «        d|df¦  «         Œ/|D ]A}|                     d|                      |¦  «        ||                      |¦  «        f¦  «         ŒB|D ]€}|                     |¦  «        |                      |¦  «        k    rR|                     |                     |¦  «        |                      |¦  «        ||                      |¦  «        f¦  «         Œ�|S ©ú-Make an inventory delta from two inventories.N)r  Úiter_all_idsÚintersectionr[   rÄ   r4   )	r   ÚoldÚold_idsÚnew_idsÚaddsÚdeletesÚcommonÚdeltar   s	            r   Ú_make_deltazCommonInventory._make_delta;  sq  € å�c×&Ò&Ñ(Ô(Ñ)Ô)ˆÝ�d×'Ò'Ñ)Ô)Ñ*Ô*ˆØ˜Ñ ˆØ˜GÑ#ˆØ×%Ò% gÑ.Ô.ˆØˆØð 	Fð 	FˆGØ�LŠL˜#Ÿ+š+ gÑ.Ô.°°g¸tÐDÑEÔEÐEÐEØð 	=ð 	=ˆGØ�LŠL˜$ §¢¨WÑ 5Ô 5Ø! 4§>¢>°'Ñ#:Ô#:ð<ñ =ô =ð =ð =àð 	Að 	AˆGØ�}Š}˜WÑ%Ô%¨¯ª¸Ñ)@Ô)@Ò@Ð@Ø—’˜cŸkšk¨'Ñ2Ô2°D·L²LÀÑ4IÔ4IØ% t§~¢~°gÑ'>Ô'>ð@ñ Aô Að Aøàˆr   c                 ó&   — t          ||||¦  «        S )z0Simple thunk to breezy.bzr.inventory.make_entry.)Ú
make_entry)r   rH   r   r%   r   s        r   r4  zCommonInventory.make_entryN  s   € å˜$  i°Ñ9Ô9Ð9r   c                 óJ   ‡‡— g Šˆˆfd„Š| j         � ‰| j         d¦  «         ‰S )zrReturn list of (path, ie) for all entries except the root.

        This may be faster than iter_entries.
        c                 óê   •— t          | j                             ¦   «         ¦  «        }|D ]H\  }}t          j        ||¦  «        }‰                     ||f¦  «         |j        dk    r ‰||¦  «         ŒId S )NrK   )r«   r�   r¬   r   Úpathjoinr[   rH   )Údir_ieÚdir_pathÚkidsr   r;   Ú
child_pathÚaccumÚdescends         €€r   r=  z(CommonInventory.entries.<locals>.descendY  s„   ø€ Ý˜&œ/×/Ò/Ñ1Ô1Ñ2Ô2ˆDØ ð ,ð ,‘��bÝ$Ô-¨h¸Ñ=Ô=�
Ø—’˜j¨"Ð-Ñ.Ô.Ð.Ø”7˜kÒ)Ð)Ø�G˜B 
Ñ+Ô+Ð+øð	,ð ,r   Nr    )r	  )r   r<  r=  s    @@r   ÚentrieszCommonInventory.entriesR  sL   øø€ ð
 ˆð	,ð 	,ð 	,ð 	,ð 	,ð 	,ð Œ9Ð ØˆG�D”I˜rÑ"Ô"Ð"Øˆr   c                 óŠ  — t          |t          ¦  «        rt          j        |¦  «        }n|}	 | j        }n# t
          j        $ r Y dS w xY w|€dS t          |¦  «        D ]`\  }}	 t          |dd¦  «        }|€ dS ||         }|j	        dk    r||d|dz   …         ||dz   d…         fc S |}ŒO# t          $ r Y  dS w xY w||g fS )a  Like get_entry_by_path, but return TreeReference objects.

        :param relpath: Path to resolve, either as string with / as separators,
            or as list of elements.
        :return: tuple with ie, resolved elements and elements left to resolve
        )NNNNr�   rN   r
   )rC   Ústrr   Ú	splitpathr	  r   r7   Ú	enumeratert   rH   ÚKeyError)r   ÚrelpathÚnamesr  ÚiÚfr�   Úcies           r   Úget_entry_by_path_partialz)CommonInventory.get_entry_by_path_partiale  s-  € õ �g�sÑ#Ô#ð 	ÝÔ% gÑ.Ô.ˆEˆEàˆEð	$Ø”YˆFˆFøÝŒð 	$ð 	$ð 	$à#Ð#Ð#ð	$øøøð ˆ>Ø#Ð#Ý˜eÑ$Ô$ð 	(ð 	(‰DˆAˆqð
(Ý" 6¨:°tÑ<Ô<�ØÐ#Ø+Ð+Ð+Ø˜q”k�Ø”8Ð/Ò/Ð/Ø  f q¨1¡u f¤¨u°Q¸±U°V°V¬}Ð<Ð<Ð<Ð<Ø��øÝð (ð (ð (à'Ð'Ð'Ð'ð(øøøð �u˜bÐ Ð s-   ®6 ¶A	ÁA	Á%B.Á;-B.Â+B.Â.
B=Â<B=c                 ó  — t          |t          ¦  «        rt          j        |¦  «        }n|}	 | j        }n# t
          j        $ r Y dS w xY w|€dS |D ]5}	 t          |dd¦  «        }|€ dS ||         }|}Œ$# t          $ r Y  dS w xY w|S )a]  Return an inventory entry by path.

        :param relpath: may be either a list of path components, or a single
            string, in which case it is automatically split.

        This returns the entry of the last component in the path,
        which may be either a file or a directory.

        Returns None IFF the path is not found.
        Nr�   )	rC   r@  r   rA  r	  r   r7   rt   rC  )r   rD  rE  r  rG  r�   rH  s          r   Úget_entry_by_pathz!CommonInventory.get_entry_by_path†  sØ   € õ �g�sÑ#Ô#ð 	ÝÔ% gÑ.Ô.ˆEˆEàˆEð	Ø”YˆFˆFøÝŒð 	ð 	ð 	à�4�4ð	øøøð ˆ>Ø�4Øð 		ð 		ˆAðÝ" 6¨:°tÑ<Ô<�ØÐ#Ø˜4˜4Ø˜q”k�Ø��øÝð ð ð à�t�t�tðøøøð ˆs'   ®6 ¶A	ÁA	ÁA6Á+
A6Á6
BÂBc                 óB   — |                       |¦  «        }|€dS |j        S )a{  Walk down through directories to return entry of last component.

        :param relpath: may be either a list of path components, or a single
            string, in which case it is automatically split.

        This returns the entry of the last component in the path,
        which may be either a file or a directory.

        Returns None IFF the path is not found.
        N)rK  r   )r   rD  r;   s      r   rû   zCommonInventory.path2id©  s)   € ð ×#Ò# GÑ,Ô,ˆØˆ:Ø�4ØŒzÐr   c                 ó~  — t          ¦   «         }|D ]@}	 |                     |                      |¦  «        ¦  «         Œ,# t          j        $ r Y Œ=w xY w|                      ¦   «         }| j        €t          d¬¦  «        S t          t          |¦  «        d         j	        ¦  «        }| j        j
        |j        _
        | j        |_        t          ¦   «         }|D ]f\  }}|j	        }	|	|v s	|j        |v r!|j        dk    r|                     |	¦  «         n|	|vrŒ?|                     |                     ¦   «         ¦  «         Œg|S )úñGet an inventory view filtered against a set of file-ids.

        Children of directories and parents are included.

        The result may or may not reference the underlying inventory
        so it should be treated as immutable.
        N©Úroot_idr
   rK   )r  ÚupdateÚ
get_idpathr   r7   r  r	  Ú	InventoryÚnextr   r$   Úrevision_idr%   rH   r  r_   )
r   Úspecific_fileidsÚinteresting_parentsÚfileidr>  ru   Údirectories_to_expandr�   r    r   s
             r   ÚfilterzCommonInventory.filter¹  sY  € õ "™eœeÐØ&ð 	ð 	ˆFðØ#×*Ò*¨4¯?ª?¸6Ñ+BÔ+BÑCÔCÐCÐCøÝ”?ð ð ð à�ðøøøð ×#Ò#Ñ%Ô%ˆØŒ9ÐÝ TÐ*Ñ*Ô*Ð*Ý�$˜w™-œ-¨Ô*Ô2Ñ3Ô3ˆØ"œiÔ0ˆŒ
ÔØ Ô,ˆÔÝ #¡¤ÐØ"ð 	$ð 	$‰KˆD�%Ø”mˆGØÐ+Ð+Ð+Ø”OÐ'<Ð<Ð<Ø”: Ò,Ð,Ø)×-Ò-¨gÑ6Ô6Ð6øØÐ 3Ð3Ð3ØØ�IŠI�e—j’j‘l”lÑ#Ô#Ð#Ð#Øˆs   ”(=½AÁAc                 óp   — g }|                       |¦  «        D ]}|                     d|j        ¦  «         Œ|S )a0  Return a list of file_ids for the path to an entry.

        The list contains one element for each directory followed by
        the id of the file itself.  So the length of the returned list
        is equal to the depth of the file in the tree, counting the
        root directory as depth 1.
        r   )r  Úinsertr   )r   r   Úpr  s       r   rR  zCommonInventory.get_idpathÚ  sD   € ð ˆØ×0Ò0°Ñ9Ô9ð 	(ð 	(ˆFØ�HŠH�Q˜œÑ'Ô'Ð'Ð'Øˆr   ry   rö   r   )r   r   r   r–   rý   rÄ   r  r  r%  r2  r4  r>  rI  rK  rû   rZ  rR  r   r   r   rø   rø   Ž  sù   € € € € € ðð ð,ð ,ð ,ð9ð 9ð 9ð 0ð 0ð 0ð 0ðdð ð ðO/ð O/ð O/ð O/ðbð ð ð&:ð :ð :ð :ðð ð ð&!ð !ð !ðB!ð !ð !ðFð ð ð ð ð ðBð ð ð ð r   rø   c                   ó´   — e Zd ZdZedf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d„Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ ZdS )rS  a   Mutable dict based in-memory inventory.

    We never store the full path to a file, because renaming a directory
    implicitly moves all of its contents.  This class internally maintains a
    lookup tree that allows the children under a directory to be
    returned quickly.

    >>> inv = Inventory()
    >>> inv.add(InventoryFile(b'123-123', 'hello.c', ROOT_ID))
    InventoryFile(b'123-123', 'hello.c', parent_id=b'TREE_ROOT', sha1=None, len=None, revision=None)
    >>> inv.get_entry(b'123-123').name
    'hello.c'

    Id's may be looked up from paths:

    >>> inv.path2id('hello.c')
    b'123-123'
    >>> inv.has_id(b'123-123')
    True

    There are iterators over the contents:

    >>> [entry[0] for entry in inv.iter_entries()]
    ['', 'hello.c']
    Nc                 ó~   — |�%|                       t          |dd¦  «        ¦  «         nd| _        i | _        || _        dS )a5  Create or read an inventory.

        If a working directory is specified, the inventory is read
        from there.  If the file is specified, read from that. If not,
        the inventory is created empty.

        The inventory is created with a default root directory, with
        an id of None.
        Nr    )Ú	_set_rootr›   r	  Ú_byidrU  )r   rP  rU  s      r   r   zInventory.__init__  sH   € ð ÐØ�NŠNÕ-¨g°r¸4Ñ@Ô@ÑAÔAÐAÐAàˆDŒIØˆDŒJØ&ˆÔÐÐr   c                 óØ   — d}d}t          | j        ¦  «        }t          |¦  «        |k    r|d |t          |¦  «        z
  …         |z   }d                     t	          | ¦  «        |¦  «        S )Ni   z...}z)<Inventory object at {:x}, contents={!r}>)Úreprra  r  rS   Úid)r   Úmax_lenÚclosingÚcontentss       r   rr   zInventory.__repr__  sh   € àˆØˆÝ˜œ
Ñ#Ô#ˆÝˆx‰=Œ=˜7Ò"Ð"ØÐ 9 '­C°©L¬LÑ"8Ð 9Ô:¸WÑDˆHØ:×AÒAÅ"ÀTÁ(Ä(ÈHÑUÔUÐUr   c                 óÎ  — t          t          t          t          t	          t          t          |¦  «        ¦  «        ¦  «        ¦  «        ¦  «        ¦  «        ¦  «         i }t          d„ |D ¦   «         d¬¦  «        D ]—\  }}t          |  	                    |¦  «        di ¦  «        }t          |¦  «        r|||<   |                      |¦  «        |k    r,t          j        ||d|                      |¦  «        z  ¦  «        ‚|                      |¦  «         Œ˜t          d„ |D ¦   «         ¦  «        D ]ü\  }}}|j        dk    rNt!          |j        |j        |j        ¦  «        }	|j        |	_        |                     |	j        i ¦  «        |	_        |	}	 |                      |¦  «         nM# t0          $ r t          j        ||j        d¦  «        ‚t2          $ r t          j        ||j        d	¦  «        ‚w xY w|                      |j        ¦  «        |k    rt          j        ||j        d
¦  «        ‚Œýt          |¦  «        r-|                     ¦   «         \  }
}t          j        d|
d¦  «        ‚dS )a/  Apply a delta to this inventory.

        See the inventory developers documentation for the theory behind
        inventory deltas.

        If delta application fails the inventory is left in an indeterminate
        state and must not be used.

        :param delta: A list of changes to apply. After all the changes are
            applied the final inventory must be internally consistent, but it
            is ok to supply changes which, if only half-applied would have an
            invalid result - such as supplying two changes which rename two
            files, 'A' and 'B' with each other : [('A', 'B', b'A-id', a_entry),
            ('B', 'A', b'B-id', b_entry)].

            Each change is a tuple, of the form (old_path, new_path, file_id,
            new_entry).

            When new_path is None, the change indicates the removal of an entry
            from the inventory and new_entry will be ignored (using None is
            appropriate). If new_path is not None, then new_entry must be an
            InventoryEntry instance, which will be incorporated into the
            inventory (and replace any existing entry with the same file id).

            When old_path is None, the change indicates the addition of
            a new entry to the inventory.

            When neither new_path nor old_path are None, the change is a
            modification to an entry, such as a rename, reparent, kind change
            etc.

            The children attribute of new_entry is ignored. This is because
            this method preserves children automatically across alterations to
            the parent of the children, and cases where the parent id of a
            child is changing require the child to be passed in as a separate
            change regardless. E.g. in the recursive deletion of a directory -
            the directory's children must be included in the delta, or the
            final inventory will be invalid.

            Note that a file_id must only appear once within a given delta.
            An AssertionError is raised otherwise.
        c              3   ó,   K  — | ]\  }}}}|®	||fV — Œd S r   r   ©r   ÚopÚnprG  Úes        r   ú	<genexpr>z(Inventory.apply_delta.<locals>.<genexpr>W  s;   è è € ð )<ð )<±\°R¸¸QÀØ,.¨Nð +-¨a¨Ø,:¨N¨N¨Nð)<ð )<r   T)r1   r�   ú!Entry was at wrong other path %r.c              3   ó.   K  — | ]\  }}}}|®	|||fV — Œd S r   r   rj  s        r   rn  z(Inventory.apply_delta.<locals>.<genexpr>h  sA   è è € ð -Fð -F¹L¸BÀÀAÀqØ68°nð /1°!°Q¨ZØ6D°n°n°nð-Fð -Fr   rK   z$New id is already present in target.zParent is not a directory.z,New path is not consistent with parent path.z	<deleted>z:The file id was deleted but its children were not deleted.N)r  Ú_check_delta_unique_idsÚ_check_delta_unique_new_pathsÚ_check_delta_unique_old_pathsÚ_check_delta_ids_match_entryÚ_check_delta_ids_are_validÚ(_check_delta_new_path_entry_both_or_Noner«   rt   r4   r  rÄ   r   ÚInconsistentDeltaÚremove_recursive_idrH   r›   r   r   r%   r$   r  r�   r  r   r6   Úpopitem)r   r1  r�   Úold_pathr   Úfile_id_childrenÚnew_pathrG  rg   Úreplacementr%   s              r   Úapply_deltazInventory.apply_delta  s  € õ^ 	Õ$Õ%BÝ)Õ*FÝ*Ý<Øñô ñ ô  ñ+!ô +!ñ "ô "ñ&#ô &#ñ $ô $ñ 	%ô 	%ð 	%ð ˆõ
 "(ð )<ð )<ÀUð )<ñ )<ô )<ØEIð"Kñ "Kô "Kð 	.ð 	.ÑˆH�gõ  ' t§~¢~°gÑ'>Ô'>À
ÈBÑOÔOÐÝÐ#Ñ$Ô$ð 5Ø$4�˜Ñ!Ø�|Š|˜GÑ$Ô$¨Ò0Ð0ÝÔ.¨x¸Ø/RÐUY×UaÒUaÐbiÑUjÔUjÑ/jñlô lð lð ×$Ò$ WÑ-Ô-Ð-Ð-õ '-ð -Fð -FØ-2ð-Fñ -Fô -Fñ 'Fô 'Fð 	_ð 	_Ñ"ˆH�a˜àŒ~ Ò,Ð,õ 1°Ô1BØ1:´ÀÔATñVô V�à'0Ô'9�Ô$Ø'/§|¢|°KÔ4GÈÑ'LÔ'L�Ô$Ø'�	ðMØ—’˜Ñ#Ô#Ð#Ð#øÝ"ð Wð Wð WÝÔ.¨x¸Ô9JØ/UñWô Wð Wå!ð Mð Mð MÝÔ.¨x¸Ô9JØ/KñMô Mð MðMøøøð �|Š|˜IÔ-Ñ.Ô.°(Ò:Ð:ÝÔ.¨x¸Ô9JØ/]ñ_ô _ð _ð ;õ ˆx‰=Œ=ð 	ià"*×"2Ò"2Ñ"4Ô"4ÑˆI�xÝÔ*¨;¸	Ø+gñiô ið ið	ið 	is   ÆF"Æ"A
G,Fc                 óf   — |                       ¦   «         }|                     |¦  «         ||_        |S )z(See CHKInventory.create_by_apply_delta())r_   r~  rU  )r   Úinventory_deltaÚnew_revision_idÚpropagate_cachesÚnew_invs        r   Úcreate_by_apply_deltazInventory.create_by_apply_delta„  s2   € ð —)’)‘+”+ˆØ×Ò˜OÑ,Ô,Ð,Ø-ˆÔØˆr   c                 óD   — || _         | j         j        | j         i| _        d S r   )r	  r   ra  )r   r;   s     r   r`  zInventory._set_rootŒ  s    € ØˆŒ	Ø”iÔ'¨¬Ð3ˆŒ
ˆ
ˆ
r   c                 ó4  — |                       ¦   «         }| j        €t          d ¬¦  «        S t          t          |¦  «        d         j        ¦  «        }| j        j        |j        _        |D ],\  }}|                     |                     ¦   «         ¦  «         Œ-|S )NrO  r
   )r  r	  rS  rT  r   r$   r  r_   )r   r>  ru   r�   r    s        r   r_   zInventory.copy�  s�   € à×#Ò#Ñ%Ô%ˆØŒ9ÐÝ TÐ*Ñ*Ô*Ð*Ý�$˜w™-œ-¨Ô*Ô2Ñ3Ô3ˆØ"œiÔ0ˆŒ
Ôð #ð 	$ð 	$‰KˆD�%Ø�IŠI�e—j’j‘l”lÑ#Ô#Ð#Ð#Øˆr   c                 ó*   — t          | j        ¦  «        S )úIterate over all file-ids.)Úiterra  r>   s    r   r)  zInventory.iter_all_ids�  s   € å�D”JÑÔÐr   c                 óF   — | j         €dS | j                             ¦   «         S )úÚIterate over all entries.

        Unlike iter_entries(), just the entries are returned (not (path, ie))
        and the order of entries is undefined.

        XXX: We may not want to merge this into bzr.dev.
        Nr   )r	  ra  Úvaluesr>   s    r   Úiter_just_entrieszInventory.iter_just_entries¡  s%   € ð Œ9ÐØ�2ØŒz× Ò Ñ"Ô"Ð"r   c                 ó*   — t          | j        ¦  «        S )zReturns number of entries.)r  ra  r>   s    r   Ú__len__zInventory.__len__­  s   € å�4”:‰ŒÐr   c                 ó¬   — t          |t          ¦  «        st          |¦  «        ‚	 | j        |         S # t          $ r t          j        | |¦  «        ‚w xY w)a1  Return the entry for given file_id.

        >>> inv = Inventory()
        >>> inv.add(InventoryFile(b'123123', 'hello.c', ROOT_ID))
        InventoryFile(b'123123', 'hello.c', parent_id=b'TREE_ROOT', sha1=None, len=None, revision=None)
        >>> inv.get_entry(b'123123').name
        'hello.c'
        )rC   rD   rE   ra  rC  r   r7   r  s     r   r4   zInventory.get_entry±  sc   € õ ˜'¥5Ñ)Ô)ð 	%Ý˜GÑ$Ô$Ð$ð	1Ø”:˜gÔ&Ð&øÝð 	1ð 	1ð 	1å”/ $¨Ñ0Ô0Ð0ð	1øøøs	   ¦3 ³ Ac                 ó&   — | j         |         j        S r   )ra  rH   r  s     r   Úget_file_kindzInventory.get_file_kindÂ  s   € ØŒz˜'Ô"Ô'Ð'r   c                 ó\   — |                       |¦  «        j                             |¦  «        S r   )r4   r�   Úget)r   r%   rü   s      r   Ú	get_childzInventory.get_childÅ  s%   € Ø�~Š~˜iÑ(Ô(Ô1×5Ò5°hÑ?Ô?Ð?r   c                 óö   — |j         | j        v rt          j        d|j         z  ¦  «        ‚|| j        |j         <   t	          |di ¦  «        }|�,|                     ¦   «         D ]}|                      |¦  «         Œ|S )z>Add an entry to the inventory, without adding it to its parentz-inventory already contains entry with id {%s}r�   )r   ra  r   r   rt   rŒ  Ú
_add_child)r   r    r�   Úchilds       r   r—  zInventory._add_childÈ  sŒ   € àŒ=˜DœJÐ&Ð&Ý”/Ø?Ø”ññô ð ð %*ˆŒ
�5”=Ñ!Ý˜5 *¨bÑ1Ô1ˆØÐØ!ŸšÑ*Ô*ð 'ð '�Ø—’ Ñ&Ô&Ð&Ð&Øˆr   c                 óê  — |j         | j        v r%t          |j         | j        |j                  ¦  «        ‚|j        €|| _        n�	 | j        |j                 }n)# t
          $ r t          j        d|j        d¦  «        ‚w xY w|j        |j	        v rCt          j        |  
                    |j	        |j                 j         ¦  «        |j         d¦  «        ‚||j	        |j        <   |                      |¦  «        S )z8Add entry to inventory.

        :return: entry
        Nú	<unknown>zParent not in inventory.zPath already versioned)r   ra  r   r%   r	  rC  r   rw  r   r�   rÄ   r—  )r   r    r  s      r   r  zInventory.addÕ  s   € ð
 Œ=˜DœJÐ&Ð&Ý! %¤-°´¸E¼MÔ1JÑKÔKÐKØŒ?Ð"ØˆDŒIˆIðKØœ E¤OÔ4��øÝð Kð Kð KÝÔ.¨{¸E¼OØ/IñKô Kð KðKøøøð Œz˜Vœ_Ð,Ð,ÝÔ.Ø—L’L ¤°´Ô!<Ô!DÑEÔEØ”MØ,ñ.ô .ð .ð +0ˆFŒO˜EœJÑ'Ø�Š˜uÑ%Ô%Ð%s   ÁA Á&A=c                 ó¶  — t          j        |¦  «        }t          |¦  «        dk    rP|€t                               ¦   «         }t          |dd¦  «        | _        | j        j        | j        i| _        | j        S |dd…         }|  	                    |¦  «        }|€t          j        |¬¦  «        ‚t          ||d         ||¦  «        }|                      |¦  «        S )zvAdd entry from a path.

        The immediate parent must already be versioned.

        Returns the new entry object.r   Nr    r  )r�   )r   rA  r  Úgenerate_idsÚgen_root_idr›   r	  r   ra  rû   r   ÚNotVersionedErrorr4  r  )r   rD  rH   r   r%   ÚpartsÚparent_pathr;   s           r   Úadd_pathzInventory.add_pathì  sÆ   € õ Ô! 'Ñ*Ô*ˆåˆu‰:Œ:˜Š?ˆ?ØˆÝ&×2Ò2Ñ4Ô4�Ý*¨7°B¸Ñ=Ô=ˆDŒIØœ)Ô+¨T¬YÐ7ˆDŒJØ”9Ðà   œ*ˆKØŸš [Ñ1Ô1ˆIØÐ ÝÔ.°KÐ@Ñ@Ô@Ð@Ý˜˜e Bœi¨°GÑ<Ô<ˆØ�xŠx˜‰|Œ|Ðr   c                 óœ   — |                       |¦  «        }| j        |= |j        �'|                       |j        ¦  «        j        |j        = dS dS )aS  Remove entry by id.

        >>> inv = Inventory()
        >>> inv.add(InventoryFile(b'123', 'foo.c', ROOT_ID))
        InventoryFile(b'123', 'foo.c', parent_id=b'TREE_ROOT', sha1=None, len=None, revision=None)
        >>> inv.has_id(b'123')
        True
        >>> inv.delete(b'123')
        >>> inv.has_id(b'123')
        False
        N)r4   ra  r%   r�   r   ©r   r   r;   s      r   ÚdeletezInventory.delete  sP   € ð �^Š^˜GÑ$Ô$ˆØŒJ�wÐØŒ<Ð#Ø—’˜rœ|Ñ,Ô,Ô5°b´gÐ>Ð>Ð>ð $Ð#r   c                 óZ   — t          |t          ¦  «        st          S | j        |j        k    S )a  Compare two sets by comparing their contents.

        >>> i1 = Inventory()
        >>> i2 = Inventory()
        >>> i1 == i2
        True
        >>> i1.add(InventoryFile(b'123', 'foo', ROOT_ID))
        InventoryFile(b'123', 'foo', parent_id=b'TREE_ROOT', sha1=None, len=None, revision=None)
        >>> i1 == i2
        False
        >>> i2.add(InventoryFile(b'123', 'foo', ROOT_ID))
        InventoryFile(b'123', 'foo', parent_id=b'TREE_ROOT', sha1=None, len=None, revision=None)
        >>> i1 == i2
        True
        )rC   rS  rz   ra  r€   s     r   r�   zInventory.__eq__  s+   € õ  ˜%¥Ñ+Ô+ð 	"Ý!Ð!àŒz˜Uœ[Ò(Ð(r   c                 ó.   — |                       |¦  «         S r   )r�   r€   s     r   rƒ   zInventory.__ne__)  s   € Ø—;’;˜uÑ%Ô%Ð%Ð%r   c                 ó    — t          d¦  «        ‚r…   r†   r>   s    r   rˆ   zInventory.__hash__,  r‰   r   c              #   ó’   K  — |�B	 | j         |         }n$# t          $ r t          j        d|¬¦  «        ‚w xY w|V — |j        }|­@dS dS ©z,Yield the parents of file_id up to the root.N)r,   r   )ra  rC  r   r7   r%   r£  s      r   r  zInventory._iter_file_id_parents/  sx   è è € àÐ!ðBØ”Z Ô(��øÝð Bð Bð BÝ”o¨4¸ÐAÑAÔAÐAðBøøøàˆHˆHˆHØ”lˆGð Ð!Ð!Ð!Ð!Ð!s   † ”!5c                 ó   — || j         v S r   )ra  r  s     r   rQ   zInventory.has_id9  s   € Ø˜4œ:Ð%Ð&r   c           	      óª  — |j         }| j         }t          |                     ¦   «         ¦  «        }t          |                      ¦   «         ¦  «        }||z
  }||z
  }|s|s|}n|                     |¦  «        }g }	|D ].}
|	                     |                     |
¦  «        d|
df¦  «         Œ/|D ]A}
|	                     d|                      |
¦  «        |
|                       |
¦  «        f¦  «         ŒB|D ]b}
 ||
¦  «        } ||
¦  «        }||u s||k    rŒ#|	                     |                     |
¦  «        |                      |
¦  «        |
|f¦  «         Œc|	S r'  )r4   r  r)  r*  r[   rÄ   )r   r+  Ú
old_getterÚ
new_getterr,  r-  r.  r/  r0  r1  r   Únew_ieÚold_ies                r   r2  zInventory._make_delta<  sœ  € à”]ˆ
Ø”^ˆ
Ý�c×&Ò&Ñ(Ô(Ñ)Ô)ˆÝ�d×'Ò'Ñ)Ô)Ñ*Ô*ˆØ˜Ñ ˆØ˜GÑ#ˆØð 	3˜Gð 	3ØˆFˆFà×)Ò)¨'Ñ2Ô2ˆFØˆØð 	Fð 	FˆGØ�LŠL˜#Ÿ+š+ gÑ.Ô.°°g¸tÐDÑEÔEÐEÐEØð 	=ð 	=ˆGØ�LŠL˜$ §¢¨WÑ 5Ô 5Ø! 4§>¢>°'Ñ#:Ô#:ð<ñ =ô =ð =ð =àð 	0ð 	0ˆGØ�Z Ñ(Ô(ˆFØ�Z Ñ(Ô(ˆFð
 ˜ÐÐ 6¨VÒ#3Ð#3Øà—’˜cŸkšk¨'Ñ2Ô2°D·L²LÀÑ4IÔ4IØ% vð/ñ 0ô 0ð 0ð 0àˆr   c                 óÀ  — | j         |         g}g }|rg|                     ¦   «         }|                     |j        ¦  «         |j        dk    r,|                     |j                             ¦   «         ¦  «         |°gt          |¦  «        D ]}|  	                    |¦  «        }| j         |= Œ |j
        �'|  	                    |j
        ¦  «        j        |j        = dS d| _        dS )zhRemove file_id, and children, from the inventory.

        :param file_id: A file_id to remove.
        rK   N)ra  r  r[   r   rH   r  r�   rŒ  r  r4   r%   r   r	  )r   r   Úto_find_deleteÚ	to_deleter;   s        r   rx  zInventory.remove_recursive_id\  së   € ð
 œ* WÔ-Ð.ˆØˆ	Øð 	<Ø×#Ò#Ñ%Ô%ˆBØ×Ò˜RœZÑ(Ô(Ð(ØŒw˜+Ò%Ð%Ø×%Ò% b¤k×&8Ò&8Ñ&:Ô&:Ñ;Ô;Ð;ð	 ð 	<õ
   	Ñ*Ô*ð 	$ð 	$ˆGØ—’ Ñ(Ô(ˆBØ”
˜7Ð#Ð#ØŒ<Ð#Ø—’˜rœ|Ñ,Ô,Ô5°b´gÐ>Ð>Ð>àˆDŒIˆIˆIr   c                 ó.  — t          |¦  «        }t          |¦  «        st          j        d|z  ¦  «        ‚| j        |         }||j        v r,t          j        |›d|                      |¦  «        ›�¦  «        ‚|                      |¦  «        }||v r@t          j        d|                      |¦  «        ›d|                      |¦  «        ›�¦  «        ‚| j        |         }| j        |j                 }|j        |j	        = ||j        |<   ||_	        ||_        dS )zšMove a file within the inventory.

        This can change either the name, or the parent, or both.

        This does not move the working file.
        znot an acceptable filename: %rz already exists in zcannot move directory z  into a subdirectory of itself, N)
Úensure_normalized_nameÚis_valid_namer   r   ra  r�   rÄ   rR  r%   r   )r   r   Únew_parent_idÚnew_nameÚ
new_parentÚnew_parent_idpathÚfile_ieÚ
old_parents           r   ÚrenamezInventory.renamep  s:  € õ *¨(Ñ3Ô3ˆÝ˜XÑ&Ô&ð 	OÝ”/Ð"BÀXÑ"MÑNÔNÐNà”Z Ô.ˆ
Ø�zÔ*Ð*Ð*Ý”/Ø#+ 8 8¨T¯\ª\¸-Ñ-HÔ-HÐ-Hð#Jñ Kô Kð Kð !ŸOšO¨MÑ:Ô:ÐØÐ'Ð'Ð'Ý”/�/à—<’< Ñ(Ô(Ð(Ð(¨$¯,ª,°}Ñ*EÔ*EÐ*EðGñHô Hð Hð ”*˜WÔ%ˆØ”Z Ô 1Ô2ˆ
ð Ô ¤Ð-Ø(/ˆ
Ô˜HÑ%àˆŒØ)ˆÔÐÐr   c                 ó4   — | j         d uo|| j         j        k    S r   )r	  r   r  s     r   Úis_rootzInventory.is_root‘  s   € ØŒy Ð$ÐE¨°D´IÔ4EÒ)EÐEr   r•   rö   )r   r   r   r–   ÚROOT_IDr   rr   r~  r„  r`  r_   r)  r�  r�  r4   r’  r•  r—  r  r¡  r¤  r�   rƒ   rˆ   r  rQ   r2  rx  r¼  r¾  r   r   r   rS  rS  è  sÄ  € € € € € ðð ð4  '°Dð 'ð 'ð 'ð 'ð"Vð Vð Vðeið eið eiðP 05ðð ð ð ð4ð 4ð 4ðð ð ð ð  ð  ð
#ð 
#ð 
#ðð ð ð1ð 1ð 1ð"(ð (ð (ð@ð @ð @ðð ð ð&ð &ð &ð.ð ð ð ð.?ð ?ð ?ð")ð )ð )ð*&ð &ð &ð)ð )ð )ð#ð #ð #ð'ð 'ð 'ðð ð ð@ð ð ð(*ð *ð *ðBFð Fð Fð Fð Fr   rS  c                   óô   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Ze	d„ ¦   «         Z
d„ Z	 d d
„Zed„ ¦   «         Ze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d„ Zd„ Zd„ Zed„ ¦   «         Z dS )"ÚCHKInventoryaö  An inventory persisted in a CHK store.

    By design, a CHKInventory is immutable so many of the methods
    supported by Inventory - add, rename, apply_delta, etc - are *not*
    supported. To create a new CHKInventory, use create_by_apply_delta()
    or from_inventory(), say.

    Internally, a CHKInventory has one or two CHKMaps:

    * id_to_entry - a map from (file_id,) => InventoryEntry as bytes
    * parent_id_basename_to_file_id - a map from (parent_id, basename_utf8)
        => file_id as bytes

    The second map is optional and not present in early CHkRepository's.

    No caching is performed: every method call or item access will perform
    requests to the storage layer. As such, keep references to objects you
    want to reuse.
    c                 ó€   — t                                | ¦  «         i | _        d| _        i | _        || _        d | _        d S r·   )rø   r   Ú_fileid_to_entry_cacheÚ_fully_cachedÚ_path_to_fileid_cacheÚ_search_key_namerP  )r   Úsearch_key_names     r   r   zCHKInventory.__init__ª  sA   € Ý× Ò  Ñ&Ô&Ð&Ø&(ˆÔ#Ø"ˆÔØ%'ˆÔ"Ø /ˆÔØˆŒˆˆr   c                 ó.  — t          |t          ¦  «        st          S | j                             ¦   «         }|j                             ¦   «         }| j                             ¦   «         }|j                             ¦   «         }d||||fv rdS ||k    o||k    S )z-Compare two sets by comparing their contents.NF)rC   rÁ  rz   Úid_to_entryÚkeyÚparent_id_basename_to_file_id)r   ru   Úthis_keyÚ	other_keyÚthis_pid_keyÚother_pid_keys         r   r�   zCHKInventory.__eq__²  s˜   € å˜%¥Ñ.Ô.ð 	"Ý!Ð!àÔ#×'Ò'Ñ)Ô)ˆØÔ%×)Ò)Ñ+Ô+ˆ	ØÔ9×=Ò=Ñ?Ô?ˆØÔ;×?Ò?ÑAÔAˆØ�H˜l¨I°}ÐEÐEÐEØ�5Ø˜9Ò$ÐF¨¸Ò)FÐFr   c                 óæ  — |j         �|j         }nd}|j                             d¦  «        }|j        dk    r,|j        rd}nd}d|j        |||j        |j        |j        |fz  S |j        dk    rd	|j        |||j        fz  S |j        d
k    r,d|j        |||j        |j	                             d¦  «        fz  S |j        dk    rd|j        |||j        |j
        fz  S t          d|j        z  ¦  «        ‚)aë  Serialise entry as a single bytestring.

        :param Entry: An inventory entry.
        :return: A bytestring for the entry.

        The BNF:
        ENTRY ::= FILE | DIR | SYMLINK | TREE
        FILE ::= "file: " COMMON SEP SHA SEP SIZE SEP EXECUTABLE
        DIR ::= "dir: " COMMON
        SYMLINK ::= "symlink: " COMMON SEP TARGET_UTF8
        TREE ::= "tree: " COMMON REFERENCE_REVISION
        COMMON ::= FILE_ID SEP PARENT_ID SEP NAME_UTF8 SEP REVISION
        SEP ::= "
"
        Nr   Úutf8rJ   ó   Yó   Ns   file: %s
%s
%s
%s
%s
%d
%srK   s   dir: %s
%s
%s
%srL   s   symlink: %s
%s
%s
%s
%srN   s   tree: %s
%s
%s
%s
%srG   )r%   r   ÚencoderH   r5   r   r$   r|   r}   r{   r   r‡   )r   r    Ú
parent_strÚname_strÚexec_strs        r   Ú_entry_to_byteszCHKInventory._entry_to_bytes¿  s;  € ð Œ?Ð&ØœˆJˆJàˆJØ”:×$Ò$ VÑ,Ô,ˆØŒ:˜ÒÐØÔð  Ø��à�Ø6Ø”˜z¨8°U´^Ø” ¤°(ð:<ñ <ð <ð ŒZ˜;Ò&Ð&Ø)Ø”˜z¨8°U´^ð-Eñ Eð EàŒZ˜9Ò$Ð$Ø1Ø”˜z¨8°U´^ØÔ$×+Ò+¨FÑ3Ô3ð55ñ 5ð 5ð ŒZÐ+Ò+Ð+Ø.Ø”˜z¨8°U´^ØÔ(ð2*ñ *ð *õ Ð.°´Ñ;Ñ<Ô<Ð<r   c                 ór  — t          ¦   «         }t          ¦   «         }i }|                      |¦  «        D ]€}|j        dk    r|                     |j        ¦  «         |                     |j        ¦  «         |                     |j        t          ¦   «         ¦  «                             |j        ¦  «         Œ�|                     |¦  «        }|                     d¦  «         |                     d¦  «         |r«t          ¦   «         }|                      |¦  «        D ][}|                     |j        ¦  «         |                     |j        t          ¦   «         ¦  «                             |j        ¦  «         Œ\|                     |¦  «        }| 	                    |¦  «         |°«| 	                    |¦  «         |                     d¦  «         |rèd„ |D ¦   «         }t          ¦   «         }| j
                             |¦  «        }	d„ |	D ¦   «         }
|
                     |¦  «        }
| 	                    |
¦  «         |                      |
¦  «        D ]f}|j        dk    r|                     |j        ¦  «         |                     |j        t          ¦   «         ¦  «                             |j        ¦  «         Œg|°è||fS )a­  Give a more wholistic view starting with the given file_ids.

        For any file_id which maps to a directory, we will include all children
        of that directory. We will also include all directories which are
        parents of the given file_ids, but we will not include their children.

        eg:
          /     # TREE_ROOT
          foo/  # foo-id
            baz # baz-id
            frob/ # frob-id
              fringle # fringle-id
          bar/  # bar-id
            bing # bing-id

        if given [foo-id] we will include
            TREE_ROOT as interesting parents
        and
            foo-id, baz-id, frob-id, fringle-id
        As interesting ids.
        rK   Nc                 óP   — g | ]#}t          |¦  «                             ¦   «         ‘Œ$S r   ©r   Úintern©r   rG  s     r   r  zHCHKInventory._expand_fileids_to_parents_and_children.<locals>.<listcomp>$  s*   € ÐLÐLÐL°•K ‘O”O×*Ò*Ñ,Ô,ÐLÐLÐLr   c                 ó   — h | ]
}|d          ’ŒS )r
   r   )r   Úitems     r   ú	<setcomp>zGCHKInventory._expand_fileids_to_parents_and_children.<locals>.<setcomp>'  s   € Ð7Ð7Ð7¨˜T !œWÐ7Ð7Ð7r   )r  Ú	_getitemsrH   r  r   r%   Ú
setdefaultÚ
differenceÚdiscardrQ  rË  Ú	iteritems)r   Úfile_idsÚinterestingrY  Úchildren_of_parent_idr    Úremaining_parentsÚnext_parentsÚkeysr¬   Únext_file_idss              r   Ú'_expand_fileids_to_parents_and_childrenz4CHKInventory._expand_fileids_to_parents_and_childrené  s¼  € õ, ‘e”eˆõ !$¡¤ÐØ "Ðà—^’^ HÑ-Ô-ð 	Bð 	BˆEØŒz˜[Ò(Ð(Ø%×)Ò)¨%¬-Ñ8Ô8Ð8Ø�OŠO˜EœOÑ,Ô,Ð,Ø!×,Ò,¨U¬_½c¹e¼eñ /ô /ß/2ªs°5´=Ñ/AÔ/AÐ/AÐ/Að
 (×2Ò2°8Ñ<Ô<Ðð 	�Š˜ÑÔÐØ×!Ò! $Ñ'Ô'Ð'Øð 	2Ý™5œ5ˆLØŸšÐ(9Ñ:Ô:ð Fð F�Ø× Ò  ¤Ñ1Ô1Ð1Ø%×0Ò0°´Å#Á%Ä%ñ 3ô 3ß36²3°u´}Ñ3EÔ3EÐ3EÐ3Eà ,× 7Ò 7¸Ñ DÔ DÐØ×ÒÐ0Ñ1Ô1Ð1ð  ð 	2ð 	×Ò˜8Ñ$Ô$Ð$Ø×Ò˜DÑ!Ô!Ð!Ø#ð 	Fð MÐLÐ6KÐLÑLÔLˆDÝ$'¡E¤EÐ!ØÔ6×@Ò@ÀÑFÔFˆEØ7Ð7°Ð7Ñ7Ô7ˆMØ)×4Ò4°[ÑAÔAˆMØ×Ò˜}Ñ-Ô-Ð-ØŸš¨Ñ6Ô6ð Fð F�Ø”: Ò,Ð,Ø)×-Ò-¨e¬mÑ<Ô<Ð<Ø%×0Ò0°´Å#Á%Ä%ñ 3ô 3ß36²3°u´}Ñ3EÔ3EÐ3EÐ3Eð $ð 	Fð Ð1Ð1Ð1r   c                 óÖ  — |                       |¦  «        \  }}t          | j        ¦  «        }| j        j        |j        _        | j        |_        |r|s|S | j        }t          || j                 ¦  «        }|rq|                     ¦   «         }||         }|j	        dk    r| 
                    ¦   «         }|                     |¦  «         ||v r|                     ||         ¦  «         |°q|S )rN  rK   )rí  rS  rP  r	  r$   rU  rÃ  r   r
  rH   r_   r  r  )	r   rV  rç  Úparent_to_childrenru   ÚcacheÚremaining_childrenr   r;   s	            r   rZ  zCHKInventory.filter1  s  € ð  $×KÒKØñ ô  ñ	ˆØ	õ ˜$œ,Ñ'Ô'ˆØ"œiÔ0ˆŒ
ÔØ Ô,ˆÔØð 	Ð"4ð 	ð ˆLØÔ+ˆÝ"Ø˜tœ|Ô,ñ.ô .Ðà ð 
	GØ(×0Ò0Ñ2Ô2ˆGØ�w”ˆBØŒw˜+Ò%Ð%Ø—W’W‘Y”Y�ð �IŠI�b‰MŒMˆMØÐ,Ð,Ð,Ø"×)Ò)Ð*<¸WÔ*EÑFÔFÐFð !ð 
	Gð ˆr   c                 óŠ   — |                       d¦  «        }|d                               d¦  «        \  }}|d         ||d         fS )z-Get the file_id, revision_id key out of data.ó   
r   ó   : r   é   )Úsplit)ÚdataÚsectionsrH   r   s       r   Ú_bytes_to_utf8name_keyz#CHKInventory._bytes_to_utf8name_keyY  sE   € ð
 —:’:˜eÑ$Ô$ˆØ  œ×)Ò)¨%Ñ0Ô0‰ˆˆgØ˜”˜W h¨q¤kÐ2Ð2r   c                 óf  — |                      d¦  «        }|d                              d¦  «        rxt          |d         dd…         |d                              d¦  «        |d         ¦  «        }|d	         |_        t          |d
         ¦  «        |_        |d         dk    |_        �nN|d                              d¦  «        r@t          |d         d
d…         |d                              d¦  «        |d         | ¦  «        }nó|d                              d¦  «        r_t          |d         dd…         |d                              d¦  «        |d         ¦  «        }|d	                              d¦  «        |_
        ny|d                              d¦  «        rLt          |d         dd…         |d                              d¦  «        |d         ¦  «        }|d	         |_        nt          d|z  ¦  «        ‚|j        |_        |d         |_        |j        dk    rd|_        || j        |j        <   |S )zDeserialise a serialised entry.ró  r   s   file: é   Nr   rÑ  r
   é   é   rÒ  s   dir: s	   symlink: é	   s   tree: zNot a serialised entry %rrõ  r   )rö  Ú
startswithr´   Údecoder|   Úintr}   r5   ÚCHKInventoryDirectoryrÙ   r{   rí   r   r‡   r   r$   r%   rÃ  )r   rD   rø  Úresults       r   Ú_bytes_to_entryzCHKInventory._bytes_to_entryb  s!  € à—;’;˜uÑ%Ô%ˆØ�AŒ;×!Ò! )Ñ,Ô,ð 	BÝ" 8¨A¤;¨q¨r¨r¤?Ø#+¨A¤;×#5Ò#5°fÑ#=Ô#=Ø#+¨A¤;ñ0ô 0ˆFð  (¨œ{ˆFÔÝ" 8¨A¤;Ñ/Ô/ˆFÔØ (¨¤¨tÒ 3ˆFÔÑØ�aŒ[×#Ò# HÑ-Ô-ð 	BÝ*¨8°A¬;°q°r°r¬?Ø+3°A¬;×+=Ò+=¸fÑ+EÔ+EØ+3°A¬;¸ñ>ô >ˆFˆFð �aŒ[×#Ò# LÑ1Ô1ð 	BÝ" 8¨A¤;¨q¨r¨r¤?Ø#+¨A¤;×#5Ò#5°fÑ#=Ô#=Ø#+¨A¤;ñ0ô 0ˆFð %-¨Q¤K×$6Ò$6°vÑ$>Ô$>ˆFÔ!Ð!Ø�aŒ[×#Ò# IÑ.Ô.ð 	BÝ" 8¨A¤;¨q¨r¨r¤?Ø#+¨A¤;×#5Ò#5°fÑ#=Ô#=Ø#+¨A¤;ñ0ô 0ˆFð )1°¬ˆFÔ%Ð%åÐ8¸5Ñ@ÑAÔAÐAØœˆŒØ" 1œ+ˆŒØÔ˜sÒ"Ð"Ø#ˆFÔØ6<ˆÔ# F¤NÑ3Øˆr   Fc           	      ó&  — t           j        }t          | j        ¦  «        }|r| j                             ¦   «         |_        t          j                             | j        ¦  «        }| j	         
                    ¦   «          | j	        j        j        }||_        t                               | j	        j        | j	                             ¦   «         |¬¦  «        |_	        |j	         
                    ¦   «          |j	        j                             |¦  «         i }| j        �´t                               | j        j        | j                             ¦   «         |¬¦  «        |_        |j         
                    ¦   «          | j         
                    ¦   «          |j        j        }	| j        j        }
|	                     |
j        ¦  «         |
j        |	_        nd|_        | j        |_        g }t+          |¦  «        }t-          |¦  «        }t/          |¦  «        }t1          |¦  «        }t3          |¦  «        }t5          |¦  «        }t7          ¦   «         }t7          ¦   «         }t7          ¦   «         }|D �]Ì\  }}}}|dk    r||_        |€6d}d}|r	 |j        |= n# t8          $ r Y nw xY w|                     |¦  «         nYt=          |¦  «        }|                     |¦  «        }||j        |<   |                      ||¦  «        d         |j         f¦  «         |€d}nit=          |¦  «        }|  !                    |¦  «        |k    r,tE          j#        ||d|  !                    |¦  «        z  ¦  «        ‚|                     |¦  «         | $                    t=          |||¦  «        ¦  «         |j        ��|€d}n*|  %                    |¦  «        }|  &                    |¦  «        }|€d}d}n|  &                    |¦  «        }|}||k    r:|�|| '                    |ddg¦  «        d<   |�|| '                    |ddg¦  «        d<   �ŒÎ|D ]{}|  %                    |¦  «        }|j(        dk    rŒ#|j)         *                    ¦   «         D ]>}|j+        |vr3tE          j#        |  !                    |j+        ¦  «        |j+        d¦  «        ‚Œ?Œ||j	         ,                    |¦  «         |rlg }| -                    ¦   «         D ];\  }\  }}|�| $                    |||f¦  «         Œ#| $                    |ddf¦  «         Œ<|j         ,                    |¦  «         | .                    d	¦  «         |D ]¼\  }}	 | %                    |¦  «        j(        dk    r)tE          j#        | !                    |¦  «        |d
¦  «        ‚n)# tD          j/        $ r tE          j#        d|d¦  «        ‚w xY w| 0                    |¦  «        |k    r,tE          j#        ||d| 0                    |¦  «        z  ¦  «        ‚Œ½|S )a  Create a new CHKInventory by applying inventory_delta to this one.

        See the inventory developers documentation for the theory behind
        inventory deltas.

        :param inventory_delta: The inventory delta to apply. See
            Inventory.apply_delta for details.
        :param new_revision_id: The revision id of the resulting CHKInventory.
        :param propagate_caches: If True, the caches for this inventory are
          copied to and updated for the result.
        :return: The new CHKInventory.
        ©Úsearch_key_funcNr    r   ro  r
   rK   z4Child not deleted or reparented when parent deleted.)r    Nz#Not a directory, but given childrenrš  z-Parent is not present in resulting inventory.zParent has wrong path %r.)1r   rö  rÁ  rÆ  rÅ  r_   Úchk_mapÚsearch_key_registryr”  rÉ  Ú_ensure_rootÚ
_root_nodeÚmaximum_sizerU  ÚCHKMapÚ_storerÊ  Úset_maximum_sizerË  Ú
_key_widthrP  rq  rs  rr  rt  ru  rv  r  rC  r  r   rØ  r%   rÄ   r   rw  r[   r4   Ú_parent_id_basename_keyrâ  rH   r�   rŒ  r   r~  r¬   rä  r7   rû   )r   r€  r�  r‚  rö  r  r  r  Úparent_id_basename_deltaÚresult_p_id_rootÚ	p_id_rootÚid_to_entry_deltar  r/  Úalteredrz  r|  r   r    Únew_keyÚ	new_valueÚold_keyr'   r˜  Ú
delta_listrÊ  Úvaluer   r  s                                r   r„  z"CHKInventory.create_by_apply_deltaƒ  sÔ  € õ ”ˆÝ˜dÔ3Ñ4Ô4ˆØð 	Mà+/Ô+E×+JÒ+JÑ+LÔ+LˆFÔ(Ý!Ô5×9Ò9ØÔ!ñ#ô #ˆàÔ×%Ò%Ñ'Ô'Ð'ØÔ'Ô2Ô?ˆØ,ˆÔÝ$Ÿ^š^ØÔÔ#ØÔ× Ò Ñ"Ô"Ø+ð ,ñ -ô -ˆÔð 	Ô×'Ò'Ñ)Ô)Ð)ØÔÔ%×6Ò6°|ÑDÔDÐDð $&Ð ØÔ-Ð9Ý3:·>²>ØÔ2Ô9ØÔ2×6Ò6Ñ8Ô8Ø /ð 4Bñ 41ô 41ˆFÔ0ð Ô0×=Ò=Ñ?Ô?Ð?ØÔ.×;Ò;Ñ=Ô=Ð=Ø%ÔCÔNÐØÔ:ÔEˆIØ×-Ò-¨iÔ.DÑEÔEÐEØ*3Ô*>ÐÔ'Ð'à37ˆFÔ0ØœˆŒØÐõ 2°/ÑBÔBˆå7¸ÑHÔHˆå7¸ÑHÔHˆå6°ÑGÔGˆå4°_ÑEÔEˆåBØñô ˆõ ‘%”%ˆõ
 ‘%”%ˆÝ‘%”%ˆØ2Að 7	Bñ 7	BÑ.ˆH�h ¨à˜2Š~ˆ~Ø!(�”ØÐà�Ø �	à#ð ðØ"Ô8¸ÐBÐBøÝ#ð ð ð Ø˜ðøøøà—’˜GÑ$Ô$Ð$Ð$å% gÑ/Ô/�Ø"×2Ò2°5Ñ9Ô9�	ð :A�Ô,¨XÑ6Ø—’˜U˜U 8™_œ_¨QÔ/°´ÐAÑBÔBÐBØÐØ��å% gÑ/Ô/�Ø—<’< Ñ(Ô(¨HÒ4Ð4Ý Ô2°8¸WØ3VØ37·<²<ÀÑ3HÔ3Hñ4IñJô Jð Jð —’˜GÑ$Ô$Ð$Ø×$Ò$¥[°¸'À9Ñ%MÔ%MÑNÔNÐNØÔ3Ð?àÐ#Ø"�G�Gà $§¢¨wÑ 7Ô 7�IØ"×:Ò:¸9ÑEÔE�GØÐ#Ø"�GØ $�I�Ià"×:Ò:¸5ÑAÔA�GØ '�Ið ˜gÒ%Ð%ð Ð*à8?ð 1×;Ò;Ø# d¨D \ñ3ô 3Ø34ñ6àÐ*à8Að 1×;Ò;Ø# d¨D \ñ3ô 3Ø34ñ6ùð ð 
	Fð 
	FˆGØ—N’N 7Ñ+Ô+ˆEØŒz˜[Ò(Ð(Øð œ×.Ò.Ñ0Ô0ð Fð F�Ø”=¨Ð/Ð/Ý Ô2°4·<²<ÀÄÑ3NÔ3NØ38´=ð CEñFô Fð Fð 0ðFð
 	Ô×&Ò&Ð'8Ñ9Ô9Ð9Ø#ð 	Ið
 ˆJØ)A×)GÒ)GÑ)IÔ)Ið =ð =Ñ%�Ñ%�g˜uØÐ$Ø×%Ò% w°°UÐ&;Ñ<Ô<Ð<Ð<à×%Ò% w°°dÐ&;Ñ<Ô<Ð<Ð<ØÔ0×<Ò<¸ZÑHÔHÐHØ�Š˜
Ñ#Ô#Ð#Ø#*ð 
	jð 
	jÑˆK˜ð`Ø×#Ò# FÑ+Ô+Ô0°KÒ?Ð?Ý Ô2°6·>²>À&Ñ3IÔ3IÈ6Ø3XñZô Zð Zð @øõ ”?ð `ð `ð `ÝÔ.¨{¸FØ/^ñ`ô `ð `ð`øøøð �~Š~˜kÑ*Ô*¨fÒ4Ð4ÝÔ.¨{¸FØ/JÈVÏ^Ê^Ð\gÑMhÔMhÑ/hñjô jð jð 5ð ˆs   ÊJÊ
JÊJÕAV"Ö"&Wc                 óŒ  — |d                               d¦  «        st          d¦  «        ‚|d         dk    rt          dt          z  ¦  «        ‚i }t          d¦  «        }|dd	…         D ]y}|                     d¦  «                             d
d¦  «        \  }}||vrt          j        d|›dt          ›�¦  «        ‚||v rt          j        d|›dt          ›�¦  «        ‚|||<   Œz|d         }	|d         }
|                     dd¦  «        }|                     dd	¦  «        }| 	                    d¦  «        st          d|›�¦  «        ‚|d         }| 	                    d¦  «        st          d|›�¦  «        ‚t          |¦  «        }|	|_        |
|_        t          j                             |j        ¦  «        }|�0t                               |t#          |¦  «        |¬¦  «        |_        nd	|_        t                               |t#          |¦  «        |¬¦  «        |_        |j        f|k    rt          d|j        ›d|›�¦  «        ‚|S )a  Deserialise a CHKInventory.

        :param chk_store: A CHK capable VersionedFiles instance.
        :param bytes: The serialised bytes.
        :param expected_revision_id: The revision ID we think this inventory is
            for.
        :return: A CHKInventory
        r  ró  z#last line should have trailing eol
r   ó   chkinventory:
z!not a serialised CHKInventory: %r)ó   root_idó   revision_idó   parent_id_basename_to_file_idó   search_key_nameó   id_to_entryr
   Nrô  zUnknown key in inventory: ú
zDuplicate key in inventory: r  r  r!  ó   plainr   s   sha1:z7parent_id_basename_to_file_id should be a sha1 key not r"  z%id_to_entry should be a sha1 key not r  z%Mismatched revision id and expected: rm   )Úendswithr‡   rD   Ú	frozensetÚrstriprö  r   r   r”  rÿ  rÁ  rU  rP  r  r	  rÆ  r  r   rË  rÉ  )ÚklassÚ	chk_storeÚlinesÚexpected_revision_idÚinfoÚallowed_keysÚlinerÊ  r  rU  rP  rÇ  rË  rÉ  r  r  s                   r   ÚdeserialisezCHKInventory.deserialise-  sÁ  € ð �RŒy×!Ò! %Ñ(Ô(ð 	EÝÐCÑDÔDÐDØ�Œ8Ð)Ò)Ð)ÝÐ@Å5ÑHÑIÔIÐIØˆÝ ð "Fñ Gô Gˆð ˜!˜"˜"”Ið 	ð 	ˆDØŸš UÑ+Ô+×1Ò1°%¸Ñ;Ô;‰JˆC�Ø˜,Ð&Ð&Ý”o�oØ),¨¨­e¨eð'5ñ 6ô 6ð 6à�dˆ{ˆ{Ý”o�oØ),¨¨­e¨eð'5ñ 6ô 6ð 6àˆD�‰IˆIØ˜>Ô*ˆØ�zÔ"ˆØŸ(š(Ð#5°xÑ@Ô@ˆØ(,¯ªØ,¨dñ)4ô )4Ð%à,×7Ò7¸ÑAÔAð 	OÝ�*Ø.KÐ.KðNñ Oô Oð Oà˜>Ô*ˆØ×%Ò% hÑ/Ô/ð 	=Ý�*Ø.9¨kð<ñ =ô =ð =õ ˜oÑ.Ô.ˆØ(ˆÔØ ˆŒÝ!Ô5×9Ò9ØÔ#ñ%ô %ˆà(Ð4Ý3:·>²>Ø�;Ð'DÑFÔFØ /ð 4Bñ 41ô 41ˆFÔ0Ð0ð 48ˆFÔ0å$Ÿ^š^¨IÝ,7¸Ñ,EÔ,EØ<Kð ,ñ Mô MˆÔð ÔÐ Ð$8Ò8Ð8Ý�*Ø$Ô0Ð0Ð0Ð2FÐ2FðHñ Iô Ið Iàˆr   r   r$  c                 ór  —  | |¦  «        }|j         |_         |j        j        |_        |j        }|j        }i }i }	|                     ¦   «         D ]N\  }
}t          |j        ¦  «                             ¦   «         } ||¦  «        ||<    ||¦  «        }|j        |	|<   ŒO| 	                    |||	|¬¦  «         |S )aª  Create a CHKInventory from an existing inventory.

        The content of inventory is copied into the chk_store, and a
        CHKInventory referencing that is returned.

        :param chk_store: A CHK capable VersionedFiles instance.
        :param inventory: The inventory to copy.
        :param maximum_size: The CHKMap node size limit.
        :param search_key_name: The identifier for the search key function
        )r  )
rU  r	  r   rP  rØ  r  r  r   rÜ  Ú_populate_from_dicts)r(  r)  Ú	inventoryr  rÇ  r  Úentry_to_bytesÚparent_id_basename_keyÚid_to_entry_dictÚparent_id_basename_dictr�   r    rÊ  Úp_id_keys                 r   Úfrom_inventoryzCHKInventory.from_inventoryi  så   € ð ��Ñ'Ô'ˆØ&Ô2ˆÔØ"œÔ/ˆŒàÔ/ˆØ!'Ô!?ÐØÐØ"$ÐØ$×1Ò1Ñ3Ô3ð 	>ð 	>‰KˆD�%Ý˜eœmÑ-Ô-×4Ò4Ñ6Ô6ˆCØ$2 N°5Ñ$9Ô$9Ð˜SÑ!Ø-Ð-¨eÑ4Ô4ˆHØ05´Ð# HÑ-Ð-à×#Ò# IÐ/?Ø$;È,ð 	$ñ 	Xô 	Xð 	Xàˆr   c                 ób  — t           j                             | j        ¦  «        }t           j                             |||d|¬¦  «        }t                                |||¦  «        | _        t           j                             |||d|¬¦  «        }t                                |||¦  «        | _        d S )Nr
   )r  Ú	key_widthr  r   )r  r	  r”  rÆ  r  Ú	from_dictrÉ  rË  )r   r)  r5  r6  r  r  Úroot_keys          r   r1  z!CHKInventory._populate_from_dicts‡  s¾   € å!Ô5×9Ò9ØÔ!ñ#ô #ˆå”>×+Ò+¨IÐ7GØ9EÐQRØ<Kð ,ñ Mô Mˆõ #Ÿ>š>¨)°XØ*9ñ;ô ;ˆÔå”>×+Ò+¨IØ,CØ9EÐQRØ<Kð ,ñ Mô Mˆõ .5¯^ª^¸IØ<DÀoñ.Wô .WˆÔ*Ð*Ð*r   c                 ó˜   — |j         �|j         }nd}t          ||j                             d¦  «        ¦  «                             ¦   «         S )zBCreate a key for a entry in a parent_id_basename_to_file_id index.Nr   rÑ  )r%   r   r   rÔ  rÜ  )r   r    r%   s      r   r  z$CHKInventory._parent_id_basename_key—  sD   € àŒ?Ð&ØœˆIˆIàˆIÝ˜9 e¤j×&7Ò&7¸Ñ&?Ô&?Ñ@Ô@×GÒGÑIÔIÐIr   c           	      óR  — |€t          j        | |¦  «        ‚| j                             |d¦  «        }|�|S 	 |                      t          | j                             t          |¦  «        g¦  «        ¦  «        d         ¦  «        S # t          $ r t          j        | |¦  «        ‚w xY w)z'map a single file_id -> InventoryEntry.Nr
   )
r   r7   rÃ  r”  r  rT  rÉ  rå  r   ÚStopIteration)r   r   r  s      r   r4   zCHKInventory.get_entryŸ  sµ   € àˆ?Ý”/ $¨Ñ0Ô0Ð0ØÔ,×0Ò0°¸$Ñ?Ô?ˆØÐØˆMð	1Ø×'Ò'Ý�TÔ%×/Ò/µ¸WÑ1FÔ1FÐ0GÑHÔHÑIÔIÈ!ÔLñNô Nð Nøåð 	1ð 	1ð 	1å”/ $¨Ñ0Ô0Ð0ð	1øøøs   ¸AB Â B&c                 ór  — g }g }|D ]J}| j                              |d¦  «        }|€|                     |¦  «         Œ5|                     |¦  «         ŒKd„ |D ¦   «         }| j                             |¦  «        D ]>\  }}|                      |¦  «        }|                     |¦  «         || j         |j        <   Œ?|S )zºSimilar to get_entry, but lets you query for multiple.

        The returned order is undefined. And currently if an item doesn't
        exist, it isn't included in the output.
        Nc                 óP   — g | ]#}t          |¦  «                             ¦   «         ‘Œ$S r   rÛ  rÝ  s     r   r  z*CHKInventory._getitems.<locals>.<listcomp>»  s*   € ÐAÐAÐA°!•[ ‘_”_×+Ò+Ñ-Ô-ÐAÐAÐAr   )rÃ  r”  r[   rÉ  rå  r  r   )	r   ræ  r  Ú	remainingr   r    Ú	file_keysÚfile_keyr  s	            r   rá  zCHKInventory._getitems­  sÙ   € ð ˆØˆ	Øð 	%ð 	%ˆGØÔ/×3Ò3°G¸TÑBÔBˆEØˆ}Ø× Ò  Ñ)Ô)Ð)Ð)à—’˜eÑ$Ô$Ð$Ð$ØAÐA°yÐAÑAÔAˆ	Ø#Ô/×9Ò9¸)ÑDÔDð 	?ð 	?‰OˆH�eØ×(Ò(¨Ñ/Ô/ˆEØ�MŠM˜%Ñ Ô Ð Ø9>ˆDÔ'¨¬Ñ6Ð6Øˆr   c           	      óÈ   — | j                              |d ¦  «        �dS t          t          | j                             t          |¦  «        g¦  «        ¦  «        ¦  «        dk    S )NTr
   )rÃ  r”  r  r  rÉ  rå  r   r  s     r   rQ   zCHKInventory.has_idÂ  sk   € àÔ&×*Ò*¨7°DÑ9Ô9ÐEØ�4Ý•4ØÔ×&Ò&­°GÑ(=Ô(=Ð'>Ñ?Ô?ñAô Añ Bô BØEFòGð 	Gr   c                 ó   — || j         k    S r   rO  r  s     r   r¾  zCHKInventory.is_rootÉ  s   € Ø˜$œ,Ò&Ð&r   c              #   ó¢   K  — |�J	 |                       |¦  «        }n$# t          $ r t          j        | |¬¦  «        ‚w xY w|V — |j        }|­HdS dS r©  )r4   rC  r   r7   r%   r£  s      r   r  z"CHKInventory._iter_file_id_parentsÌ  s}   è è € àÐ!ðBØ—^’^ GÑ,Ô,��øÝð Bð Bð BÝ”o¨4¸ÐAÑAÔAÐAðBøøøàˆHˆHˆHØ”lˆGð Ð!Ð!Ð!Ð!Ð!s   † œ!=c              #   ó\   K  — | j                              ¦   «         D ]\  }}|d         V — ŒdS )rˆ  r  N)rÉ  rå  )r   rÊ  Ú_s      r   r)  zCHKInventory.iter_all_idsÖ  sA   è è € àÔ&×0Ò0Ñ2Ô2ð 	ð 	‰FˆC�Ø�b”'ˆMˆMˆMˆMð	ð 	r   c              #   óØ   K  — | j                              ¦   «         D ]M\  }}|d         }| j                             |d¦  «        }|€|                      |¦  «        }|| j        |<   |V — ŒNdS )r‹  r   N)rÉ  rå  rÃ  r”  r  )r   rÊ  r    r   r;   s        r   r�  zCHKInventory.iter_just_entriesÛ  s…   è è € ð Ô*×4Ò4Ñ6Ô6ð 	ð 	‰JˆC�Ø˜!”fˆGØÔ,×0Ò0°¸$Ñ?Ô?ˆBØˆzØ×)Ò)¨%Ñ0Ô0�Ø79�Ô+¨GÑ4ØˆHˆHˆHˆHð	ð 	r   c           	      ó  — | j         rdS | j        }| j                             ¦   «         D ]4\  }}|d         }||vr|                      |¦  «        }|||<   Œ,||         }Œ5dx}}| j                             ¦   «         }|D ]ü\  }}	|dk    r&|	| j        k    rt          d|	›d| j        ›�¦  «        ‚Œ1|\  }
}||	         }|
|k    r|}n||
         }|j        dk    rt          d|
›d|j        ›d	�¦  «        ‚|j	        €i |_	        | 
                    d
¦  «        }||j	        v r)|j	        |         }||k    rt          d|›d|
›d�¦  «        ‚||j        k    rt          d|	›d|›d|j        ›�¦  «        ‚||j	        |<   Œýd| _         dS )z4Make sure all file-ids are in _fileid_to_entry_cacheNr   )r   r   zYData inconsistency detected. We expected data with key ("","") to match the root id, but z != rK   z^Data inconsistency detected. An entry in the parent_id_basename_to_file_id map has parent_id {z!} but the kind of that object is z not "directory"rÂ   z7Data inconsistency detected. Two entries with basename z! were found in the parent entry {rÜ   zPData inconsistency detected. In the parent_id_basename_to_file_id map, file_id {z} is listed as having basename z#, but in the id_to_entry map it is T)rÄ  rÃ  rÉ  rå  r  rË  rP  r‡   rH   Ú	_childrenr   r   )r   rð  rÊ  r    r   r;   Úlast_parent_idÚlast_parent_ieÚ	pid_itemsÚchild_file_idr%   ÚbasenameÚ	parent_ieÚexisting_ies                 r   r  zCHKInventory._preload_cacheë  s3  € àÔð 	ØˆFàÔ+ˆØÔ*×4Ò4Ñ6Ô6ð 	$ð 	$‰JˆC�Ø˜!”fˆGØ˜eÐ#Ð#Ø×)Ò)¨%Ñ0Ô0�Ø!#��g‘�à˜7”^��Ø*.Ð.ˆ˜ØÔ6×@Ò@ÑBÔBˆ	Ø"+ð #	/ð #	/ÑˆC�Ø�jÒ Ð Ø  D¤LÒ0Ð0Ý$˜*ð )6¨¨°t´|°|ð&Eñ Fô Fð Fð Ø"%ÑˆI�xØ�}Ô%ˆBØ˜NÒ*Ð*Ø*�	�	à! )Ô,�	ØŒ~ Ò,Ð,Ý �jð >G¸Y¸YÈ	ÌÈÈð"Xñ Yô Yð Yð Ô"Ð*Ø&(�	Ô#Ø—’ wÑ/Ô/ˆHØ˜9Ô.Ð.Ð.Ø'Ô1°(Ô;�Ø "Ò$Ð$Ý$˜*ð )1¨¨°)°)°)ð&=ñ >ô >ð >ð ˜2œ7Ò"Ð"Ý �jð %2 M M°8°8°8¸R¼W¸Wð	"Fñ Gô Gð Gð
 -/ˆIÔ Ñ)Ð)Ø!ˆÔÐÐr   c           	   #   ó˜  K  — | j                              |j         ¦  «        D �]¦\  }}}|d         }|�@|                     |¦  «        }|                     |¦  «        }|j        }|j        }	|j        }
nd}d}d}	d}
|�@|                      |¦  «        }|                      |¦  «        }|j        }|j        }|j        }nd}d}d}d}|€d|j        f}d}n|€|j        df}d}n|j        |j        f}d}d}|d         |d         k    rd}nl|d         d	k    r#|j        |j        k    s|j	        |j	        k    rd}n=|d         d
k    r|j
        |j
        k    rd}n|d         dk    r|j        |j        k    rd}||f}|	|f}|
|f}|s8|d         |d         k    r&|d         |d         k    r|d         |d         k    r�Œ˜|||f||||||fV — �Œ¨dS )zäGenerate a Tree.iter_changes change list between this and basis.

        :param basis: Another CHKInventory.
        :return: An iterator over the changes between self and basis, as per
            tree.iter_changes().
        r   N)FT)TF)TTFr
   TrJ   rL   rN   )rÉ  Úiter_changesr  rÄ   r%   r   r5   rH   r}   r|   r{   r   )r   ÚbasisrÊ  Úbasis_valueÚ
self_valuer   Úbasis_entryÚpath_in_sourceÚbasis_parentÚ
basis_nameÚbasis_executableÚ
self_entryÚpath_in_targetÚself_parentÚ	self_nameÚself_executablerH   Ú	versionedÚchanged_contentr  r   r5   s                         r   rU  zCHKInventory.iter_changes   sz  è è € ð Ô ×-Ò-¨eÔ.?Ñ@Ô@ð>	;ñ >	;Ñ(ˆC�˜jà˜!”fˆGØÐ&Ø#×3Ò3°KÑ@Ô@�Ø!&§¢¨wÑ!7Ô!7�Ø*Ô4�Ø(Ô-�
Ø#.Ô#9Ð Ð à!%�Ø#�Ø!�
Ø#'Ð ØÐ%Ø!×1Ò1°*Ñ=Ô=�
Ø!%§¢¨gÑ!6Ô!6�Ø(Ô2�Ø&œO�	Ø",Ô"7��à!%�Ø"�Ø �	Ø"&�ØÐ"à˜jœoÐ.�Ø)�	�	ØÐ#à#Ô(¨$Ð/�Ø)�	�	à#Ô(¨*¬/Ð:�Ø(�	Ø#ˆOØ�AŒw˜$˜qœ'Ò!Ð!Ø"&��Ø�a”˜FÒ"Ð"ØÔ(¨KÔ,AÒAÐAØ%Ô/°;Ô3HÒHÐHØ&*�OøØ�a”˜IÒ%Ð%ØÔ,°Ô0JÒJÐJØ&*�OøØ�a”Ð,Ò,Ð,ØÔ1Ø&Ô9ò:ð :à&*�OØ" KÐ0ˆFØ 	Ð*ˆDØ*¨OÐ<ˆJØ#ð Ø�q”	˜V AœYÒ&Ð&Ø�Q”˜4 œ7Ò"Ð"Ø˜q”M Z°¤]Ò2Ð2ñ à˜.¨.Ð9¸?Ø˜6 4¨¨zð;ð ;ð ;ð ;ñ ;ðy>	;ð >	;r   c                 ó*   — t          | j        ¦  «        S )z.Return the number of entries in the inventory.)r  rÉ  r>   s    r   r�  zCHKInventory.__len__j  s   € å�4Ô#Ñ$Ô$Ð$r   c                 ó¢  — t          |t          ¦  «        st                               | |¦  «        S g }| j                             |j        ¦  «        D ]|\  }}}|d         }|�|                     |¦  «        }nd}|�5|                      |¦  «        }|| j        |<   |                      |¦  «        }	nd}d}	| 	                    ||	||f¦  «         Œ}|S )r(  r   N)
rC   rÁ  rø   r2  rÉ  rU  rÄ   r  rÃ  r[   )
r   r+  r1  rÊ  Ú	old_valuerX  r   rz  r    r|  s
             r   r2  zCHKInventory._make_deltan  så   € å˜#�|Ñ,Ô,ð 	:Ý"×.Ò.¨t°SÑ9Ô9Ð9ØˆàÔ ×-Ò-¨c¬oÑ>Ô>ð	?ð 	?Ñ&ˆC�˜Jà˜!”fˆGØÐ$ØŸ;š; wÑ/Ô/��à�ØÐ%Ø×,Ò,¨ZÑ8Ô8�Ø7<�Ô+¨GÑ4ØŸ<š<¨Ñ0Ô0��à�Ø�Ø�LŠL˜( H¨g°uÐ=Ñ>Ô>Ð>Ð>Øˆr   c                 óV  — t          |t          ¦  «        rt          j        |¦  «        }n|}|g k    rdg}t          j        |Ž }| j                             |d¦  «        }|�|S | j        }|€dS | j        }d}|D ]¯}|€|}n|dz   |z   }| 	                    d¦  «        }| j                             |d¦  «        }	|	€lt          ||¦  «        g}
|                     |
¦  «        }|D ]4\  \  }}}	||k    s||k    r t          j        d|›d|›d|›d|›�¦  «        ‚Œ5|	€ dS |	| j        |<   |	}Œ°|S )zSee CommonInventory.path2id().r    NrA   rÑ  zcorrupt inventory lookup! ú )rC   r@  r   rA  r7  rÅ  r”  rP  rË  rÔ  r   rå  r   r   )r   rD  rE  r  Ú
current_idÚparent_id_indexÚcur_pathrQ  Úbasename_utf8r   Ú
key_filterr¬   r%   Ú	name_utf8s                 r   rû   zCHKInventory.path2id„  s¡  € õ �g�sÑ#Ô#ð 	1ÝÔ% gÑ.Ô.ˆEˆEàˆEØ˜"Š}ˆ}Ø˜$�ÝÔ&¨Ð0ˆGØÔ+×/Ò/°¸Ñ>Ô>ˆØÐØˆMØ”\ˆ
ØÐØ�4ØÔ<ˆØˆØð 	!ð 	!ˆHØÐØ#��à# c™>¨HÑ4�Ø$ŸOšO¨FÑ3Ô3ˆMØÔ0×4Ò4°X¸tÑDÔDˆGØˆÝ)¨*°mÑDÔDÐE�
Ø'×1Ò1°*Ñ=Ô=�Ø7<ð Oð OÑ3Ñ*�Y 	¨GØ  JÒ.Ð.°)¸}Ò2LÐ2LÝ$œo˜oØ?H¸y¸yÈ*È*È*ÐV_ÐV_ÐV_Ø?L¸}ð/Nñ Oô Oð Oð 3Mð �?Ø˜4˜4à;B�DÔ.¨xÑ8Ø ˆJˆJØÐr   c                 ó  — dg}| j         dk    rÄ|                     d| j         z  ¦  «         |                     d| j        z  ¦  «         |                     d| j                             ¦   «         d         fz  ¦  «         |                     d| j        z  ¦  «         |                     d| j                             ¦   «         d         fz  ¦  «         n­|                     d| j        z  ¦  «         |                     d| j        z  ¦  «         | j        �6|                     d| j                             ¦   «         d         fz  ¦  «         |                     d| j                             ¦   «         d         fz  ¦  «         |S )	z!Serialise the inventory to lines.r  r$  s   search_key_name: %s
s   root_id: %s
s"   parent_id_basename_to_file_id: %s
r   s   revision_id: %s
s   id_to_entry: %s
)rÆ  r[   rP  rË  rÊ  rU  rÉ  )r   r*  s     r   Úto_lineszCHKInventory.to_lines¬  s�  € à#Ð$ˆØÔ  HÒ,Ð,à�LŠLÐ1ØÔ%ñ'ñ (ô (ð (à�LŠLÐ)¨D¬LÑ8Ñ9Ô9Ð9Ø�LŠLÐ?ØÔ<×@Ò@ÑBÔBÀ1ÔEÐGñHñ Iô Ið Ià�LŠLÐ-°Ô0@Ñ@ÑAÔAÐAØ�LŠLÐ-°Ô1A×1EÒ1EÑ1GÔ1GÈÔ1JÐ0LÑLÑMÔMÐMÐMà�LŠLÐ-°Ô0@Ñ@ÑAÔAÐAØ�LŠLÐ)¨D¬LÑ8Ñ9Ô9Ð9ØÔ1Ð=Ø—’ÐCØ"Ô@×DÒDÑFÔFÀqÔIÐKñLñ Mô Mð Mà�LŠLÐ-°Ô1A×1EÒ1EÑ1GÔ1GÈÔ1JÐ0LÑLÑMÔMÐMØˆr   c                 ó6   — |                       | j        ¦  «        S )zGet the root entry.)r4   rP  r>   s    r   r	  zCHKInventory.rootÁ  s   € ð �~Š~˜dœlÑ+Ô+Ð+r   Nr•   )r   r$  )!r   r   r   r–   r   r�   rØ  rí  rZ  r™   rù  r  r„  Úclassmethodr/  r8  r1  r  r4   rá  rQ   r¾  r  r)  r�  r  rU  r�  r2  rû   rq  Úpropertyr	  r   r   r   rÁ  rÁ  •  s  € € € € € ðð ð(ð ð ðGð Gð Gð(=ð (=ð (=ðTF2ð F2ð F2ðP&ð &ð &ðP ð3ð 3ñ „\ð3ðð ð ðD 05ðhð hð hð hðT ð9ð 9ñ „[ð9ðv ðð ð ñ „[ðð:Wð Wð Wð Jð Jð Jð1ð 1ð 1ðð ð ð*Gð Gð Gð'ð 'ð 'ð#ð #ð #ðð ð ð
ð ð ð 3"ð 3"ð 3"ðjH;ð H;ð H;ðT%ð %ð %ðð ð ð,&ð &ð &ðPð ð ð* ð,ð ,ñ „Xð,ð ,ð ,r   rÁ  c                   ó6   — e Zd ZdZddgZd„ Zed„ ¦   «         ZdS )r  rœ   rL  Ú_chk_inventoryc                 ó\   — t                                | |||¦  «         d | _        || _        d S r   )r"   r   rL  rv  )r   r   r   r%   Úchk_inventorys        r   r   zCHKInventoryDirectory.__init__Ì  s3   € õ 	×Ò  g¨t°YÑ?Ô?Ð?ØˆŒØ+ˆÔÐÐr   c                 óä  — | j         �| j         S | j        j        €t          d¦  «        ‚i }| j        j        }t	          ¦   «         }|                     t          | j        ¦  «        g¬¦  «        D ]*\  \  }}}|                     t          |¦  «        ¦  «         Œ+t	          ¦   «         }|D ]I}| j        j	         
                    |d         d¦  «        }	|	�|	||	j        <   |                     |¦  «         ŒJ|                     |¦  «         | j        j        }
|
                     |¦  «        D ]>\  }}| j                             |¦  «        }	|	||	j        <   |	| j        j	        |d         <   Œ?|| _         |S )a¥  Access the list of children of this directory.

        With a parent_id_basename_to_file_id index, loads all the children,
        without loads the entire index. Without is bad. A more sophisticated
        proxy object might be nice, to allow partial loading of children as
        well when specific names are accessed. (So path traversal can be
        written in the obvious way but not examine siblings.).
        NzIInventories without parent_id_basename_to_file_id are no longer supported)rn  r   )rL  rv  rË  ÚAssertionErrorr  rå  r   r   r  rÃ  r”  r   Údifference_updaterÉ  r  )r   r  rk  Ú
child_keysr%   ro  r   ÚcachedÚfile_id_keyr    rÉ  rD   s               r   r�   zCHKInventoryDirectory.childrenÓ  s›  € ð Œ>Ð%Ø”>Ð!àÔÔ<ÐDÝ ð "Zñ [ô [ð [àˆð Ô-ÔKˆÝ‘U”Uˆ
Ø/>×/HÒ/HÝ'¨¬Ñ6Ô6Ð7ð 0Iñ 09ô 09ð 	2ð 	2Ñ+Ñ"ˆY˜	 Gà�NŠN�; wÑ0Ô0Ñ1Ô1Ð1Ð1Ý‘”ˆØ%ð 	(ð 	(ˆKØÔ'Ô>×BÒBØ˜A” ñ&ô &ˆEàÐ Ø%*��u”zÑ"Ø—
’
˜;Ñ'Ô'Ð'øØ×$Ò$ VÑ,Ô,Ð,àÔ)Ô5ˆØ"-×"7Ò"7¸
Ñ"CÔ"Cð 	Oð 	OÑˆK˜ØÔ'×7Ò7¸Ñ>Ô>ˆEØ!&ˆF�5”:ÑØINˆDÔÔ6°{À1´~ÑFÐFØˆŒØˆr   N)r   r   r   r–   r—   r   rt  r�   r   r   r   r  r  Ç  sO   € € € € € Ø&Ð&àÐ.Ð/€Ið,ð ,ð ,ð ð&ð &ñ „Xð&ð &ð &r   r  )rK   rJ   rL   rN   Nc                 óÖ   — |€t                                |¦  «        }t          |¦  «        }	 t          |          }n## t          $ r t          j        || ¦  «        ‚w xY w ||||¦  «        S )züCreate an inventory entry.

    :param kind: the type of inventory entry to create.
    :param name: the basename of the entry.
    :param parent_id: the parent_id of the entry.
    :param file_id: the file_id to use. if None, one will be created.
    )rœ  Úgen_file_idr´  Úentry_factoryrC  r   ÚBadFileKindError)rH   r   r%   r   Úfactorys        r   r4  r4  	  s|   € ð €Ý×*Ò*¨4Ñ0Ô0ˆÝ! $Ñ'Ô'€Dð2Ý Ô%ˆˆøÝð 2ð 2ð 2ÝÔ% d¨DÑ1Ô1Ð1ð2øøøàˆ7�7˜D )Ñ,Ô,Ð,s	   ­; » Ac                 óp   — t          j        | ¦  «        \  }}|| k    r|r|S t          j        | ¦  «        ‚| S )zÍNormalize name.

    :raises InvalidNormalization: When name is not normalized, and cannot be
        accessed on this platform by the normalized path.
    :return: The NFC normalised version of name.
    )r   Únormalized_filenamer   ÚInvalidNormalization)r   Ú	norm_nameÚ
can_accesss      r   r´  r´  	  sJ   € õ $Ô7¸Ñ=Ô=Ñ€IˆzØ�DÒÐØð 	4ØÐõ Ô-¨dÑ3Ô3Ð3Ø€Kr   z	^[^/\\]+$c                 óP   — t          t                               | ¦  «        ¦  «        S r   )rú   Ú_NAME_REÚmatchrB   s    r   rµ  rµ  0	  s   € Ý•—’˜tÑ$Ô$Ñ%Ô%Ð%r   c              #   ó  K  — t          ¦   «         }| D ]p}t          |¦  «        dz   }|                     |d         ¦  «         t          |¦  «        |k    r*t          j        |d         p|d         |d         d¦  «        ‚|V — ŒqdS )ziDecorate a delta and check that the file ids in it are unique.

    :return: A generator over delta.
    r
   r   r   zrepeated file_idN©r  r  r  r   rw  )r1  Úidsrß  Úlengths       r   rq  rq  4	  s˜   è è € õ
 ‰%Œ%€CØð ð ˆÝ�S‘”˜A‘ˆØ�Š��Q”ÑÔÐÝˆs‰8Œ8�vÒÐÝÔ*¨4°¬7Ð+=°d¸1´g¸tÀA¼wØ+=ñ?ô ?ð ?àˆ
ˆ
ˆ
ˆ
ðð r   c              #   óø   K  — t          ¦   «         }| D ]f}t          |¦  «        dz   }|d         }|�D|                     |¦  «         t          |¦  «        |k    rt          j        ||d         d¦  «        ‚|V — ŒgdS )zjDecorate a delta and check that the new paths in it are unique.

    :return: A generator over delta.
    r
   Nr   úrepeated pathr�  ©r1  Úpathsrß  r�  r�   s        r   rr  rr  C	  óŒ   è è € õ
 ‰EŒE€EØð ð ˆÝ�U‘”˜a‘ˆØ�AŒwˆØÐØ�IŠI�d‰OŒOˆOÝ�5‰zŒz˜VÒ#Ð#ÝÔ.¨t°T¸!´W¸oÑNÔNÐNØˆ
ˆ
ˆ
ˆ
ðð r   c              #   óø   K  — t          ¦   «         }| D ]f}t          |¦  «        dz   }|d         }|�D|                     |¦  «         t          |¦  «        |k    rt          j        ||d         d¦  «        ‚|V — ŒgdS )zjDecorate a delta and check that the old paths in it are unique.

    :return: A generator over delta.
    r
   r   Nr   r‘  r�  r’  s        r   rs  rs  S	  r”  r   c              #   ó&  K  — | D ]‹}|d         }|d         €-t          j        |d         p|d         |d         d|z  ¦  «        ‚t          |d         t          ¦  «        s-t          j        |d         p|d         |d         d|z  ¦  «        ‚|V — ŒŒdS )zcDecorate a delta and check that the ids in it are valid.

    :return: A generator over delta.
    rõ  r   Nr   r
   zentry with file_id None %rzentry with non bytes file_id %r)r   rw  rC   rD   ©r1  rß  r    s      r   ru  ru  c	  s¿   è è € ð
 ð ð ˆØ�Q”ˆØ�Œ7ˆ?ÝÔ*¨4°¬7Ð+=°d¸1´g¸tÀA¼wØ+GÈ%Ñ+OñQô Qð Qå˜$˜qœ'¥5Ñ)Ô)ð 	VÝÔ*¨4°¬7Ð+=°d¸1´g¸tÀA¼wØ+LÈuÑ+TñVô Vð Vàˆ
ˆ
ˆ
ˆ
ðð r   c              #   ó¬   K  — | D ]N}|d         }|�>|j         |d         k    r-t          j        |d         p|d         |d         d|z  ¦  «        ‚|V — ŒOdS )zqDecorate a delta and check that the ids in it match the entry.file_id.

    :return: A generator over delta.
    rõ  Nr   r   r
   zmismatched id with %r)r   r   rw  r—  s      r   rt  rt  s	  s�   è è € ð
 ð ð ˆØ�Q”ˆØÐØŒ}  Q¤Ò'Ð'ÝÔ.¨t°A¬wÐ/A¸$¸q¼'À4ÈÄ7Ø/FÈÑ/NñPô Pð Pàˆ
ˆ
ˆ
ˆ
ðð r   c              #   óÈ   K  — | D ]\}|d         }|d         }|€$|�"t          j        |d         |d         d¦  «        ‚|�|€t          j        ||d         d¦  «        ‚|V — Œ]dS )zmDecorate a delta and check that the new_path and entry are paired.

    :return: A generator over delta.
    r
   rõ  Nr   zEntry with no new_pathznew_path with no entry)r   rw  )r1  rß  r|  r    s       r   rv  rv  �	  s�   è è € ð
 ð 	ð 	ˆØ˜”7ˆØ�Q”ˆØÐ Ð 1ÝÔ*¨4°¬7°D¸´GØ+CñEô Eð EàÐ E MÝÔ*¨8°T¸!´WØ+CñEô Eð Eàˆ
ˆ
ˆ
ˆ
ð	ð 	r   c                 óÐ   — |                       ¦   «         }t          d|                      ¦   «         ¦  «        }|D ],\  }}|                     |                     ¦   «         ¦  «         Œ-|S )z„Create a new inventory that has the same contents as a specified tree.

    :param tree: Revision tree to create inventory from
    N)r%  rS  Úget_revision_idr  r_   )r,   r>  r:   r�   Ú	inv_entrys        r   Úmutable_inventory_from_treer�  ’	  sg   € ð
 ×&Ò&Ñ(Ô(€GÝ
�D˜$×.Ò.Ñ0Ô0Ñ
1Ô
1€CØ"ð "ð "‰ˆˆiØ�Š�	—’Ñ Ô Ñ!Ô!Ð!Ð!Ø€Jr   r   )&r¿  Úcollectionsr   r   Úglobalsr    r   r   r   r	   Ústatic_tupler   ÚInternalBzrErrorr   r   r   r"   r›   r´   rÙ   rí   rø   rS  rÁ  r  r�  r4  r´  Úlazy_compilerŠ  rµ  rq  rr  rs  ru  rt  rv  r�  r   r   r   ú<module>r£     s‡  ðð8 €à Ð Ð Ð Ð Ð ð &Ð %Ð %Ð %Ð %Ð %Ø €ˆGˆG‰IŒIð ñ ô ð ðð ð ð ð ð ð ð ð ð ð ð ð &Ð %Ð %Ð %Ð %Ð %ðð ð ð ð �vÔ.ñ ô ð ðð ð ð ð �f”oñ ô ð ðCð Cð Cð Cð Cñ Cô Cð CðL
$ð $ð $ð $ð $˜ñ $ô $ð $ðNgð gð gð gð g�Nñ gô gð gðTIð Ið Ið Ið I�Nñ Iô Ið IðX"ð "ð "ð "ð "�Nñ "ô "ð "ðJWð Wð Wð Wð Wñ Wô Wð Wðt
jFð jFð jFð jFð jF�ñ jFô jFð jFðZo,ð o,ð o,ð o,ð o,�?ñ o,ô o,ð o,ðd3ð 3ð 3ð 3ð 3Ð.ñ 3ô 3ð 3ðn $ØØØ#ð	ð €ð-ð -ð -ð -ð$ð ð ð, #ˆ:Ô" <Ñ0Ô0€ð&ð &ð &ðð ð ðð ð ð ð ð ð ð ð ð ð ð ðð ð ð"	ð 	ð 	ð 	ð 	r   