File: //kunden/lib/python3/dist-packages/breezy/__pycache__/fetch_ghosts.cpython-39.pyc
a
�*�^� � @ sT d dl mZ ddlmZ ddlmZ ddlmZ ddlm Z m
Z
G dd� de�Zd S )
� )�absolute_import� )�cleanup)�Branch)�note)�NoSuchRevision�BzrCommandErrorc @ s8 e Zd Zedd� �Zdd� Zdd� Zdd� Zd d
� ZdS )�GhostFetcherc C sR t �d�d }|d u r:|�� }|d u r0td��n
td|� t �|�d }| ||�S )N�.r z*No branch specified and no location saved.zUsing saved location %s.)r Zopen_containingZ
get_parentr r )�cls�other�this_branch�other_branch� r �5/usr/lib/python3/dist-packages/breezy/fetch_ghosts.py�from_cmdline s
zGhostFetcher.from_cmdlinec C s || _ || _d S �N)r
r )�selfr
r r r r �__init__( s zGhostFetcher.__init__c C sh | j j| jjk}t�� �<}|�| j �� � |r>|�| j�� � | �� W d � S 1 sZ0 Y d S r ) r
�baser r � ExitStack�
enter_contextZ
lock_writeZ lock_read�_run_locked)r Z
lock_otherZ
exit_stackr r r �run, s
zGhostFetcher.runc c s� t � }| j�� g}|d du r"dS t|�dkr�g }|D ]P}||v rDq6|�|� z| jj�|�}|�|j� W q6 t y� |V Y q60 q6|}q"dS )z5Find all ancestors that aren't stored in this branch.r N)
�setr
�
last_revision�len�addZ
repositoryZget_revision�extendZ
parent_idsr )r �seen�linesZ new_lines�line�revisionr r r �iter_ghosts4 s
zGhostFetcher.iter_ghostsc C sx g }g }| j �� d u r"td� d S | �� }|D ]@}z| j �| j|� |�|� W q. tyl |�|� Y q.0 q.||fS )NzNo revisions in branch.)r
r �printr# Zfetchr �appendr )r Z installedZfailedZghostsr"