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__/bisect.cpython-39.pyc
a

�*�^4A�@s�dZddlmZddlZddlmZddlmZddl	m
Z
ddlmZdd	l
mZdd
lmZddlmZdZd
ZGdd�de�ZGdd�de�ZGdd�de
�ZdS)zbisect command implementations.�)�absolute_importN�)�
ControlDir��revision)�Command)�BzrCommandError)�Option)�	text_type)�note�bisectZbisect_revidc@s\eZdZdZefdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dS)�
BisectCurrentz/Bisect class for managing the current revision.cCsL||_||_|j��|_|jj�|�r<|jj�|���|_n|j�	�|_dS�N)
�	_filename�_controldir�open_branch�_branch�control_transport�hasZ	get_bytes�strip�_revid�
last_revision��self�
controldir�filename�r�//usr/lib/python3/dist-packages/breezy/bisect.py�__init__'s�zBisectCurrent.__init__cCs|jj�|j|jd�dS)zSave the current revision.�
N)rr�	put_bytesrr�rrrr�_save1s�zBisectCurrent._savecCs|jS)zReturn the current revision id.)rr!rrr�get_current_revid6szBisectCurrent.get_current_revidcCs|j�|j�S)z.Return the current revision number as a tuple.)rZrevision_id_to_dotted_revnorr!rrr�get_current_revno:szBisectCurrent.get_current_revnocCsL|jj}|���(|�|jg��|jd�}Wd�n1s>0Y|S)z6Return the IDs of the current revision's predecessors.N)r�
repository�	lock_read�get_parent_mapr�get)r�repo�retvalrrr�get_parent_revids>s
6zBisectCurrent.get_parent_revidscCst|���dkS)z&Is the current revision a merge point?r��lenr+r!rrr�is_merge_pointEszBisectCurrent.is_merge_pointcCsD|jj�|j�}d�dd�|��D��}|�d||j|jf�dS)z1Write the current revision's log entry to a file.�.cSsg|]}t|��qSr)�str��.0�xrrr�
<listcomp>L�z.BisectCurrent.show_rev_log.<locals>.<listcomp>zOn revision %s (%s):
%s
N)	rr%Zget_revisionr�joinr$�writeZrevision_id�message)r�outfZrev�revnorrr�show_rev_logIs
�zBisectCurrent.show_rev_logcCsh|j��}t|t�r"|j�|�}nt|t�r>|d�|j�j	}|�
d|jj�|�d�||_
|��dS)z/Switch the current revision to the given revid.rNF)r�open_workingtree�
isinstance�intr�
get_rev_id�list�
in_history�branch�rev_id�revertr%�
revision_treerr")r�revid�workingrrr�switchPs


�zBisectCurrent.switchcCsP|j��}|j��}|jj�|�}|�d|d�|jj�t	�rL|jj�
t	�dS)z5Revert bisection, setting the working tree to normal.NF)rr<rBrr%rErDrr�BISECT_REV_PATH�delete)rrGZlast_revZrev_treerrr�reset\s

zBisectCurrent.resetN)�__name__�
__module__�__qualname__�__doc__rIrr"r#r$r+r.r;rHrKrrrrr
$s
r
c@s�eZdZdZefdd�Zdd�Zdd�Zd!d	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd �ZdS)"�	BisectLogzBisect log file handler.cCs@g|_t|�|_||_d|_d|_d|_d|_||_|�	�dSr)
�_itemsr
�_currentrr�_high_revid�
_low_revid�
_middle_revidr�loadrrrrris
zBisectLog.__init__cCs |jr|jj�|j�StjSdS)zOpen log file for reading.N)rrrr(�sys�stdinr!rrr�_open_for_readtszBisectLog._open_for_readcCs|js|j��|_dS)zLoad bzr information.N)rrrr!rrr�
_load_tree{szBisectLog._load_treeNcs^|��d|_|s|j��}n|}|jj}|����|��}|�|tj	f�}d}d}g}|D]r�|�
d���fdd�|jD�}	|	s�q\t|	�dkr�t
d���|	ddkr��}g}q\|	ddkr\�}|d=q�q\|s�|}|s�|j�d�}Wd�n1s�0Yt|�d}
|
d	k�r"d}n|
d	d}t|�dk�rH|||_n||_||_||_dS)
z2Find the current revision range, and the midpoint.Nrcs,g|]$}|d�kr|ddvr|d�qS)rr��yes�norr1rrrr4�s�z4BisectLog._find_range_and_middle.<locals>.<listcomp>rzrevision %s duplicatedr\r]�)rZrUrrr%r&Z	get_graphZiter_lefthand_ancestry�
_mod_revisionZ
NULL_REVISION�insertrQr-�RuntimeErrorr?rSrT)rZbranch_last_revZ
last_revidr)ZgraphZrev_sequenceZ
high_revidZ	low_revidZbetween_revsZmatchesZspreadZmiddle_indexrrr�_find_range_and_middle�sR
�*
z BisectLog._find_range_and_middlecCs|j�|�|jj|d�dS)z)Move the working tree to the given revno.�r9N)rRrHr;)rr:r9rrr�_switch_wc_to_revno�szBisectLog._switch_wc_to_revnocCsD|��s@|dkr0|dd�|jD�vr0td|��|j�||f�dS)z*Set the bisect status for the given revid.�donecSs g|]}|ddvr|d�qS)rr[rrr1rrrr4�s�z)BisectLog._set_status.<locals>.<listcomp>z attempting to add revid %s twiceN)�is_donerQra�append)rrF�statusrrr�_set_status�szBisectLog._set_statuscCs
||_dS)zSwitch log files.N)r)rrrrr�change_file_name�szBisectLog.change_file_namecCsNg|_|jj�|j�rJ|��}|D]&}|��\}}|j�||�d�f�q"dS)zLoad the bisection log.�asciiN)	rQrrrrrY�splitrg�decode)rZrevlog�linerFrhrrrrV�szBisectLog.loadcCs@d�dd�|jD��}|jr0|jj�|j|�ntj�|�dS)zSave the bisection log.r5css$|]\}}d||�d�fVqdS)s%s %s
rkN)�encode)r2rFrhrrr�	<genexpr>�s�z!BisectLog.save.<locals>.<genexpr>N)	r6rQrrrr rW�stdoutr7)r�contentsrrr�save�s
��zBisectLog.savecCs t|j�dko|jdddkS)z.Report whether we've found the right revision.r���rre)r-rQr!rrrrf�szBisectLog.is_donecCs*|��|d�|j�j}|�||�dS)z5Set the bisection status for the revision in revspec.rN)rZrArrCri)r�revspecrhrFrrr�set_status_from_revspec�sz!BisectLog.set_status_from_revspeccCs|�|j��|�dS)z7Set the current revision to the given bisection status.N)rirRr#)rrhrrr�set_current�szBisectLog.set_currentcCst|�|��dkS)Nrr,)rrFrrrr.�szBisectLog.is_merge_pointcCsH|jj}|���$|�|g��|d�}Wd�n1s:0Y|Sr)rr%r&r'r()rrFr)r*rrrr+�s
2zBisectLog.get_parent_revidscCs�|��|j|jks |j|jkr\|�|j�r\|�|j�D] }||jkrJq8q8|�|�qq8q|�|j|�|j|jks�|j|jkr�|�d�dS)z4Using the current revision's status, do a bisection.reN)rbrUrSrTr.r+rdrw)rr9�parentrrrr�s 
�
�


�zBisectLog.bisect)N)rLrMrNrO�BISECT_INFO_PATHrrYrZrbrdrirjrVrsrfrvrwr.r+rrrrrrPfs 
9	rPc@s�eZdZdZddgZeddded�dd	gZd
d�Zdd
�Z	d"dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�ZdS)#�
cmd_bisectaFind an interesting commit using a binary search.

    Bisecting, in a nutshell, is a way to find the commit at which
    some testable change was made, such as the introduction of a bug
    or feature.  By identifying a version which did not have the
    interesting change and a later version which did, a developer
    can test for the presence of the change at various points in
    the history, eventually ending up at the precise commit when
    the change was first introduced.

    This command uses subcommands to implement the search, each
    of which changes the state of the bisection.  The
    subcommands are:

    brz bisect start
        Start a bisect, possibly clearing out a previous bisect.

    brz bisect yes [-r rev]
        The specified revision (or the current revision, if not given)
        has the characteristic we're looking for,

    brz bisect no [-r rev]
        The specified revision (or the current revision, if not given)
        does not have the characteristic we're looking for,

    brz bisect move -r rev
        Switch to a different revision manually.  Use if the bisect
        algorithm chooses a revision that is not suitable.  Try to
        move as little as possible.

    brz bisect reset
        Clear out a bisection in progress.

    brz bisect log [-o file]
        Output a log of the current bisection to standard output, or
        to the specified file.

    brz bisect replay <logfile>
        Replay a previously-saved bisect log, forgetting any bisection
        that might be in progress.

    brz bisect run <script>
        Bisect automatically using <script> to determine 'yes' or 'no'.
        <script> should exit with:
           0 for yes
           125 for unknown (like build failed so we could not test)
           anything else for no
    �
subcommandzargs*�output�ozWrite log to this file.)Z
short_name�help�typer�	directorycCs|j�t�std��dS)z0Check preconditions for most operations to work.zNo bisection in progress.N)rrryr�rrrrr�_check@szcmd_bisect._checkcCs`t|�}|��r,td�|jj|jd�dS|r>|�||�n
|�|�|�|j�|�	�dS)zkSet the state of the given revspec and bisecting.

        Returns boolean indicating if bisection is done.z"No further bisection is possible.
rcTF)
rPrfrrRr;r9rvrwrrs)rrru�state�
bisect_logrrr�
_set_stateEs
zcmd_bisect._set_stater/Nc
Cs>d}|dvr|rn^|dvr4|r4t|�dkr4|d}n<|dvrJ|sJtd��n&|dvr\|d}n|sd|rptd	|��t�|�\}}	|d
kr�|�|�n�|dkr�|�||�n�|dkr�|�||�n||d
kr�|�||�nf|dkr�|�|�nR|dkr�|�	||�n<|dk�r|�
||�n$|dk�r.|�||�ntd|��dS)zHandle the bisect command.N)r\r]�move)�replayrr)r�z.The 'bisect move' command requires a revision.)�runzImproper arguments to bisect �startr\r]r�rK�logr�r�zUnknown bisect command: )r-rrZopen_containingr�r\r]r�rKr�r��
run_bisect)
rr{Z	args_listr�rr|Zlog_fnZ
run_scriptr�_rrrr�WsF
�
�

�zcmd_bisect.runcCs&|�|�t|���|j�t�dS)z#Reset the bisect state to no state.N)r�r
rKrrJryr�rrrrK�s
zcmd_bisect.resetcCsB|j�t�r$t|���|j�t�t|�}|�d�|��dS)z9Reset the bisect state, then prepare for a new bisection.r�N)	rrryr
rKrJrPrwrs)rrr�rrrr��s
zcmd_bisect.startcCs|�||d�dS)z;Mark that a given revision has the state we're looking for.r\N�r��rrrurrrr\�szcmd_bisect.yescCs|�||d�dS)zMark a given revision as wrong.r]Nr�r�rrrr]�sz
cmd_bisect.nocCs$t|�}|�|�|j|jd�dS)z&Move to a different revision manually.rcN)r
rHr;r9)rrruZcurrentrrrr��s
zcmd_bisect.movecCs(|�|�t|�}|�|�|��dS)z'Write the current bisect log to a file.N)r�rPrjrs�rrrr�rrrr��s

zcmd_bisect.logcCsP|j�t�r$t|���|j�t�t||�}|�t�|��|�	|j
�dS)zlApply the given log file to a clean state, so the state is
        exactly as it was when the log was saved.N)rrryr
rKrJrPrjrsrr9r�rrrr��s

zcmd_bisect.replaycCs�ddl}td�|�|�z\|j|dd�}|��|j}|dkrP|�|dd�}n|dkr^Wq�n|�|dd�}|rtWq�Wqty�Yq�Yq0qdS)NrzStarting bisect.T)�shellr\�}r])�
subprocessrr��Popen�wait�
returncoder�ra)rrZscriptr�ZprocessZretcodererrrr��s 
zcmd_bisect.run_bisect)r/NN)rLrMrNrOZ
takes_argsr	r
Z
takes_optionsr�r�r�rKr�r\r]r�r�r�r�rrrrrz	s(1���
)
rz)rOZ
__future__rrWrr�rr_Zcommandsr�errorsrZoptionr	Zsixishr
ZtracerryrI�objectr
rPrzrrrr�<module>sB$