§
    cÌcÃG  ã                   óÄ   — d Z 	 ddlZddlmZmZ ddlmZ ddlmZ ddl	m
Z
  G d„ d	¦  «        Z G d
„ d¦  «        Z	 dd„Z	 dd„Z G d„ d¦  «        Z G d„ d¦  «        ZdS )Úgoogleé    Né   )ÚerrorsÚui)Úgettext)ÚNULL_REVISION)Úmutterc                   ó0   — e Zd ZdZ	 	 dd„Zd„ Zd„ Zd„ ZdS )	ÚRepoFetcherzµPull revisions and texts from one repository to another.

    This should not be used directly, it's essential a object to encapsulate
    the logic in InterRepository.fetch().
    NTc           
      óÔ  — || _         || _        |                     ¦   «         | _        || _        || _        || _        | j                             ¦   «         5  t          dt          | j        ¦  «        t          | j        j
        ¦  «        t          | j         ¦  «        t          | j         j
        ¦  «        ¦  «         |                      ¦   «          ddd¦  «         dS # 1 swxY w Y   dS )aO  Create a repo fetcher.

        Args:
          last_revision: If set, try to limit to the data this revision
            references.
          fetch_spec: A SearchResult specifying which revisions to fetch.
            If set, this overrides last_revision.
          find_ghosts: If True search the entire history for ghosts.
        z3Using fetch logic to copy between %s(%s) and %s(%s)N)Úto_repositoryÚfrom_repositoryÚ	_get_sinkÚsinkÚ_last_revisionÚ_fetch_specÚfind_ghostsÚ	lock_readr	   ÚstrÚ_formatÚ_RepoFetcher__fetch)Úselfr   r   Úlast_revisionr   Ú
fetch_specs         ú2/usr/lib/python3/dist-packages/breezy/bzr/fetch.pyÚ__init__zRepoFetcher.__init__-   s  € ð +ˆÔØ.ˆÔØ!×+Ò+Ñ-Ô-ˆŒ	à+ˆÔØ%ˆÔØ&ˆÔØÔ!×+Ò+Ñ-Ô-ð 	ð 	ÝÐHÝ�tÔ+Ñ,Ô,­c°$Ô2FÔ2NÑ.OÔ.OÝ�tÔ)Ñ*Ô*­C°Ô0BÔ0JÑ,KÔ,KñMô Mð Mð �LŠL‰NŒNˆNð		ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð 	ð 	s   ÁA:CÃC!Ã$C!c                 ó  — d| _         i | _        t          j                             ¦   «         5 }dx|_        |_        |                     t          d¦  «        dd¦  «         |  	                    ¦   «         }t          dt          |¦  «        ¦  «         |                     ¦   «         r	 ddd¦  «         dS |                     t          d¦  «        dd¦  «         |                      |¦  «         ddd¦  «         dS # 1 swxY w Y   dS )	zªPrimary worker function.

        This initialises all the needed variables, and then fetches the
        requested revisions, finally clearing the progress bar.
        r   FzFinding revisionsr   zfetching: %sNzFetching revisionsé   )Úcount_totalÚfile_ids_namesr   Ú
ui_factoryÚnested_progress_barÚshow_pctÚ
show_countÚupdater   Ú_revids_to_fetchr	   r   Úis_emptyÚ_fetch_everything_for_search)r   ÚpbÚsearch_results      r   Ú__fetchzRepoFetcher.__fetchG   sS  € ð ˆÔØ ˆÔÝŒ]×.Ò.Ñ0Ô0ð 	=°BØ*/Ð/ˆBŒK˜"œ-Ø�IŠI•gÐ1Ñ2Ô2°A°qÑ9Ô9Ð9Ø ×1Ò1Ñ3Ô3ˆMÝ�>¥3 }Ñ#5Ô#5Ñ6Ô6Ð6Ø×%Ò%Ñ'Ô'ð Øð	=ð 	=ð 	=ñ 	=ô 	=ð 	=ð 	=ð 	=ð �IŠI•gÐ2Ñ3Ô3°Q¸Ñ:Ô:Ð:Ø×-Ò-¨mÑ<Ô<Ð<ð	=ð 	=ð 	=ñ 	=ô 	=ð 	=ð 	=ð 	=ð 	=ð 	=ð 	=ð 	=øøøð 	=ð 	=ð 	=ð 	=ð 	=ð 	=s   ­A9C9Â39C9Ã9C=Ä C=c                 óÀ  — | j         j        j        r1| j        j        j        s t	          j        | j         | j        d¦  «        ‚t          j                             ¦   «         5 }| 	                    d¦  «         | j          
                    | j        j        ¦  «        }|                     |¦  «        }| j         j        }| 	                    d¦  «         | j                             ||g ¦  «        \  }}|r^| 	                    d¦  «         |                     |¦  «        }| 	                    d¦  «         | j                             |||¦  «        \  }}|r"t          d                     |¦  «        ¦  «        ‚|r"t          d                     |¦  «        ¦  «        ‚| 	                    d¦  «         | j                             ¦   «          d	d	d	¦  «         d	S # 1 swxY w Y   d	S )
z.Fetch all data for the given set of revisions.zdifferent rich-root supportzGet stream sourcezInserting streamzMissing keyszInserting missing keysz,second push failed to complete a fetch {!r}.z,second push failed to commit the fetch {!r}.zFinishing streamN)r   r   Úrich_root_datar   r   ÚIncompatibleRepositoriesr   r!   r"   r%   Ú_get_sourceÚ
get_streamr   Úinsert_streamÚget_stream_for_missing_keysÚAssertionErrorÚformatÚfinished)r   Úsearchr)   ÚsourceÚstreamÚfrom_formatÚresume_tokensÚmissing_keyss           r   r(   z(RepoFetcher._fetch_everything_for_search_   s6  € ð Ô Ô(Ô7ð 	/ØÔ&Ô.Ô=ð	/åÔ1ØÔ$ dÔ&8Ø-ñ/ô /ð /õ Œ]×.Ò.Ñ0Ô0ð 	!°BØ�IŠIÐ)Ñ*Ô*Ð*ØÔ)×5Ò5ØÔ"Ô*ñ,ô ,ˆFà×&Ò& vÑ.Ô.ˆFØÔ.Ô6ˆKØ�IŠIÐ(Ñ)Ô)Ð)Ø*.¬)×*AÒ*AØ˜ Rñ+)ô +)Ñ'ˆM˜<àð 8Ø—	’	˜.Ñ)Ô)Ð)Ø×;Ò;¸LÑIÔI�Ø—	’	Ð2Ñ3Ô3Ð3Ø.2¬i×.EÒ.EØ˜K¨ñ/8ô /8Ñ+�˜|àð 'Ý$ØB×IÒIØ$ñ&ô &ñ'ô 'ð 'ð ð (Ý$ØB×IÒIØ%ñ'ô 'ñ(ô (ð (ð �IŠIÐ(Ñ)Ô)Ð)ØŒI×ÒÑ Ô Ð ð1	!ð 	!ð 	!ñ 	!ô 	!ð 	!ð 	!ð 	!ð 	!ð 	!ð 	!ð 	!øøøð 	!ð 	!ð 	!ð 	!ð 	!ð 	!s   Á!E%GÇGÇGc                 ór  — ddl m} | j        �| j        S | j        t          k    r|                     ¦   «         S | j        �@|                     | j        | j        | j        g| j	        ¬¦  «         
                    ¦   «         S |                     | j        | j        | j	        ¬¦  «         
                    ¦   «         S )a  Determines the exact revisions needed from self.from_repository to
        install self._last_revision in self.to_repository.

        Returns:
          A SearchResult of some sort.  (Possibly a
          PendingAncestryResult, EmptySearchResult, etc.)
        r   ©Ú	vf_searchN)r   )Ú r>   r   r   r   ÚEmptySearchResultÚNotInOtherForRevsr   r   r   ÚexecuteÚEverythingNotInOther)r   r>   s     r   r&   zRepoFetcher._revids_to_fetchˆ   sÝ   € ð 	 ÐÐÐÐÐØÔÐ'àÔ#Ð#ØÔ ¥MÒ1Ð1ð ×.Ò.Ñ0Ô0Ð0ØÔ Ð,Ø×.Ò.¨tÔ/AØ/3Ô/CØ37Ô3FðFHà;?Ô;Kð /ñ Mô M÷ NUÊWÉYÌYðWð
 ×1Ò1°$Ô2DØ26Ô2FØ>BÔ>Nð 2ñ Pô PçPWÒPWÑPYÔPYðZó    )NTN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r(   r&   © rD   r   r   r   &   so   € € € € € ðð ð FJØ.2ðð ð ð ð4=ð =ð =ð0'!ð '!ð '!ðRZð Zð Zð Zð ZrD   r   c                   ó.   — e Zd ZdZdZd„ Zd„ Zd„ Zd„ ZdS )ÚInter1and2HelperzpHelper for operations that convert data from model 1 and 2

    This is for use by fetchers and converters.
    éd   c                 ó   — || _         dS )zUConstructor.

        Args:
          source: The repository data comes from
        N)r7   )r   r7   s     r   r   zInter1and2Helper.__init__¬   s   € ð ˆŒˆˆrD   c              #   óî   K  — t          |¦  «        }|ra| j                             |dd…         ¦  «        D ]0}|j        j        €|                     ¦   «         |j        _        |V — Œ1|dd…         }|°_dS dS )a  Iterate through RevisionTrees efficiently.

        Additionally, the inventory's revision_id is set if unset.

        Trees are retrieved in batches of 100, and then yielded in the order
        they were requested.

        Args:
          revs: A list of revision ids
        NrL   )Úlistr7   Úrevision_treesÚroot_inventoryÚrevision_idÚget_revision_id)r   ÚrevsÚtrees      r   Úiter_rev_treeszInter1and2Helper.iter_rev_trees´   s›   è è € õ �D‰zŒzˆØð 	Øœ×2Ò2°4¸¸¸´:Ñ>Ô>ð ð �ØÔ&Ô2Ð:Ø6:×6JÒ6JÑ6LÔ6L�DÔ'Ô3Ø�
�
�
�
Ø˜˜˜”:ˆDð ð 	ð 	ð 	ð 	ð 	rD   c                 óê  — i }|                       |¦  «        D ]1}|                     d¦  «        }|                     d¦  «        }|||<   Œ2t          |                     ¦   «         ¦  «        }|                     |¦  «         |                     t          ¦  «         |                     |¦  «        }|                       |¦  «        D ].}|                     d¦  «        }||| 	                    ¦   «         <   Œ/|S )Nr?   )
rV   Úpath2idÚget_file_revisionÚsetÚvaluesÚdifference_updateÚdiscardr   Úget_parent_maprS   )	r   rT   Ú
parent_mapÚgraphÚrevision_rootrU   Úroot_idrR   Úparentss	            r   Ú_find_root_idszInter1and2Helper._find_root_idsÈ   sô   € ØˆØ×'Ò'¨Ñ-Ô-ð 	1ð 	1ˆDØ—l’l 2Ñ&Ô&ˆGØ×0Ò0°Ñ4Ô4ˆKØ)0ˆM˜+Ñ&Ð&å�j×'Ò'Ñ)Ô)Ñ*Ô*ˆØ×!Ò! -Ñ0Ô0Ð0Ø�Š�Ñ&Ô&Ð&à×&Ò& wÑ/Ô/ˆØ×'Ò'¨Ñ0Ô0ð 	<ð 	<ˆDØ—l’l 2Ñ&Ô&ˆGØ4;ˆM˜$×.Ò.Ñ0Ô0Ñ1Ð1ØÐrD   c                 óº  ‡— ddl m} | j                             ¦   «         }|                     |¦  «        } ||¦  «        }|                      |||¦  «        Šˆfd„|D ¦   «         }|                     t          j        d¦  «        ¬¦  «         t          |¦  «        | j
        k    r| j                             |¦  «        }t          |‰|| j        |¦  «        }d|fgS )zjGenerate VersionedFiles for all root ids.

        Args:
          revs: the revisions to include
        r   )Ú	topo_sortc                 ó$   •— g | ]}‰|         |f‘ŒS rI   rI   )Ú.0Úrev_idÚrev_id_to_root_ids     €r   ú
<listcomp>z8Inter1and2Helper.generate_root_texts.<locals>.<listcomp>ä   s0   ø€ ð $ð $ð $ÀÐ+¨FÔ3°VÐ<ð $ð $ð $rD   r   )ÚkeyÚtexts)Útsortrf   r7   Ú	get_graphr^   rd   ÚsortÚoperatorÚ
itemgetterÚlenÚknown_graph_thresholdÚget_known_graph_ancestryÚ_new_root_data_stream)	r   rT   rf   r`   r_   Ú	rev_orderÚroot_id_orderÚnew_roots_streamrj   s	           @r   Úgenerate_root_textsz$Inter1and2Helper.generate_root_textsÙ   s  ø€ ð 	&Ð%Ð%Ð%Ð%Ð%Ø”×%Ò%Ñ'Ô'ˆØ×)Ò)¨$Ñ/Ô/ˆ
Ø�I˜jÑ)Ô)ˆ	Ø ×/Ò/°°jÀ%ÑHÔHÐð$ð $ð $ð $Ø"ð$ñ $ô $ˆð 	×Ò�xÔ2°1Ñ5Ô5ÐÑ6Ô6Ð6åˆt‰9Œ9�tÔ1Ò1Ð1Ø”K×8Ò8¸Ñ>Ô>ˆEÝ0ØÐ,¨j¸$¼+ÀuñNô NÐàÐ*Ð+Ð,Ð,rD   N)	rE   rF   rG   rH   rt   r   rV   rd   rz   rI   rD   r   rK   rK   £   sb   € € € € € ðð ð  Ððð ð ðð ð ð(ð ð ð"-ð -ð -ð -ð -rD   rK   c           	   #   ór   K  — ddl m} | D ]+}|\  }}t          ||||||¦  «        }	 |||	dg ¦  «        V — Œ,dS )a+  Generate a texts substream of synthesised root entries.

    Used in fetches that do rich-root upgrades.

    Args:
      root_keys_to_create: iterable of (root_id, rev_id) pairs describing
        the root entries to create.
      rev_id_to_root_id_map: dict of known rev_id -> root_id mappings for
        calculating the parents.  If a parent rev_id is not found here then it
        will be recalculated.
      parent_map: a parent map for all the revisions in
        root_keys_to_create.
      graph: a graph to use instead of repo.get_graph().
    r   )ÚChunkedContentFactoryN)Úversionedfiler|   Ú_parent_keys_for_root_version)
Úroot_keys_to_createÚrev_id_to_root_id_mapr_   Úrepor`   r|   Úroot_keyrb   ri   Úparent_keyss
             r   rv   rv   ó   s   è è € ð  5Ð4Ð4Ð4Ð4Ð4Ø'ð Eð EˆØ"‰ˆ�Ý3Ø�VÐ2°JÀÀeñMô Mˆà#Ð# H¨k¸4ÀÑDÔDÐDÐDÐDÐDð	Eð ErD   c           	      óÖ  ‡ — ||         }g }|D ]ý}|t           k    rŒ||vrI	 |                     |¦  «        }	|	                     d¦  «        }
n# t          j        $ r d}
Y nw xY wd||<   n||         }
‰ |
k    r|                     |¦  «         Œ	 |                     |¦  «        }		 |                     |	                     |	                     ‰ d¬¦  «        ¦  «        ¦  «         ŒÔ# t          j        $ r Y Œåw xY w# t          j        $ r Y Œúw xY w|€| 	                    ¦   «         }| 
                    |¦  «        }g }|D ]}||v r||vr|                     |¦  «         Œ ˆ fd„|D ¦   «         }|S )z_Get the parent keys for a given root id.

    A helper function for _new_root_data_stream.
    r?   NÚnone)Úrecursec                 ó   •— g | ]}‰|f‘ŒS rI   rI   )rh   Ú	parent_idrb   s     €r   rk   z1_parent_keys_for_root_version.<locals>.<listcomp>G  s   ø€ ÐFÐFÐF¨I�G˜YÐ'ÐFÐFÐFrD   )r   Úrevision_treerX   r   ÚNoSuchRevisionÚappendrY   Úid2pathÚNoSuchIdro   Úheads)rb   ri   r€   r_   r�   r`   Úrev_parentsÚ
parent_idsrˆ   rU   Úparent_root_idrŽ   Úselected_idsrƒ   s   `             r   r~   r~     s  ø€ ð ˜VÔ$€KØ€JØ ð )ð )ˆ	Ø�Ò%Ð%ØØÐ1Ð1Ð1ð2Ø×)Ò)¨)Ñ4Ô4�ð "&§¢¨bÑ!1Ô!1��øõ Ô(ð &ð &ð &ð "&���ð	&øøøð 04Ð! )Ñ,Ð,ð
 3°9Ô=ˆNØ�nÒ$Ð$ð
 ×Ò˜iÑ(Ô(Ð(Ð(ðØ×)Ò)¨)Ñ4Ô4�ð
Ø×%Ò%Ø×.Ò.Ø ŸLšL¨¸&˜LÑAÔAñCô CñDô Dð Dð Døõ ”ð ð ð à�Dðøøøøõ Ô(ð ð ð à�ðøøøð €}Ø—’Ñ Ô ˆØ�KŠK˜
Ñ#Ô#€EØ€LØð +ð +ˆ	Ø˜ÐÐ )°<Ð"?Ð"?Ø×Ò 	Ñ*Ô*Ð*øØFÐFÐFÐF¸ÐFÑFÔF€KØÐs5   ¡AÁA ÁA ÂC7Â$=C"Ã"C4Ã3C4Ã7D	ÄD	c                   ó   — e Zd ZdZdZdZdZdS )ÚTargetRepoKindszlAn enum-like set of constants.

    They are the possible values of FetchSpecFactory.target_repo_kinds.
    ÚpreexistingÚstackedÚemptyN)rE   rF   rG   rH   ÚPREEXISTINGÚSTACKEDÚEMPTYrI   rD   r   r”   r”   K  s)   € € € € € ðð ð
  €KØ€GØ€E€E€ErD   r”   c                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )ÚFetchSpecFactorya‘  A helper for building the best fetch spec for a sprout call.

    Factors that go into determining the sort of fetch to perform:
     * did the caller specify any revision IDs?
     * did the caller specify a source branch (need to fetch its
       heads_to_fetch(), usually the tip + tags)
     * is there an existing target repo (don't need to refetch revs it
       already has)
     * target is stacked?  (similar to pre-existing target repo: even if
       the target itself is new don't want to refetch existing revs)

    Attributes:
      source_branch: the source branch if one specified, else None.
      source_branch_stop_revision_id: fetch up to this revision of
        source_branch, rather than its tip.
      source_repo: the source repository if one found, else None.
      target_repo: the target repository acquired by sprout.
      target_repo_kind: one of the TargetRepoKinds constants.
    c                 ó€   — t          ¦   «         | _        d | _        d | _        d | _        d | _        d | _        d | _        d S ©N)rZ   Ú_explicit_rev_idsÚsource_branchÚsource_branch_stop_revision_idÚsource_repoÚtarget_repoÚtarget_repo_kindÚlimit)r   s    r   r   zFetchSpecFactory.__init__k  sA   € Ý!$¡¤ˆÔØ!ˆÔØ.2ˆÔ+ØˆÔØˆÔØ $ˆÔØˆŒ
ˆ
ˆ
rD   c                 ó:   — | j                              |¦  «         dS )z:Add revision_ids to the set of revision_ids to be fetched.N)rŸ   r%   )r   Úrevision_idss     r   Úadd_revision_idsz!FetchSpecFactory.add_revision_idst  s   € àÔ×%Ò% lÑ3Ô3Ð3Ð3Ð3rD   c                 óò  — ddl m} | j        �| j        €'t	          d                     | j        ¦  «        ¦  «        ‚t          | j        ¦  «        dk    r~| j	        €w| j
        �t          d¦  «        ‚| j        t          j        k    r|                     | j        ¦  «        S |                     | j        | j        ¦  «                             ¦   «         S t%          | j        ¦  «        }| j	        �| j	                             ¦   «         \  }}| j        �F|                     | j	                             ¦   «         ¦  «         |                     | j        ¦  «         |                     |¦  «         nt%          ¦   «         }| j        t          j        k    r¯|                     |¦  «        }|                     || j        ¦  «        }| j
        �v| j                             ¦   «         }t9          |                     |                     ¦   «         ¦  «        ¦  «        }|d| j
        …         }	| j                             |	¦  «        }|S |                      | j        | j        ||| j
        ¬¦  «                             ¦   «         S )z5Build a SearchResult or PendingAncestryResult or etc.r   r=   Nz!Incomplete FetchSpecFactory: {!r}r   z0limit is only supported with a source branch set)Úrequired_idsÚif_present_idsr¥   )!r?   r>   r¤   r¢   r3   r4   Ú__dict__rs   rŸ   r    r¥   ÚNotImplementedErrorr”   rš   ÚEverythingResultrC   r£   rB   rZ   Úheads_to_fetchr¡   r]   r   Úaddr%   ÚunionÚPendingAncestryResultro   rO   Úiter_topo_orderÚget_keysÚrevision_ids_to_search_resultrA   )
r   r>   r¯   Ú
must_fetchÚif_present_fetchÚ	all_headsÚretr`   Ú
topo_orderÚ
result_sets
             r   Úmake_fetch_specz FetchSpecFactory.make_fetch_specx  sg  € àÐÐÐÐÐØÔ Ð(¨DÔ,<Ð,DÝ Ø3×:Ò:¸4¼=ÑIÔIñKô Kð KåˆtÔ%Ñ&Ô&¨!Ò+Ð+°Ô0BÐ0JØŒzÐ%Ý)ØFñHô Hð Hð Ô$­Ô(=Ò=Ð=Ø ×1Ò1°$Ô2BÑCÔCÐCð !×5Ò5ØÔ$ dÔ&6ñ8ô 8ß8?º¹	¼	ðBå˜TÔ3Ñ4Ô4ˆØÔÐ)Ø+/Ô+=×+LÒ+LÑ+NÔ+NÑ(ˆJÐ(ØÔ2Ð>ð ×"Ò" 4Ô#5×#CÒ#CÑ#EÔ#EÑFÔFÐFØ—’˜tÔBÑCÔCÐCØ×!Ò! *Ñ-Ô-Ð-Ð-å"™uœuÐØÔ ¥OÔ$9Ò9Ð9ð '×,Ò,Ð-=Ñ>Ô>ˆIØ×1Ò1°)¸TÔ=MÑNÔNˆCØŒzÐ%ØÔ(×2Ò2Ñ4Ô4�Ý! %×"7Ò"7¸¿º¹¼Ñ"GÔ"GÑHÔH�
Ø'¨¨¬¨Ô4�
ØÔ&×DÒDØñ ô  �àˆJà×.Ò.¨tÔ/?ÀÔAQØ<JÐ[kØ59´Zð /ñ Aô AçAHÂÁÄðKrD   N)rE   rF   rG   rH   r   r¨   r¼   rI   rD   r   rœ   rœ   V  sP   € € € € € ðð ð(ð ð ð4ð 4ð 4ð2Kð 2Kð 2Kð 2Kð 2KrD   rœ   rž   )Ú__docformat__rq   r?   r   r   Úi18nr   Úrevisionr   Útracer	   r   rK   rv   r~   r”   rœ   rI   rD   r   ú<module>rÁ      s�  ðð" €ðð €€€ðð ð ð ð ð ð ð ð Ð Ð Ð Ð Ð Ø $Ð $Ð $Ð $Ð $Ð $Ø Ð Ð Ð Ð Ð ðzZð zZð zZð zZð zZñ zZô zZð zZðzM-ð M-ð M-ð M-ð M-ñ M-ô M-ð M-ðb MQðEð Eð Eð Eð2 IMð=ð =ð =ð =ð@ð ð ð ð ñ ô ð ðTKð TKð TKð TKð TKñ TKô TKð TKð TKð TKrD   