§
    cÌc.  ã                   ó4   — d Z ddlmZmZ  G d„ d¦  «        ZdS )z$Walk multiple trees simultaneously.
é   )ÚerrorsÚosutilsc                   ó~   — e Zd ZdZd„ Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zd„ Z	d„ Z
d„ Zd	„ Zd
„ Zd„ ZdS )ÚMultiWalkerz=Walk multiple trees simultaneously, getting combined results.c                 óH   — || _         || _        t          ¦   «         | _        dS )aC  Create a new MultiWalker.

        All trees being walked must implement "iter_entries_by_dir()", such
        that they yield (path, object) tuples, where that object will have a
        '.file_id' member, that can be used to check equality.

        :param master_tree: All trees will be 'slaved' to the master_tree such
            that nodes in master_tree will be used as 'first-pass' sync points.
            Any nodes that aren't in master_tree will be merged in a second
            pass.
        :param other_trees: A list of other trees to walk simultaneously.
        N)Ú_master_treeÚ_other_treesÚsetÚ_out_of_order_processed)ÚselfÚmaster_treeÚother_treess      ú4/usr/lib/python3/dist-packages/breezy/multiwalker.pyÚ__init__zMultiWalker.__init__#   s(   € ð (ˆÔØ'ˆÔõ
 (+¡u¤uˆÔ$Ð$Ð$ó    c                 óT   — 	 t          | ¦  «        \  }}d||fS # t          $ r Y dS w xY w)z‘Step an iter_entries_by_dir iterator.

        :return: (has_more, path, ie)
            If has_more is False, path and ie will be None.
        T©FNN)ÚnextÚStopIteration)ÚiteratorÚpathÚies      r   Ú	_step_onezMultiWalker._step_one8   sJ   € ð	"Ý˜H‘~”~‰HˆD�"ð ˜˜r�>Ð!øõ ð 	%ð 	%ð 	%Ø$Ð$Ð$ð	%øøøs   ‚ ™
'¦'c                 óZ  — | |k    rdS t          | t          ¦  «        s"t          dt          | ¦  «        ›d| ›�¦  «        ‚t          |t          ¦  «        s"t          dt          |¦  «        ›d|›�¦  «        ‚t                               | ¦  «        t                               |¦  «        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: negative number if ``path1`` comes first,
            0 if paths are equal
            and a positive number if ``path2`` sorts first
        Fz&'path1' must be a unicode string, not z: z&'path2' must be a unicode string, not )Ú
isinstanceÚstrÚ	TypeErrorÚtyper   Ú_path_to_key)Úpath1Úpath2s     r   Ú_lt_path_by_dirblockz MultiWalker._lt_path_by_dirblockF   s¸   € ð �EŠ>ˆ>Ø�5õ ˜%¥Ñ%Ô%ð 	4Ý�)Ý# E™{œ{˜{˜{¨E¨Eð3ñ 4ô 4ð 4å˜%¥Ñ%Ô%ð 	4Ý�)Ý# E™{œ{˜{˜{¨E¨Eð3ñ 4ô 4ð 4å×(Ò(¨Ñ/Ô/Ý×(Ò(¨Ñ/Ô/ò0ð 	1r   c                 ó^   — t          j        | ¦  «        \  }}|                     d¦  «        |fS )Nú/)r   Úsplit)r   ÚdirnameÚbasenames      r   r   zMultiWalker._path_to_keyc   s-   € å#œM¨$Ñ/Ô/Ñˆ�Ø—’˜cÑ"Ô" HÐ-Ð-r   c                 ó`   — |                       ||| j                             |¦  «        ¦  «        S )N)Ú_lookup_by_file_idr   Úpath2id)r   Úextra_entriesÚ
other_treeÚmaster_paths       r   Ú_lookup_by_master_pathz"MultiWalker._lookup_by_master_pathh   s3   € Ø×&Ò&Ø˜:ØÔ×%Ò% kÑ2Ô2ñ4ô 4ð 	4r   c                 ó(  — ||v r|                      |¦  «        S 	 |                     |¦  «        }n# t          j        $ r d}Y nw xY w|€dS | j                             |¦  «         t          |                     |g¬¦  «        ¦  «        d         }||fS )a  Lookup an inventory entry by file_id.

        This is called when an entry is missing in the normal order.
        Generally this is because a file was either renamed, or it was
        deleted/added. If the entry was found in the inventory and not in
        extra_entries, it will be added to self._out_of_order_processed

        :param extra_entries: A dictionary of {file_id: (path, ie)}.  This
            should be filled with entries that were found before they were
            used. If file_id is present, it will be removed from the
            dictionary.
        :param other_tree: The Tree to search, in case we didn't find the entry
            yet.
        :param file_id: The file_id to look for
        :return: (path, ie) if found or (None, None) if not present.
        N©NN)Úspecific_filesr   )ÚpopÚid2pathr   ÚNoSuchIdr   Úaddr   Úiter_entries_by_dir)r   r+   r,   Úfile_idÚcur_pathÚcur_ies         r   r)   zMultiWalker._lookup_by_file_idm   sÃ   € ð" �mÐ#Ð#Ø ×$Ò$ WÑ-Ô-Ð-ð	Ø!×)Ò)¨'Ñ2Ô2ˆHˆHøÝŒð 	ð 	ð 	ØˆHˆHˆHð	øøøàÐØ�<àÔ(×,Ò,¨WÑ5Ô5Ð5Ý˜*×8Ò8Ø (˜zð 9ñ +ô +ñ ,ô ,Ø,-ô/ˆFà˜fÐ%Ð%s   ›1 ±AÁAc              #   óš   K  — |                       ¦   «         E d{V —† |                      ¦   «          |                      ¦   «         E d{V —† dS )z+Match up the values in the different trees.N)Ú_walk_master_treeÚ_finish_othersÚ_walk_others)r   s    r   Úiter_allzMultiWalker.iter_allŒ   sf   è è € à×)Ò)Ñ+Ô+Ð+Ð+Ð+Ð+Ð+Ð+Ð+Ø×ÒÑÔÐØ×$Ò$Ñ&Ô&Ð&Ð&Ð&Ð&Ð&Ð&Ð&Ð&Ð&r   c              #   óT  ‡ K  — ‰ j                              ¦   «         }d„ ‰ j        D ¦   «         }ˆ fd„|D ¦   «         }d„ t          t	          ‰ j        ¦  «        ¦  «        D ¦   «         }d}‰ j        }‰ j        }‰ j        }|�r’ ||¦  «        \  }}	}
|s�ng }|j        }g }|j        }t          |¦  «        D �]J\  }\  }}}|s= |‰  
                    ||         ‰ j        |         |	¦  «        ¦  «          |d¦  «         ŒI|
j        |j        k    r( |||f¦  «          | |||         ¦  «        ¦  «         Œ�||         }||         }|rO‰                      ||	¦  «        r9|j        }||vr||f||<    ||¦  «        \  }}}|r‰                      ||	¦  «        °9|r-|j        |
j        k    r |||f¦  «          ||¦  «        \  }}}n+ |‰  
                    |‰ j        |         |	¦  «        ¦  «          ||||f¦  «         �ŒL|}|	|
j        |
|fV — |�°’|‰ _        |‰ _        |‰ _        dS )zòFirst pass, walk all trees in lock-step.

        When we are done, all nodes in the master_tree will have been
        processed. _other_walkers, _other_entries, and _others_extra will be
        set on 'self' for future processing.
        c                 ó6   — g | ]}|                      ¦   «         ‘ŒS © )r6   )Ú.0Úothers     r   ú
<listcomp>z1MultiWalker._walk_master_tree.<locals>.<listcomp>ž   s4   € ð 9ð 9ð 9Ø"ð ×2Ò2Ñ4Ô4ð 9ð 9ð 9r   c                 ó:   •— g | ]}‰                      |¦  «        ‘ŒS rA   )r   )rB   Úwalkerr   s     €r   rD   z1MultiWalker._walk_master_tree.<locals>.<listcomp>    s%   ø€ ÐLÐLÐL°F˜Ÿš¨Ñ/Ô/ÐLÐLÐLr   c                 ó   — g | ]}i ‘ŒS rA   rA   )rB   Ú_s     r   rD   z1MultiWalker._walk_master_tree.<locals>.<listcomp>¢   s   € ÐBÐBÐB˜q˜ÐBÐBÐBr   Tr   N)r   r6   r	   ÚrangeÚlenr   r)   r   ÚappendÚ	enumerater.   r7   r"   Ú_other_walkersÚ_other_entriesÚ_others_extra)r   Úmaster_iteratorÚother_walkersÚother_entriesÚothers_extraÚmaster_has_moreÚstep_oneÚlookup_by_file_idÚout_of_order_processedr   Ú	master_ieÚother_valuesÚother_values_appendÚnext_other_entriesÚnext_other_entries_appendÚidxÚother_has_moreÚ
other_pathÚother_ieÚother_walkerÚother_extraÚother_file_ids   `                     r   r;   zMultiWalker._walk_master_tree’   s=  øè è € ð Ô+×?Ò?ÑAÔAˆð9ð 9Ø&*Ô&7ð9ñ 9ô 9ˆàLÐLÐLÐL¸mÐLÑLÔLˆàBÐB¥E­#¨dÔ.?Ñ*@Ô*@Ñ$AÔ$AÐBÑBÔBˆàˆØ”>ˆØ Ô3ÐØ!%Ô!=Ðàñ /	CØ19°¸/Ñ1JÔ1JÑ.ˆ_˜d IØ"ð ÙàˆLØ".Ô"5ÐØ!#ÐØ(:Ô(AÐ%Ý?HÈÑ?WÔ?Wð ":ñ ":Ñ;�Ñ;�n j°(Ø%ð !:Ø'Ð'¨×(CÒ(CØ$ SÔ)¨4Ô+<¸SÔ+AÀ4ñ)Iô )Iñ Jô Jð Jà-Ð-Ð.AÑBÔBÐBÐBØÔ&¨(Ô*:Ò:Ð:ð (Ð'¨°XÐ(>Ñ?Ô?Ð?Ø-Ð-¨h¨h°}ÀSÔ7IÑ.JÔ.JÑKÔKÐKÐKð $1°Ô#5�LØ".¨sÔ"3�KØ)ð 3Ø×4Ò4°ZÀÑFÔFð3à(0Ô(8˜Ø(Ð0FÐFÐFØ:DÀhÐ9O˜K¨Ñ6à$˜H \Ñ2Ô2ñ =˜¨
°Hð *ð 3Ø×4Ò4°ZÀÑFÔFð3ð &ð 
H¨(Ô*:¸iÔ>OÒ*OÐ*Oð ,Ð+¨Z¸Ð,BÑCÔCÐCà$˜H \Ñ2Ô2ñ =˜¨
°H°Hð
 ,Ð+¨D×,GÒ,GØ'¨Ô):¸3Ô)?Àñ-Gô -Gñ Hô Hð Hà-Ð-¨~¸zØ/7ð/9ñ :ô :ð :ñ :à.ˆMð ˜	Ô)¨9°lÐBÐBÐBÐBð_ ñ /	Cð` ,ˆÔØ+ˆÔØ)ˆÔÐÐr   c                 óâ   — t          | j        ¦  «        D ]W\  }}| j        |         }|\  }}}|r=|j        }|| j        vr||f||<   |                      | j        |         ¦  «        \  }}}|°=ŒX| `dS )z:Finish walking the other iterators, so we get all entries.N)rL   rN   rO   r7   r   r   rM   )r   r]   Úinforb   r^   r_   r`   rc   s           r   r<   zMultiWalker._finish_othersÝ   s¡   € å" 4Ô#6Ñ7Ô7ð 	=ð 	=‰IˆC�ØÔ,¨SÔ1ˆKØ59Ñ2ˆ^˜Z¨Ø ð =Ø (Ô 0�Ø ¨Ô(DÐDÐDØ2<¸hÐ1G�K Ñ.à—N’N 4Ô#6°sÔ#;Ñ<Ô<ñ 5� 
¨Hð	 !ð =øð ÐÐÐr   c           
   #   ó   ‡ K  — t          ‰ j        ¦  «        D ]å\  }}t          |                     ¦   «         ˆ fd„¬¦  «        }|D ]·\  }}|j        }|                     |¦  «         dg|z  }|                     ||f¦  «         t          ‰ j        |dz   d…         ¦  «        D ]Q\  }}	||z   dz   }‰ j        |         }	‰ j        |         }
|                     ‰                      |	|
|¦  «        ¦  «         ŒR||d|fV — Œ¸ŒædS )z.Finish up by walking all the 'deferred' nodes.c                 ó:   •— ‰                      | d         ¦  «        S )Né    )r   )Úxr   s    €r   ú<lambda>z*MultiWalker._walk_others.<locals>.<lambda>ò   s   ø€ ¨$×*;Ò*;¸A¸a¼DÑ*AÔ*A€ r   )Úkeyr0   r   N)	rL   rO   ÚsortedÚvaluesr7   r2   rK   r	   r)   )r   r]   rb   Úothersr_   r`   r7   rY   Úalt_idxÚ	alt_extraÚalt_trees   `          r   r=   zMultiWalker._walk_othersê   s_  øè è € õ !*¨$Ô*<Ñ =Ô =ð 	>ð 	>ÑˆC�Ý˜K×.Ò.Ñ0Ô0Ø AÐ AÐ AÐ AðCñ Cô CˆFà(.ð >ð >Ñ$�
˜HØ"Ô*�ð —’ Ñ(Ô(Ð(Ø ,˜~°Ñ3�Ø×#Ò# Z°Ð$:Ñ;Ô;Ð;Ý*3°DÔ4FÀsÈQÁwÀxÀxÔ4PÑ*QÔ*Qð 7ð 7Ñ&�G˜YØ%¨™m¨aÑ/�GØ $Ô 2°7Ô ;�IØ#Ô0°Ô9�HØ ×'Ò'¨×(?Ò(?Ø! 8¨Wñ)6ô )6ñ 7ô 7ð 7ð 7à  '¨4°Ð=Ð=Ð=Ð=Ð=ð>ð	>ð 	>r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ústaticmethodr   r"   r   r.   r)   r>   r;   r<   r=   rA   r   r   r   r      sØ   € € € € € ØGÐGð-ð -ð -ð* ð"ð "ñ „\ð"ð ð1ð 1ñ „\ð1ð8 ð.ð .ñ „\ð.ð4ð 4ð 4ð
&ð &ð &ð>'ð 'ð 'ðI*ð I*ð I*ðV ð  ð  ð>ð >ð >ð >ð >r   r   N)ru   Ú r   r   r   rA   r   r   ú<module>rx      ss   ðð"ð ðð ð ð ð ð ð ð ðg>ð g>ð g>ð g>ð g>ñ g>ô g>ð g>ð g>ð g>r   