§
    cÌc©,  ã                   ó    — d Z ddlZddlZddlZddlmZmZ ej         ej        d¦  «        j	        fd„Z
d„ Zd„ Zd	„ Zddi fd
„Zd„ Zd„ Zd„ ZdS )z4Python implementations of Dirstate Helper functions.é    Né   )ÚDirStateÚDirstateCorruptú>6Lc           
      óÒ   —  | || j         dz  t          | j        ¦  «        dz  t          | j        ¦  «        dz  | j        dz  | j        dz  | j        ¦  «        ¦  «        dd…         S )a  Convert stat values into a packed representation

    Not all of the fields from the stat included are strictly needed, and by
    just encoding the mtime and mode a slight speed increase could be gained.
    However, using the pyrex version instead is a bigger win.
    l   ÿÿ Néÿÿÿÿ)Úst_sizeÚintÚst_mtimeÚst_ctimeÚst_devÚst_inoÚst_mode)ÚstÚ_b64Ú_packs      úA/usr/lib/python3/dist-packages/breezy/bzr/_dirstate_helpers_py.pyÚ	pack_statr      sw   € ð ˆ4���b”j :Ñ-­s°2´;Ñ/?Ô/?À*Ñ/LÝ˜"œ+Ñ&Ô&¨Ñ3°R´YÀÑ5KØ”i *Ñ,¨b¬jñ:ô :ñ ;ô ;à;>¸B¸3ô@ð @ó    c                 óˆ   — t          j        dt          j        | ¦  «        ¦  «        \  }}}}}}t	          ||||||¬¦  «        S )z{Turn a packed_stat back into the stat fields.

    This is meant as a debugging tool, should not be used in real code.
    r   )r	   r   r   r   r   r   )ÚstructÚunpackÚbinasciiÚ
a2b_base64Údict)Úpacked_statr	   r   r   r   r   r   s          r   Ú_unpack_statr   )   sT   € õ ”˜e¥XÔ%8¸Ñ%EÔ%EÑFÔFñ€Wˆh˜ &¨&ØÝ˜¨(¸XØ f°gð?ñ ?ô ?ð ?r   c                 ó�   — t          | ¦  «        }d}||k     r.||z   dz  }| |         }t          ||¦  «        r|dz   }n|}||k     °.|S )ah  Return the index where to insert path into paths.

    This uses the dirblock sorting. So all children in a directory come before
    the children of children. For example::

        a/
          b/
            c
          d/
            e
          b-c
          d-e
        a-a
        a=c

    Will be sorted as::

        a
        a-a
        a=c
        a/b
        a/b-c
        a/d
        a/d-e
        a/b/c
        a/d/e

    :param paths: A list of paths to search through
    :param path: A single path to insert
    :return: An offset where 'path' can be inserted.
    :seealso: bisect.bisect_left
    r   é   r   ©ÚlenÚ_lt_path_by_dirblock©ÚpathsÚpathÚhiÚloÚmidÚcurs         r   Ú_bisect_path_leftr*   4   sh   € õB 
ˆU‰Œ€BØ	
€BØ
ˆrŠ'ˆ'Ø�B‰w˜1‰nˆà�CŒjˆÝ  TÑ*Ô*ð 	Ø�q‘ˆBˆBàˆBð ˆrŠ'ˆ'ð €Ir   c                 ó�   — t          | ¦  «        }d}||k     r.||z   dz  }| |         }t          ||¦  «        r|}n|dz   }||k     °.|S )aŠ  Return the index where to insert path into paths.

    This uses a path-wise comparison so we get::
        a
        a-b
        a=b
        a/b
    Rather than::
        a
        a-b
        a/b
        a=b
    :param paths: A list of paths to search through
    :param path: A single path to insert
    :return: An offset where 'path' can be inserted.
    :seealso: bisect.bisect_right
    r   r   r   r    r#   s         r   Ú_bisect_path_rightr,   b   sg   € õ$ 
ˆU‰Œ€BØ	
€BØ
ˆrŠ'ˆ'Ø�B‰w˜1‰nˆà�CŒjˆÝ  cÑ*Ô*ð 	ØˆBˆBà�q‘ˆBð ˆrŠ'ˆ'ð €Ir   c                 óX  — |€t          | ¦  «        }	 ||         }n*# t          $ r |                     d¦  «        }|||<   Y nw xY w||k     r^||z   dz  }| |         d         }	 ||         }n*# t          $ r |                     d¦  «        }|||<   Y nw xY w||k     r|dz   }n|}||k     °^|S )aR  Return the index where to insert dirname into the dirblocks.

    The return value idx is such that all directories blocks in dirblock[:idx]
    have names < dirname, and all blocks in dirblock[idx:] have names >=
    dirname.

    Optional args lo (default 0) and hi (default len(dirblocks)) bound the
    slice of a to be searched.
    Nó   /r   r   r   )r!   ÚKeyErrorÚsplit)	Ú	dirblocksÚdirnamer'   r&   ÚcacheÚdirname_splitr(   r)   Ú	cur_splits	            r   Úbisect_dirblockr6   �   sù   € ð 
€zÝ�‰^Œ^ˆð'Ø˜gœˆˆøÝð 'ð 'ð 'ØŸš dÑ+Ô+ˆØ&ˆˆg‰ˆˆð'øøøð ˆrŠ'ˆ'Ø�B‰w˜1‰nˆà˜Œn˜QÔˆð	#Ø˜cœ
ˆIˆIøÝð 	#ð 	#ð 	#ØŸ	š	 $™œˆIØ"ˆE�#‰JˆJˆJð	#øøøð �}Ò$Ð$Ø�q‘ˆBˆBàˆBð ˆrŠ'ˆ'ð €Is!   “ œ$AÁAÁ#A, Á,$BÂBc                 ó6  — t          | t          ¦  «        s"t          dt          | ¦  «        ›d| ›�¦  «        ‚t          |t          ¦  «        s"t          dt          |¦  «        ›d|›�¦  «        ‚|                      d¦  «        |                     d¦  «        k     S )a×  Compare two paths directory by directory.

    This is equivalent to doing::

       operator.lt(path1.split('/'), path2.split('/'))

    The idea is that you should compare path components separately. This
    differs from plain ``path1 < path2`` for paths like ``'a-b'`` and ``a/b``.
    "a-b" comes after "a" but would come before "a/b" lexically.

    :param path1: first path
    :param path2: second path
    :return: True if path1 comes first, otherwise False
    z#'path1' must be a byte string, not ú: z#'path2' must be a byte string, not r.   )Ú
isinstanceÚbytesÚ	TypeErrorÚtyper0   )Úpath1Úpath2s     r   Ú
lt_by_dirsr?   ¢   sŸ   € õ �e�UÑ#Ô#ð 0ÝˆiÝ ™;œ;˜;˜;¨¨ð/ñ 0ô 0ð 	0å�e�UÑ#Ô#ð 0ÝˆiÝ ™;œ;˜;˜;¨¨ð/ñ 0ô 0ð 	0à�;Š;�tÑÔ˜uŸ{š{¨4Ñ0Ô0Ò0Ð0r   c                 óÎ  — t          | t          ¦  «        s"t          dt          | ¦  «        ›d| ›�¦  «        ‚t          |t          ¦  «        s"t          dt          |¦  «        ›d|›�¦  «        ‚t          j                             | ¦  «        \  }}|                     d¦  «        |f}t          j                             |¦  «        \  }}|                     d¦  «        |f}||k     S )a‡  Compare two paths based on what directory they are in.

    This generates a sort order, such that all children of a directory are
    sorted together, and grandchildren are in the same order as the
    children appear. But all grandchildren come after all children.

    :param path1: first path
    :param path2: the second path
    :return: True if path1 comes first, otherwise False
    z$'path1' must be a plain string, not r8   z$'path2' must be a plain string, not r.   )r9   r:   r;   r<   Úosr%   r0   )r=   r>   Údirname1Ú	basename1Úkey1Údirname2Ú	basename2Úkey2s           r   r"   r"   º   sâ   € õ �e�UÑ#Ô#ð 0ÝˆiÝ ™;œ;˜;˜;¨¨ð/ñ 0ô 0ð 	0å�e�UÑ#Ô#ð 0ÝˆiÝ ™;œ;˜;˜;¨¨ð/ñ 0ô 0ð 	0åœ'Ÿ-š-¨Ñ.Ô.Ñ€HˆiØ�NŠN˜4Ñ Ô  )Ð,€DÝœ'Ÿ-š-¨Ñ.Ô.Ñ€HˆiØ�NŠN˜4Ñ Ô  )Ð,€DØ�$Š;Ðr   c                 óü  ‡‡‡— | j                              | j        ¦  «         | j                              ¦   «         }|                     d¦  «        Š‰                     ¦   «         }|dk    r#t          | d                     |¦  «        ¦  «        ‚d}|                      ¦   «         }d|z   }|  	                    ¦   «         Š‰| j
        z  }t          ‰¦  «        }||z
  |k    r't          | d||z
  ›d|›d‰›d| j
        ›d	‰›�
¦  «        ‚|dk    �r–t          }t          ‰¦  «        }	t          |	d
d¦  «        }
|
€|	j        }
t!          |¦  «        D ]} |
¦   «          Œdg fdg fg| _        | j        d         d         }d}|j        }t!          | j
        ¦  «        D ]÷} |
¦   «         } |
¦   «         } |
¦   «         }||k    r'g }|}| j                             ||f¦  «         |j        }|||f |
¦   «          |
¦   «          | |
¦   «         ¦  «         |
¦   «         dk     |
¦   «         f |
¦   «          |
¦   «          | |
¦   «         ¦  «         |
¦   «         dk     |
¦   «         fgf} |
¦   «         }|dk    rt'          d|z  ¦  «        ‚ ||¦  «         Œø|                      ¦   «          nH|                      ¦   «         Šˆˆˆfd„t!          ||‰¦  «        D ¦   «         }|                      |¦  «         t.          j        | _        dS )a,  Read in the dirblocks for the given DirState object.

    This is tightly bound to the DirState internal representation. It should be
    thought of as a member function, which is only separated out so that we can
    re-write it in pyrex.

    :param state: A DirState object.
    :return: None
    ó    r   ztrailing garbage: {!r}r   zfield count incorrect z != z, entry_size=z, num_entries=z fields=Ú__next__Nr   ó   yó   
z trailing garbage in dirstate: %rc                 ó<   •— g | ]} ‰‰||‰z   …         ¦  «        ‘ŒS © rN   )Ú.0ÚposÚ
entry_sizeÚfieldsÚfields_to_entrys     €€€r   ú
<listcomp>z#_read_dirblocks.<locals>.<listcomp>6  sH   ø€ ð Cð Cð CØð #�? 6¨#¨c°JÑ.>Ð*>Ô#?Ñ@Ô@ð Cð Cð Cr   )Ú_state_fileÚseekÚ_end_of_headerÚreadr0   Úpopr   ÚformatÚ_num_present_parentsÚ_fields_per_entryÚ_num_entriesr!   r
   ÚiterÚgetattrÚnextÚrangeÚ
_dirblocksÚappendÚ
ValueErrorÚ"_split_root_dirblock_into_contentsÚ_get_fields_to_entryÚ_entries_to_current_stater   ÚIN_MEMORY_UNMODIFIEDÚ_dirblock_state)ÚstateÚtextÚtrailingr)   Únum_present_parentsÚ
tree_countÚexpected_field_countÚfield_countÚ_intÚ_iterr`   ÚxÚcurrent_blockÚcurrent_dirnameÚappend_entryÚcountr2   ÚnameÚfile_idÚentryÚentriesrQ   rR   rS   s                        @@@r   Ú_read_dirblocksr|   Ò   s¢  øøø€ ð 
Ô×Ò˜5Ô/Ñ0Ô0Ð0ØÔ×!Ò!Ñ#Ô#€Dð �ZŠZ˜ÑÔ€Fà�zŠz‰|Œ|€HØ�3‚€Ý˜eØ6×=Ò=¸hÑGÔGñIô Ið 	Ið
 €Cð  ×4Ò4Ñ6Ô6ÐØÐ(Ñ(€JØ×(Ò(Ñ*Ô*€JØ%¨Ô(:Ñ:ÐÝ�f‘+”+€Kà�SÑÐ0Ò0Ð0Ý˜e˜eð #.°Ñ"3Ð"3Ð"3Ð5IÐ5IÐ5IÈ:È:È:Ø"'Ô"4Ð"4Ð"4°f°fð>ñ?ô ?ð 	?ð ˜aÒÑåˆõ
 �V‘”ˆå�u˜j¨$Ñ/Ô/ˆØˆ<Ø”:ˆDå�s‘”ð 	ð 	ˆAØˆD‰FŒFˆFˆFð ! "˜I¨¨R yÐ1ˆÔØÔ(¨Ô+¨AÔ.ˆØˆØ$Ô+ˆÝ˜5Ô-Ñ.Ô.ð  	 ð  	 ˆEØ�d‘f”fˆGØ�4‘6”6ˆDØ�d‘f”fˆGØ˜/Ò)Ð)à "�Ø")�ØÔ ×'Ò'¨¸-Ð(HÑIÔIÐIØ,Ô3�ð & t¨WÐ5à˜™œØ˜™œØ˜˜d˜d™fœf™œØ˜™œ 4šØ˜™œðð ˜™œØ˜™œØ˜˜d˜d™fœf™œØ˜™œ 4šØ˜™œðððˆEð  �t‘v”vˆHØ˜5Ò Ð Ý Ð!CÀhÑ!NÑOÔOÐOàˆL˜ÑÔÐÐØ×0Ò0Ñ2Ô2Ð2Ð2à×4Ò4Ñ6Ô6ˆðCð Cð Cð Cð Cð CÝ# C¨°jÑAÔAðCñ Cô Cˆà×'Ò'¨Ñ0Ô0Ð0õ %Ô9€EÔÐÐr   )Ú__doc__r   rA   r   Údirstater   r   Ú
b2a_base64ÚStructÚpackr   r   r*   r,   r6   r?   r"   r|   rN   r   r   ú<module>r‚      sû   ðð" ;Ð :à €€€Ø 	€	€	€	Ø €€€ð 0Ð /Ð /Ð /Ð /Ð /Ð /Ð /ð  Ô*°-°&´-ÀÑ2FÔ2FÔ2Kð 
@ð 
@ð 
@ð 
@ð?ð ?ð ?ð+ð +ð +ð\ð ð ð> ,-°¸Rð ð ð ð ðB1ð 1ð 1ð0ð ð ð0l:ð l:ð l:ð l:ð l:r   