§
    cÌc”=  ã                   ó2  — d Z dgZddlmZ ddlmZ ddlmZ ddlmZ dZ	 G d	„ d
ej
        ¦  «        Z G d„ dej
        ¦  «        Zd„ Zd„ Zd„ Zd„ Zej        fd„Zej        fd„Zej        fd„Zej        fd„Z G d„ d¦  «        Z G d„ d¦  «        Zd„ ZdS )zÖInventory delta serialisation.

See doc/developers/inventory.txt for the description of the format.

In this module the interesting classes are:
 - InventoryDeltaSerializer - object to read/write inventory deltas.
ÚInventoryDeltaSerializeré   )Úerrors)Úbasenameé   )Ú	inventory)ÚNULL_REVISIONs!   bzr inventory delta v1 (bzr 1.14)c                   ó&   ‡ — e Zd ZdZdZˆ fd„Zˆ xZS )ÚInventoryDeltaErrorz>An error when serializing or deserializing an inventory delta.Tc                 óH   •— || _          t          ¦   «         j        di |¤Ž d S )N© )Ú_fmtÚsuperÚ__init__)ÚselfÚformat_stringÚkwargsÚ	__class__s      €ú</usr/lib/python3/dist-packages/breezy/bzr/inventory_delta.pyr   zInventoryDeltaError.__init__+   s-   ø€ à!ˆŒ	Ø�‰ŒÔÐ"Ð"˜6Ð"Ð"Ð"Ð"Ð"ó    )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úinternal_errorr   Ú__classcell__)r   s   @r   r
   r
   #   sE   ø€ € € € € ØHÐHð
 €Nð#ð #ð #ð #ð #ð #ð #ð #ð #r   r
   c                   ó   — e Zd ZdZdZdS )ÚIncompatibleInventoryDeltaz The delta could not be deserialised because its contents conflict with
    the allow_versioned_root or allow_tree_references flags of the
    deserializer.
    FN)r   r   r   r   r   r   r   r   r   r   1   s   € € € € € ðð ð €N€N€Nr   r   c                 ó   — dS )zmSerialize the content component of entry which is a directory.

    :param entry: An InventoryDirectory.
    ó   dirr   )Úentrys    r   Ú_directory_contentr!   9   s	   € ð
 ˆ6r   c                 óv   — | j         rd}nd}| j        || j        f}d|v rt          d| j        ¬¦  «        ‚d|z  S )zcSerialize the content component of entry which is a file.

    :param entry: An InventoryFile.
    ó   Yr   Nz"Missing size or sha for %(fileid)r©Úfileids   file %d %s %s)Ú
executableÚ	text_sizeÚ	text_sha1r
   Úfile_id)r    Ú
exec_bytesÚsize_exec_shas      r   Ú_file_contentr,   A   sc   € ð
 Ôð Øˆ
ˆ
àˆ
Ø”O Z°´Ð@€MØˆ}ÐÐÝ!Ø0¸¼ðHñ Hô Hð 	Hà$ }Ñ4Ð4r   c                 óp   — | j         }|€t          d| j        ¬¦  «        ‚d|                     d¦  «        z  S )zfSerialize the content component of entry which is a symlink.

    :param entry: An InventoryLink.
    NzMissing target for %(fileid)rr$   s   link %sÚutf8)Úsymlink_targetr
   r)   Úencode)r    Útargets     r   Ú_link_contentr2   Q   sJ   € ð
 Ô!€FØ€~Ý!Ø+°E´MðCñ Cô Cð 	Cà˜6Ÿ=š=¨Ñ0Ô0Ñ0Ð0r   c                 óJ   — | j         }|€t          d| j        ¬¦  «        ‚d|z  S )zlSerialize the content component of entry which is a tree-reference.

    :param entry: A TreeReference.
    Nz)Missing reference revision for %(fileid)rr$   s   tree %s)Úreference_revisionr
   r)   )r    Útree_revisions     r   Ú_reference_contentr6   ]   s?   € ð
 Ô,€MØÐÝ!Ø7ÀÄðOñ Oô Oð 	Oà˜=Ñ(Ð(r   c                 ó.   —  ||||¦  «        }||_         |S )z6Convert a dir content record to an InventoryDirectory.)Úrevision©ÚcontentÚnameÚ	parent_idr)   Úlast_modifiedÚ_typeÚresults          r   Ú_dir_to_entryr@   i   s#   € ð ˆU�7˜D )Ñ,Ô,€FØ#€F„OØ€Mr   c                 óª   —  ||||¦  «        }||_         t          | d         ¦  «        |_        | d         |_        | d         rd|_        nd|_        |S )z1Convert a dir content record to an InventoryFile.r   é   r   TF)r8   Úintr'   r(   r&   r9   s          r   Ú_file_to_entryrD   q   s`   € ð ˆU�7˜D )Ñ,Ô,€FØ#€F„OÝ˜7 1œ:‘”€FÔØ˜q”z€FÔØˆq„zð "Ø ˆÔÐà!ˆÔØ€Mr   c                 ón   —  ||||¦  «        }||_         | d                              d¦  «        |_        |S )z2Convert a link content record to an InventoryLink.r   r.   )r8   Údecoder/   r9   s          r   Ú_link_to_entryrG      s=   € ð ˆU�7˜D )Ñ,Ô,€FØ#€F„OØ# AœJ×-Ò-¨fÑ5Ô5€FÔØ€Mr   c                 óH   —  ||||¦  «        }||_         | d         |_        |S )z1Convert a tree content record to a TreeReference.r   )r8   r4   r9   s          r   Ú_tree_to_entryrI   ˆ   s/   € ð ˆU�7˜D )Ñ,Ô,€FØ#€F„OØ '¨¤
€FÔØ€Mr   c                   ó*   — e Zd ZdZd„ Zd„ Zd„ Zd„ ZdS )r   zSerialize inventory deltas.c                 ó|   — || _         || _        t          t          t          dœ| _        |rt          | j        d<   dS dS )a  Create an InventoryDeltaSerializer.

        :param versioned_root: If True, any root entry that is seen is expected
            to be versioned, and root entries can have any fileid.
        :param tree_references: If True support tree-reference entries.
        )Ú	directoryÚfileÚsymlinkztree-referenceN)Ú_versioned_rootÚ_tree_referencesr!   r,   r2   Ú_entry_to_contentr6   )r   Úversioned_rootÚtree_referencess      r   r   z!InventoryDeltaSerializer.__init__”   sW   € ð  .ˆÔØ /ˆÔå+Ý!Ý$ð"
ð "
ˆÔð
 ð 	JÝ7IˆDÔ"Ð#3Ñ4Ð4Ð4ð	Jð 	Jr   c                 ót  — t          |t          ¦  «        s"t          d                     |¦  «        ¦  «        ‚t          |t          ¦  «        s"t          d                     |¦  «        ¦  «        ‚g d¢}| j        }|D ]J} |||¦  «        }|j        t          k    rt          d|d         ¬¦  «        ‚|                     |¦  «         ŒK|                     ¦   «          dt          z  |d<   d	|z  |d
<   d|z  |d<   d|  
                    | j        ¦  «        z  |d<   d|  
                    | j        ¦  «        z  |d<   |S )ad  Return a line sequence for delta_to_new.

        Both the versioned_root and tree_references flags must be set via
        require_flags before calling this.

        :param old_name: A UTF8 revision id for the old inventory.  May be
            NULL_REVISION if there is no older inventory and delta_to_new
            includes the entire inventory contents.
        :param new_name: The version name of the inventory we create with this
            delta.
        :param delta_to_new: An inventory delta such as Inventory.apply_delta
            takes.
        :return: The serialized delta as lines.
        z old_name should be str, got {!r}z new_name should be str, got {!r})r   r   r   r   r   z&to_line gave non-bytes output %(line)réÿÿÿÿ©Úlines   format: %s
é    s   parent: %s
r   s   version: %s
r   s   versioned_root: %s
rB   s   tree_references: %s
é   )Ú
isinstanceÚbytesÚ	TypeErrorÚformatÚ_delta_item_to_liner   r
   ÚappendÚsortÚFORMAT_1Ú_serialize_boolrO   rP   )r   Úold_nameÚnew_nameÚdelta_to_newÚlinesÚto_lineÚ
delta_itemrW   s           r   Údelta_to_linesz'InventoryDeltaSerializer.delta_to_lines¥   se  € õ ˜(¥EÑ*Ô*ð 	QÝÐ>×EÒEÀhÑOÔOÑPÔPÐPÝ˜(¥EÑ*Ô*ð 	QÝÐ>×EÒEÀhÑOÔOÑPÔPÐPØ)Ð)Ð)ˆØÔ*ˆØ&ð 	ð 	ˆJØ�7˜: xÑ0Ô0ˆDàŒ~¥Ò&Ð&Ý)Ø<À5ÈÄ9ðNñ Nô Nð Nà�LŠL˜ÑÔÐÐØ�
Š
‰ŒˆØ"¥XÑ-ˆˆa‰Ø" XÑ-ˆˆa‰Ø# hÑ.ˆˆa‰Ø*¨T×-AÒ-AØÔ ñ."ô ."ñ "ˆˆa‰à+¨d×.BÒ.BØÔ!ñ/#ô /#ñ #ˆˆa‰àˆr   c                 ó   — |rdS dS )Nó   trueó   falser   ©r   Úvalues     r   rb   z(InventoryDeltaSerializer._serialize_boolË   s   € Øð 	Ø�7à�8r   c                 óØ  — |\  }}}}|€&d|                      d¦  «        z   }d}d}	t          }
d}n±|€d}nd|                      d¦  «        z   }|dk    rt          d|›�¦  «        ‚d|                      d¦  «        z   }|j        pd}	|j        }
|dk    r | j        s|
|k    rt          d	||
|¬
¦  «        ‚|
€t          d|¬¦  «        ‚ | j        |j                 |¦  «        }d||||	|
|fz  S )zConvert delta_item to a line.Nó   /r.   ó   Noner   s	   deleted  ú/zMBad inventory delta: '/' is not a valid newpath (should be '') in delta item z9Version present for / in %(fileid)r (%(last)r != %(new)r))r%   ÚlastÚnewz no version for fileid %(fileid)rr$   s   %s %s %s %s %s %s
)	r0   r   ÚAssertionErrorr<   r8   rO   r
   rQ   Úkind)r   rh   Únew_versionÚoldpathÚnewpathr)   r    Úoldpath_utf8Únewpath_utf8r<   r=   r:   s               r   r^   z,InventoryDeltaSerializer._delta_item_to_lineÑ   sa  € à+5Ñ(ˆ�˜' 5Øˆ?à '§.¢.°Ñ"8Ô"8Ñ8ˆLØ"ˆLØˆIÝ)ˆMØ(ˆGˆGàˆØ&��à# g§n¢n°VÑ&<Ô&<Ñ<�Ø˜#Š~ˆ~Ý$�nà9C¸ðFñGô Gð Gð   '§.¢.°Ñ"8Ô"8Ñ8ˆLàœÐ.¨3ˆIà!œNˆMà˜tÒ#Ð#¨DÔ,@Ð#ð ! KÒ/Ð/Ý-ð1à&¨]ÀðMñ Mô Mð Mð Ð$Ý)Ø6¸wðHñ Hô Hð Hà8�dÔ,¨U¬ZÔ8¸Ñ?Ô?ˆGØ5Ø˜|¨W°iÀØðñð 	r   N)r   r   r   r   r   ri   rb   r^   r   r   r   r   r   ‘   sZ   € € € € € Ø%Ð%ðJð Jð Jð"$ð $ð $ðLð ð ð-ð -ð -ð -ð -r   c                   ó&   — e Zd ZdZdd„Zd„ Zd„ ZdS )ÚInventoryDeltaDeserializerzDeserialize inventory deltas.Tc                 ó"   — || _         || _        dS )a
  Create an InventoryDeltaDeserializer.

        :param versioned_root: If True, any root entry that is seen is expected
            to be versioned, and root entries can have any fileid.
        :param tree_references: If True support tree-reference entries.
        N)Ú_allow_versioned_rootÚ_allow_tree_references)r   Úallow_versioned_rootÚallow_tree_referencess      r   r   z#InventoryDeltaDeserializer.__init__  s   € ð &:ˆÔ"Ø&;ˆÔ#Ð#Ð#r   c                 óD   — |dk    rdS |dk    rdS t          d|¬¦  «        ‚)Nrk   Trl   Fzvalue %(val)r is not a bool)Úval)r
   rm   s     r   Ú_deserialize_boolz,InventoryDeltaDeserializer._deserialize_bool  s6   € Ø�GÒÐØ�4Ø�hÒÐØ�5å%Ð&CÈÐOÑOÔOÐOr   c                 óö  — |st          d¦  «        ‚|d                              d¦  «        st          d|d         ¬¦  «        ‚d„ |D ¦   «         }|r|d         dt          z  k    rt          d	|dd
…         ¬¦  «        ‚t          |¦  «        dk     s|d
                              d¦  «        st          d¦  «        ‚|d
         dd…         }t          |¦  «        dk     s|d                              d¦  «        st          d¦  «        ‚|d         dd…         }t          |¦  «        dk     s|d                              d¦  «        st          d¦  «        ‚|                      |d         dd…         ¦  «        }t          |¦  «        dk     s|d                              d¦  «        st          d¦  «        ‚|                      |d         dd…         ¦  «        }| j        s|rt          d¦  «        ‚g }t          ¦   «         }t          |¦  «        }t          d¦  «        D ]}	t          |¦  «         Œ|D �]¿}
|
                     dd¦  «        \  }}}}}}|pd}||v rt          d|¬¦  «        ‚|                     |¦  «         |d k    r|s||k    rt          d!|
¬¦  «        ‚|d"k    r|dd…         d#k    rt          d$|
¬¦  «        ‚|                     d%¦  «        r+|d&u rt          d'|
¬¦  «        ‚| j        st          d(¦  «        ‚|d"k    rd}n>|dd
…         d k    rt          d)|¬*¦  «        ‚|d
d…         }|                     d+¦  «        }|d"k    rd}n>|dd
…         d k    rt          d,|¬*¦  «        ‚|d
d…         }|                     d+¦  «        }t!          |                     d¦  «        ¦  «        }|d         d-k    rd}nt#          |||||¦  «        }||||f}|                     |¦  «         �ŒÁ|||||fS ).a«  Parse the text bytes of a serialized inventory delta.

        If versioned_root and/or tree_references flags were set via
        require_flags, then the parsed flags must match or a BzrError will be
        raised.

        :param lines: The lines to parse. This can be obtained by calling
            delta_to_lines.
        :return: (parent_id, new_id, versioned_root, tree_references,
            inventory_delta)
        zinventory delta is emptyrU   ó   
zlast line not empty: %(line)rrV   c                 ó8   — g | ]}|                      d ¦  «        ‘ŒS )r‡   )Úrstrip)Ú.0rW   s     r   ú
<listcomp>z?InventoryDeltaDeserializer.parse_text_bytes.<locals>.<listcomp>(  s$   € Ð6Ð6Ð6¨�—’˜UÑ#Ô#Ð6Ð6Ð6r   rX   s
   format: %szunknown format %(line)rr   r   s   parent: zmissing parent: markeré   NrB   s	   version: zmissing version: markeré	   rY   s   versioned_root: zmissing versioned_root: markeré   é   s   tree_references: zmissing tree_references: markeré   zversioned_root not allowedó    zduplicate file id %(fileid)rr$   rp   zVersioned root found: %(line)rrq   ó   :z"special revisionid found: %(line)rs   tree FzGTree reference found (but header said tree_references: false): %(line)rzTree reference not allowedz1oldpath invalid (does not start with /): %(path)r)Úpathr.   z1newpath invalid (does not start with /): %(path)rs   deleted)r
   Úendswithra   ÚlenÚ
startswithr…   r   r   ÚsetÚiterÚrangeÚnextÚsplitÚaddr€   rF   ÚtupleÚ_parse_entryr_   )r   rf   Údelta_parent_idÚdelta_version_idÚdelta_versioned_rootÚdelta_tree_referencesr?   Úseen_idsÚ	line_iterÚirW   rz   r{   r)   r<   r=   r:   rx   ry   Úcontent_tupler    rh   s                         r   Úparse_text_bytesz+InventoryDeltaDeserializer.parse_text_bytes  s÷  € ð ð 	,Ý%Ø*ñ,ô ,ð ,à�RŒy×!Ò! %Ñ(Ô(ð 	AÝ%Ø/°e¸B´iðAñ Aô Að Aà6Ð6°Ð6Ñ6Ô6ˆØð 	<˜˜aœ MµHÑ$<Ò<Ð<Ý%Ø)°°a¸°c´
ð<ñ <ô <ð <åˆu‰:Œ:˜Š>ˆ>  q¤×!4Ò!4°[Ñ!AÔ!Aˆ>Ý%Ð&>Ñ?Ô?Ð?Ø œ( 1 2 2œ,ˆÝˆu‰:Œ:˜Š>ˆ>  q¤×!4Ò!4°\Ñ!BÔ!Bˆ>Ý%Ð&?Ñ@Ô@Ð@Ø  œ8 A B Bœ<ÐÝˆu‰:Œ:˜Š>ˆ>  q¤×!4Ò!4Ð5HÑ!IÔ!Iˆ>Ý%Ð&FÑGÔGÐGØ#×5Ò5°e¸A´h¸r¸s¸s´mÑDÔDÐÝˆu‰:Œ:˜Š>ˆ>  q¤×!4Ò!4Ð5IÑ!JÔ!Jˆ>Ý%Ð&GÑHÔHÐHØ $× 6Ò 6°u¸Q´xÀÀÀ´}Ñ EÔ EÐØÔ*ð 	KÐ/Cð 	KÝ,Ð-IÑJÔJÐJØˆÝ‘5”5ˆÝ˜‘K”Kˆ	Ý�q‘”ð 	ð 	ˆAÝ�‰OŒOˆOˆOØð 5	&ñ 5	&ˆDàŸ:š: g¨qÑ1Ô1ñˆ\˜<¨°)¸]ØØ!Ð) TˆIØ˜(Ð"Ð"Ý)Ø2¸7ðDñ Dô Dð Dà�LŠL˜Ñ!Ô!Ð!Ø Ò$Ð$Ð-AÐ$Ø!Ð%5Ò5Ð5õ *Ø4¸4ðAñ Aô Að Aà Ò(Ð(¨]¸2¸3¸3Ô-?À4Ò-GÐ-Gõ *Ø8¸tðEñ Eô Eð Eà×!Ò! +Ñ.Ô.ð 6Ø(¨EÐ1Ð1Ý-ð<ØBFðHñ Hô Hð Hð Ô4ð 6Ý4Ø4ñ6ô 6ð 6à˜wÒ&Ð&Ø��Ø˜b˜q˜bÔ! TÒ)Ð)Ý)ØGØ%ð'ñ 'ô 'ð 'ð  ,¨A¨B¨BÔ/�Ø&×-Ò-¨fÑ5Ô5�Ø˜wÒ&Ð&Ø��Ø˜b˜q˜bÔ! TÒ)Ð)Ý)ØGØ%ð'ñ 'ô 'ð 'ð
  ,¨A¨B¨BÔ/�Ø&×-Ò-¨fÑ5Ô5�Ý! '§-¢-°Ñ"8Ô"8Ñ9Ô9ˆMØ˜QÔ :Ò-Ð-Ø��å$Ø˜W i°ÀñOô O�à! 7¨G°UÐ;ˆJØ�MŠM˜*Ñ%Ô%Ð%Ñ%ØÐ!1Ð3GØ% vð/ð 	/r   N)TT)r   r   r   r   r   r…   r§   r   r   r   r}   r}     sT   € € € € € Ø'Ð'ð<ð <ð <ð <ðPð Pð Pð`/ð `/ð `/ð `/ð `/r   r}   c                 óÔ   — t           t          t          t          dœ}|d         }|                      d¦  «        rt
          ‚t          | ¦  «        } ||d                  |||||¦  «        S )N)r   s   files   links   treerX   rr   )r@   rD   rG   rI   r–   ru   r   )r“   r)   r<   r=   r:   Úentry_factoryrv   r;   s           r   rž   rž   y  sr   € åÝÝÝð	ð €Mð �1Œ:€DØ‡‚�sÑÔð ÝÐÝ�D‰>Œ>€DØ$ˆ=˜ œÔ$Ø��y '¨=ñ:ô :ð :r   N)r   Ú__all__Ú r   Úosutilsr   r   r8   r   ra   ÚBzrErrorr
   r   r!   r,   r2   r6   ÚInventoryDirectoryr@   ÚInventoryFilerD   ÚInventoryLinkrG   ÚTreeReferencerI   r   r}   rž   r   r   r   ú<module>r²      så  ðð"ð ð &Ð
&€à Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø $Ð $Ð $Ð $Ð $Ð $à/€ð#ð #ð #ð #ð #˜&œ/ñ #ô #ð #ðð ð ð ð  ¤ñ ô ð ðð ð ð5ð 5ð 5ð 	1ð 	1ð 	1ð	)ð 	)ð 	)ð "Ô4ðð ð ð ð #Ô0ðð ð ð ð #Ô0ðð ð ð ð #Ô0ðð ð ð ðmð mð mð mð mñ mô mð mð`u/ð u/ð u/ð u/ð u/ñ u/ô u/ð u/ðp:ð :ð :ð :ð :r   