§
    cÌcï  ã                   óp   — d Z ddlmZ ddlmZmZmZ ddlmZm	Z	 ddl
mZ ddlmZmZ  G d	„ d
¦  «        ZdS )zBAn object that updates a bunch of branches based on data imported.é    )Ú
itemgetteré   )ÚerrorsÚosutilsÚ	transport)Ú
show_errorÚnote)Ú
controldiré   )Ú'best_format_for_objects_in_a_repositoryÚsingle_pluralc                   ó2   — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ ZdS )ÚBranchUpdaterc                 ó‚   — || _         || _        || _        || _        || _        || _        t          |¦  «        | _        dS )zäCreate an object responsible for updating branches.

        :param heads_by_ref: a dictionary where
          names are git-style references like refs/heads/master;
          values are one item lists of commits marks.
        N)ÚrepoÚbranchÚ	cache_mgrÚheads_by_refÚlast_refÚtagsr   Ú_branch_format)Úselfr   r   r   r   r   r   s          úJ/usr/lib/python3/dist-packages/breezy/plugins/fastimport/branch_updater.pyÚ__init__zBranchUpdater.__init__    sH   € ð ˆŒ	ØˆŒØ"ˆŒØ(ˆÔØ ˆŒØˆŒ	å3°DÑ9Ô9ð 	ÔÐÐó    c                 ó¢   — g }|                       ¦   «         \  }}|D ]0\  }}|                      ||¦  «        r|                     |¦  «         Œ1||fS )aà  Update the Bazaar branches and tips matching the heads.

        If the repository is shared, this routine creates branches
        as required. If it isn't, warnings are produced about the
        lost of information.

        :return: updated, lost_heads where
          updated = the list of branches updated ('trunk' is first)
          lost_heads = a list of (bazaar-name,revision) for branches that
            would have been created had the repository been shared
        )Ú_get_matching_branchesÚ_update_branchÚappend)r   ÚupdatedÚbranch_tipsÚ
lost_headsÚbrÚtips         r   ÚupdatezBranchUpdater.update0   sh   € ð ˆØ"&×"=Ò"=Ñ"?Ô"?Ñˆ�ZØ"ð 	#ð 	#‰GˆB�Ø×"Ò" 2 sÑ+Ô+ð #Ø—’˜rÑ"Ô"Ð"øØ˜
Ð"Ð"r   c                 ó  ‡ — g }g }t          ‰ j        ¦  «        }‰ j        �Y‰                      |¦  «        }‰ j        |         d         }|                     ‰ j        |f¦  «         |                     |¦  «         i }|D ]$}‰ j        j                             |¦  «        ||<   Œ%|r+‰ j        €$‰                      |¦  «        }|||         fg}||= ng }| 	                    t          |                     ¦   «         t          d¦  «        ¬¦  «        ¦  «         ˆ fd„}	ˆ fd„}
‰ j        �|
}n|	}‰ j                             ¦   «         p‰ j        j        j        j        }|D ]ª\  }}‰ j        |         d         }|r]	 ‰                      |||¦  «        }|                     ||f¦  «         ŒJ# t&          j        $ r}t+          d||¦  «         Y d}~nd}~ww xY w‰ j                             |¦  «        }||f}|                     |¦  «         Œ«||fS )aq  Get the Bazaar branches.

        :return: branch_tips, lost_heads where
          branch_tips = a list of (branch,tip) tuples for branches. The
            first tip is the 'trunk'.
          lost_heads = a list of (bazaar-name,revision) for branches that
            would have been created had the repository been shared and
            everything succeeded
        Nr   r   )Úkeyc                 ó\   •— ‰j         j        j        j        }t	          j        |d| ¦  «        S ©Nz..)r   r
   r   Úbaser   Úpathjoin)ÚnameÚ	repo_baser   s     €r   Údir_under_currentz?BranchUpdater._get_matching_branches.<locals>.dir_under_currente   s(   ø€ àœ	Ô,Ô6Ô;ˆIÝÔ# I¨t°TÑ:Ô:Ð:r   c                 óD   •— t          j        ‰j        j        d| ¦  «        S r)   )r   r+   r   r*   )r,   r   s    €r   Údir_sister_branchz?BranchUpdater._get_matching_branches.<locals>.dir_sister_branchj   s   ø€ åÔ# D¤KÔ$4°d¸DÑAÔAÐAr   z%ERROR: failed to create branch %s: %s)Úlistr   r   Úselect_trunkr   Úremover   Úbranch_mapperÚ
git_to_bzrÚextendÚsortedÚitemsr   r   Ú	is_sharedr
   Ú_formatÚcolocated_branchesÚmake_branchr   ÚBzrErrorr   Úlookup_committish)r   r!   r"   Ú	ref_namesÚtrunkÚdefault_tipÚgit_to_bzr_mapÚref_nameÚgit_bzr_itemsr.   r0   Ú
dir_policyÚcan_create_branchesr,   r$   r#   ÚexÚ	lost_headÚ	lost_infos   `                  r   r   z$BranchUpdater._get_matching_branchesC   s¢  ø€ ð ˆØˆ
Ý˜Ô*Ñ+Ô+ˆ	ØŒ;Ð"Ø×%Ò% iÑ0Ô0ˆEØÔ+¨EÔ2°1Ô5ˆKØ×Ò ¤¨[Ð9Ñ:Ô:Ð:Ø×Ò˜UÑ#Ô#Ð#ð ˆØ!ð 	ð 	ˆHØ'+¤~Ô'C×'NÒ'NØñ(ô (ˆN˜8Ñ$Ð$àð 	˜œÐ,Ø×%Ò% iÑ0Ô0ˆEØ# ^°EÔ%:Ð;Ð<ˆMØ˜uÐ%Ð%àˆMØ×Ò�V N×$8Ò$8Ñ$:Ô$:Å
È1ÁÄÐNÑNÔNÑOÔOÐOð	;ð 	;ð 	;ð 	;ð 	;ð
	Bð 	Bð 	Bð 	Bð 	Bð Œ;Ð"Ø*ˆJˆJà*ˆJð ŒI×ÒÑ!Ô!ð <ØŒIÔ Ô(Ô;ð 	ð ,ð 	)ð 	)‰NˆH�dØÔ# HÔ-¨aÔ0ˆCØ"ð )ð)Ø×)Ò)¨$°¸*ÑEÔE�BØ×&Ò&¨¨C yÑ1Ô1Ð1ØøÝ”ð )ð )ð )ÝÐFØ# Rñ)ô )ð )ð )ð )ð )ð )ð )øøøøð)øøøð œ×8Ò8¸Ñ=Ô=ˆIØ˜yÐ)ˆIØ×Ò˜iÑ(Ô(Ð(Ð(Ø˜JÐ&Ð&s   Å7.F&Æ&GÆ5GÇGc                 ó*   — dD ]
}||v r|c S Œ| j         S )z2Given a set of ref names, choose one as the trunk.)zrefs/heads/master)r   )r   r?   Ú	candidates      r   r2   zBranchUpdater.select_trunk…   s7   € à.ð 	!ð 	!ˆIØ˜IÐ%Ð%Ø Ð Ð Ð ð &ð Œ}Ðr   c                 ó<  — | j                              ¦   «         r© ||¦  «        }t          j        |¦  «        }|                     ¦   «          	 t
          j                             |¦  «                             ¦   «         S # t          j
        $ r2}t
          j                             || j        |g¬¦  «        cY d}~S d}~ww xY w	 | j         j                             |¦  «        S # t          j
        $ r)}| j         j                             |¦  «        cY d}~S d}~ww xY w)z5Make a branch in the repository if not already there.)ÚformatÚpossible_transportsN)r   r9   r   Úget_transportÚcreate_prefixr
   Ú
ControlDirÚopenÚopen_branchr   ÚNotBranchErrorÚcreate_branch_conveniencer   Úcreate_branch)r   r,   rC   rE   ÚlocationÚto_transportrG   s          r   r<   zBranchUpdater.make_branch�   sI  € àŒ9×ÒÑ Ô ð 	@Ø!�z $Ñ'Ô'ˆHÝ$Ô2°8Ñ<Ô<ˆLØ×&Ò&Ñ(Ô(Ð(ð8Ý!Ô,×1Ò1°(Ñ;Ô;×GÒGÑIÔIÐIøÝÔ(ð 8ð 8ð 8Ý!Ô,×FÒFØØÔ.Ø)5¨ð Gñ 8ô 8ð 8ð 8ð 8ð 8ð 8ð 8øøøøð8øøøð@Ø”yÔ+×7Ò7¸Ñ=Ô=Ð=øÝÔ(ð @ð @ð @Ø”yÔ+×9Ò9¸$Ñ?Ô?Ð?Ð?Ð?Ð?Ð?Ð?øøøøð@øøøs<   Á0A? Á?C Â'B;Â5C Â;C ÃC# Ã#DÃ2DÄDÄDc                 ó  — | j                              |¦  «        }| j                             ¦   «         5  | j                             ¦   «         }|                     |g ¦  «        }ddd¦  «         n# 1 swxY w Y   |                     ¦   «         \  }}d}||k    s||k    r|                     ||¦  «         d}i }	| j        r| j                             ¦   «         }d„ | 	                    |g¦  «        D ¦   «         }
| j         
                    ¦   «         D ]\  }}||
v r||	|<   Œ|	r|j                             |	¦  «         d}|rFt          |	¦  «        }t          d|j        |t          |dd¦  «        |t          |dd	¦  «        ¦  «         |S )
zxUpdate a branch with last revision and tag information.

        :return: whether the branch was changed or not
        NFTc                 ó   — g | ]	\  }}|®|‘Œ
S )N© )Ú.0ÚrÚpss      r   ú
<listcomp>z0BranchUpdater._update_branch.<locals>.<listcomp>²   s(   € ð 2ð 2ð 2™g˜q "Ø"$ .ð Ø"0 . .r   z#	 branch %s now has %d %s and %d %sÚrevisionÚ	revisionsÚtagr   )r   r>   r   Ú	lock_readÚ	get_graphÚfind_distance_to_nullÚlast_revision_infoÚset_last_revision_infor   Úiter_ancestryr8   Ú_set_tag_dictÚlenr	   Únickr   )r   r#   Ú	last_markÚlast_rev_idÚgraphÚrevnoÚexisting_revnoÚexisting_last_rev_idÚchangedÚmy_tagsÚancestryrb   ÚrevÚtagnos                 r   r   zBranchUpdater._update_branch    s  € ð
 ”n×6Ò6°yÑAÔAˆØŒY× Ò Ñ"Ô"ð 	Að 	AØ”I×'Ò'Ñ)Ô)ˆEØ×/Ò/°¸RÑ@Ô@ˆEð	Að 	Að 	Añ 	Aô 	Að 	Að 	Að 	Að 	Að 	Að 	Aøøøð 	Að 	Að 	Að 	Að 02×/DÒ/DÑ/FÔ/FÑ,ˆÐ,ØˆØ�NÒ"Ð" kÐ5IÒ&IÐ&IØ×%Ò% e¨[Ñ9Ô9Ð9ØˆGàˆØŒ9ð 		Ø”I×'Ò'Ñ)Ô)ˆEð2ð 2¨×)<Ò)<Ø�ñ*ô *ð 2ñ 2ô 2ˆHà œIŸOšOÑ-Ô-ð 'ð '‘��SØ˜(�?�?Ø#&�G˜C‘LøØð Ø”×%Ò% gÑ.Ô.Ð.Ø�Øð 	=Ý˜‘L”LˆEÝÐ7¸¼Ø� e¨Z¸ÑEÔEØ� e¨U°FÑ;Ô;ñ=ô =ð =ð ˆs   ´0A0Á0A4Á7A4N)	Ú__name__Ú
__module__Ú__qualname__r   r%   r   r2   r<   r   r[   r   r   r   r      su   € € € € € ð:ð :ð :ð #ð #ð #ð&@'ð @'ð @'ðDð ð ð@ð @ð @ð&ð ð ð ð r   r   N)Ú__doc__Úoperatorr   Ú r   r   r   Útracer   r	   Úbreezyr
   Úhelpersr   r   r   r[   r   r   ú<module>r€      sÌ   ðð  IÐ Hà Ð Ð Ð Ð Ð à *Ð *Ð *Ð *Ð *Ð *Ð *Ð *Ð *Ð *Ø %Ð %Ð %Ð %Ð %Ð %Ð %Ð %à Ð Ð Ð Ð Ð ðð ð ð ð ð ð ð ðað að að að añ aô að að að ar   