File: //kunden/lib/python3/dist-packages/breezy/__pycache__/switch.cpython-39.pyc
a
�*�^� � @ sp d dl mZ ddlmZmZmZmZ ddlmZ ddl m
Z
ddlmZ dd� Z
ddd�Zdd
d�Zdd� Zd
S )� )�absolute_import� )�errors�lock�merge�revision)�Branch)�gettext)�notec C sB ddl m} tjd }|sd S || |||�}|D ]}||� q0d S )Nr )�SwitchHookParamsZpost_switch)�branchr r �hooks)�control_dir� to_branch�force�revision_idr r
�params�hook� r �//usr/lib/python3/dist-packages/breezy/switch.py�_run_post_switch_hooks s
r FNc
C s z| � � }W n8 tjyD } z|r&|r,|�nd}W Y d}~n*d}~0 0 |sT|j�� r^|�� n|�� zn|dur�|�� } t| �dkr�t� t
d���|r�|�� |du r�|j}
d}n|jj}
|�
� }W |dur�|�� n|dur�|�� 0 |�� �* t| ||�r|jnd|� W d � n1 �s"0 Y | � � }|�rD|�� n|�� z�|du �r`|�
� }|du �rr|�
� }||k�r�|�s�tt
d�|�� � nJ|
�|�}|j�|�}
t�||||
� |�|� |�s�tt
d�|�� � |�r�|�� t| |||� W |�� n
|�� 0 dS )a� Switch the branch associated with a checkout.
:param control_dir: ControlDir of the checkout to change
:param to_branch: branch that the checkout is to reference
:param force: skip the check for local commits in a heavy checkout
:param revision_id: revision ID to switch to.
:param store_uncommitted: If True, store uncommitted changes in the
branch.
Nr zAPending merges must be committed or reverted before using switch.z"Tree is up to date at revision %d.zUpdated to revision %d.)Zopen_workingtreer ZNotBranchErrorr �get_bound_location�
lock_writeZlock_tree_writeZget_parent_ids�len�BzrCommandErrorr �store_uncommitted�
repository�
last_revisionZunlock� lock_read�_set_branch_locationr
ZrevnoZ
revision_treer ZMerge3MergerZset_last_revisionZrestore_uncommittedr )r r r �quietr r �possible_transportsZtree�exZ
parent_idsZsource_repositoryZbase_revision_idZ base_treeZtarget_treer r r �switch* sj
�
�
:
�
r# c
C s� | � � }|�| �dur(|�| d|� �n`|}|�� }|dur�g }z |s^t||�r^t�td���W n: tjy� } z t�td�|j ��W Y d}~n
d}~0 0 |�
� �H |�d� |j|d|d� |�|j
� |�|�� �� � W d � n1 s�0 Y n�|�� �p |j�|j�} |jjj�rZ|�s>| �|�� |�� ��rZ|j�� |jj|dd� nt�td���W d � n1 �s~0 Y dS ) z�Set location value of a branch reference.
:param control: ControlDir of the checkout to change
:param to_branch: branch that the checkout is to reference
:param force: skip the check for local commits in a heavy checkout
NzyCannot switch as local commits found in the checkout. Commit these to the bound branch or use --force to throw them away.z_Unable to connect to current master branch %(target)s: %(error)s To switch anyway, use --force.T)Z overwriter! � )�namez(Cannot switch a branch, only a checkout.)Zfind_branch_formatZ
get_referenceZ
set_referencer �_any_local_commitsr r r ZBoundBranchConnectionFailure�__dict__r Zset_bound_locationZpull�baseZ
set_parent�get_master_branchZ
get_parentr r � get_graphZ
controldirZ_formatZcolocated_branches�is_ancestorr Zdestroy_branchZset_branch_reference)
Zcontrolr Zcurrent_branchr Z
branch_format�bZbound_branchr! �e�graphr r r r x sN �
��
�2
���
�r c C s� t �| �� �}|t jkr�| �|�}| �� �v |�� �N |�� }| j�|j�}|�||�stW d � W d � dS W d � n1 s�0 Y W d � n1 s�0 Y dS )z;Does this branch have any commits not in the master branch?NTF) r Zensure_nullr Z
NULL_REVISIONr) r r r* r+ )Zthis_branchr! Zlast_revZother_branchZother_last_revr. r r r r&