HEX
Server: Apache
System: Linux infong-uk86 4.4.400-icpu-106 #2 SMP Mon Sep 15 08:23:40 UTC 2025 x86_64
User: u44115835 (4976590)
PHP: 8.4.17
Disabled: NONE
Upload Files
File: //kunden/lib/python3/dist-packages/breezy/__pycache__/upgrade.cpython-39.pyc
a

�*�^2�@s�dZddlmZddlmZmZmZmZddlm	Z	m
Z
ddlmZddl
mZGdd	�d	e�Zddd
�Zddd�Zddd�Zdd�Zddd�Zd
S)zbrz upgrade logic.�)�absolute_import�)�errors�trace�ui�urlutils)�
ControlDir�format_registry)�gettext)�RemoteBzrDirc@s&eZdZddd�Zdd�Zdd�ZdS)	�ConvertNc	Cs�||_d}|tjjv}|dur.|dur.td��|dur>||_nt�|�|_t|jt	�rj|j�
�|jj|_|jj�
�r|tj�|jj|_tjj�|�z|��W|s�tjj�|�n|s�tjj�|�0dS)a�Convert a Bazaar control directory to a given format.

        Either the url or control_dir parameter must be given.

        :param url: the URL of the control directory or None if the
          control_dir is explicitly given instead
        :param format: the format to convert to or None for the default
        :param control_dir: the control directory or None if it is
          specified via the URL parameter instead
        Zcross_format_fetchNz4either the url or control_dir parameter must be set.)�formatr�
ui_factoryZsuppressed_warnings�AssertionError�
controldirr�open_unsupported�
isinstancerZ_ensure_realZ_real_bzrdir�root_transportZis_readonlyrZUpgradeReadonly�	transport�add�convert�remove)�self�urlr
�control_dirZ
warning_idZ
saved_warning�r�0/usr/lib/python3/dist-packages/breezy/upgrade.py�__init__%s.�



�zConvert.__init__c	Csjz<|j��}|j|jjkr8tj�td�t�|jd��~Wnt	j
t	jfyVYn0|jdur�z|j�
�jj}Wnt	jy�d}Yn0|r�d}nd}t�|�}n|j}|j�|�s�t	�|jj��|j��s�t	�td�|jj��|j�|�tj�td�t�|jjd��|j��\|_|_|j�|��rV|jj�|�}|�|jd�|_�q&tj�td��dS)	NzDThis is a checkout. The branch (%s) needs to be upgraded separately.�utf-8Fzdefault-rich-root�defaultz$cannot upgrade from bzrdir format %szstarting upgrade of %sZfinished)r�open_branchZuser_urlrr�noter
r�unescape_for_displayr�NotBranchErrorZIncompatibleRepositoriesr
Zfind_repositoryZ_formatZrich_root_data�NoRepositoryPresentr	Zmake_controldirZneeds_format_conversion�UpToDateFormatZcan_convert_formatZBzrErrorZcheck_conversion_targetr�baseZ
backup_bzrdirZbackup_oldpath�backup_newpathZ
get_converterr)r�branchZ	rich_rootZformat_namer
Z	converterrrrrHsL
���



��zConvert.convertcCsX|j}|�|j�}tj���(}|�td��|�|�Wd�n1sJ0YdS)zUClean-up after a conversion.

        This removes the backup.bzr directory.
        zDeleting backup.bzrN)	r�relpathr'rr�nested_progress_bar�updater
Zdelete_tree)rrZbackup_relpath�child_pbrrr�clean_upps
zConvert.clean_up)NNN)�__name__�
__module__�__qualname__rrr-rrrrr#s
#(rNFcCsdt�|�g}t||||d�\}}}t|�dkr`t|�}t|�}	||	}
tj�td��||	|
��|S)a�Upgrade locations to format.

    This routine wraps the smart_upgrade() routine with a nicer UI.
    In particular, it ensures all URLs can be opened before starting
    and reports a summary at the end if more than one upgrade was attempted.
    This routine is useful for command line tools. Other breezy clients
    probably ought to use smart_upgrade() instead.

    :param url: a URL of the locations to upgrade.
    :param format: the format to convert to or None for the best default
    :param clean-up: if True, the backup.bzr directory is removed if the
      upgrade succeeded for a given repo/branch/tree
    :param dry_run: show what would happen but don't actually do any upgrades
    :return: the list of exceptions encountered
    �r-�dry_runrz;
SUMMARY: {0} upgrades attempted, {1} succeeded, {2} failed)	rr�
smart_upgrade�lenrrr!r
r
)rr
r-r2�control_dirs�	attempted�	succeeded�
exceptionsZattempted_countZsucceeded_countZfailed_countrrr�upgrade|s���r9cCsTg}g}g}|D]8}t||||d�\}}	}
|�|�|�|	�|�|
�q|||fS)a�Convert control directories to a new format intelligently.

    If the control directory is a shared repository, dependent branches
    are also converted provided the repository converted successfully.
    If the conversion of a branch fails, remaining branches are still tried.

    :param control_dirs: the BzrDirs to upgrade
    :param format: the format to convert to or None for the best default
    :param clean_up: if True, the backup.bzr directory is removed if the
      upgrade succeeded for a given repo/branch/tree
    :param dry_run: show what would happen but don't actually do any upgrades
    :return: attempted-control-dirs, succeeded-control-dirs, exceptions
    r1)�_smart_upgrade_one�extend)r5r
r-r2Z
all_attemptedZ
all_succeededZall_exceptionsrr6r7r8rrrr3�s�

r3cCs�d}z|��}Wntjy$Yn0|��r>t|jdd��}|g}t|g|||�\}}|r�|r�tj�	t
d�t|�f�dd�|D�}	t|	|||dd�\}
}|�|	�|�|
�|�|�|||fS)	zmConvert a control directory to a new format intelligently.

    See smart_upgrade for parameter details.
    NT)Zusingz+Found %d dependent branches - upgrading ...cSsg|]
}|j�qSr)r)�.0�brrr�
<listcomp>��z&_smart_upgrade_one.<locals>.<listcomp>r()�label)
�open_repositoryrr$Z	is_shared�listZ
find_branches�_convert_itemsrrr!r
r4r;)rr
r-r2Z
dependents�repor6r7r8Zbranch_cdirsZ	successesZproblemsrrrr:�s.
���



r:c	Cs�z6z|jddd�}Wnty2|jdd�}Yn0WntjyJYn
0|dfSz|��}WntjytYn
0|dfSz|��}Wntjtjfy�Yn
0|dfSt	d|��dS)	aCReturn the primary object and type label for a control directory.

    :return: object, label where:
      * object is a Branch, Repository or WorkingTree and
      * label is one of:
        * branch            - a branch
        * repository        - a repository
        * tree              - a lightweight checkout
    T)Zunsupported�ignore_fallbacks)rEr(Z
repositoryZtreez$unknown type of control directory %sN)
r �NotImplementedErrorrr#rAr$Zopen_workingtreeZ
NoWorkingTreeZNotLocalUrlr)r�brrDZwtrrr�_get_object_and_label�s*
�
rHcCs�g}g}tj�����}|�td�dt|��t|�D�]�\}}	|	jj}
t	|	�\}}|pX|}
|�td�|
|dt|��tj�
td��|
t�
|
d���z|s�t|	|d�}Wn�tjy�}z2tj�
t|��|�|	�WYd}~q4WYd}~nRd}~0t�y@}z0t�d	|�|�|�WYd}~q4WYd}~n
d}~00|�|	�|r4z"tj�
td
��|�sp|��Wq4t�y�}z,t�td�|
|f�|�|�WYd}~q4d}~00q4Wd�n1�s�0Y||fS)aConvert a sequence of control directories to the given format.

    :param items: the control directories to upgrade
    :param format: the format to convert to or None for the best default
    :param clean-up: if True, the backup.bzr directory is removed if the
      upgrade succeeded for a given repo/branch/tree
    :param dry_run: show what would happen but don't actually do any upgrades
    :param label: the label for these items or None to calculate one
    :return: items successfully upgraded, exceptions
    zUpgrading bzrdirsrzUpgrading %srzUpgrading {0} {1} ...r)rr
Nzconversion error: %szRemoving backup ...zfailed to clean-up {0}: {1})rrr*r+r
r4�	enumeraterr&rHr!r
rr"rrr%�str�append�	ExceptionrZwarningr-)�itemsr
r-r2r@r7r8r,�ir�locationZ
bzr_objectZ	bzr_labelZ
type_labelZcv�exrrrrCsN
��
�
 
"
�BrC)NFF)FF)FF)N)�__doc__Z
__future__r�rrrrrrr	Zi18nr
Z
bzr.remoter�objectrr9r3r:rHrCrrrr�<module>sY
�
�
,$