https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/mercurial/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/mercurial/__pycache__/transaction.cpython-310.pyc
o

�]Lb�g�@s�ddlmZddlZddlmZddlmZmZmZddl	m
Z
dZdZd	Z
d
Zdd�Z	
	ddd�ZGdd�dej�Zed�Zddd�ZdS)�)�absolute_importN�)�_)�error�pycompat�util)�
stringutil�sallsprefinalizespostfinalizecs�fdd�}|S)Ncs*|jdkr
t�d���|g|�Ri|��S)Nrs;cannot use transaction when it is already committed/aborted)�_countr�ProgrammingError)�self�args�kwds��func��7/usr/lib/python3/dist-packages/mercurial/transaction.py�_active"s

�zactive.<locals>._activer)rrrrr�active!srTcCs�tt|����D]i\}}	|	s|sO|o|df|v}
z&||d|
d�}|��|	kr4t�td�||	|��f��|�|	�|��Wqt	yN|td�|��wz|�
|�Wqt	tfyq}z
|jtj
krg�WYd}~qd}~wwg}
|D]�\}}}}||vr�|r�|d||f�||}zp|r�|r�|�|�}|�|�}|o�||f|v}
ztj|||
d�|
�|�WnHt	y�}zt�|�}|td�||f�WYd}~n,d}~ww|p�|}z|�
|�Wnt	tfy�}z
|jtj
kr�WYd}~nd}~wwWqvt	ttjf�y|�s�Yqvwd|}|�|��r |�
|�|�
|�z|
D]}|�|��r5|�
|��q(WdSt	ttjf�yHYdSw)	N��a)�
checkambigsBattempted to truncate %s to %d bytes, but it was already %d bytes
sfailed to truncate %s
s.couldn't handle %s: unknown cache location %s
sfailed to recover %s (%s)
�%s.backupfiles)�sorted�dict�items�tellr�Abortr�truncate�close�IOError�unlink�OSError�errno�ENOENT�joinr�copyfile�appendr�forcebytestr�exists)�journal�report�opener�vfsmap�entries�
backupentriesr!�checkambigfiles�f�or�fp�inst�backupfiles�l�b�c�vfs�filepath�
backuppath�exc�e_msg�targetrrr�	_playback,s�
���
����


 ��������


���r?c@s�eZdZ							dGdd�Zdd�Zdd�Zed	d
��Zedd��Z	ed
d��Z
edd��Zdd�ZedHdd��Z
dd�ZedIdd��Ze			dJdd��Zedd ��Zdefd!d"�Zed#d$��Zed%d&��Zed'd(��ZedKd)d*��Zd+d,�Zd-d.�Zd/d0�Zed1d2��Zed3d4��Zed5d6��Zed7d8��Zed9d:��Zed;d<��Z ed=d>��Z!ed?d@��Z"edAdB��Z#dCdD�Z$dEdF�Z%dS)L�transactionN�	<unnamed>cCsJd|_d|_||_||_|��}||d<||_||_i|_t�|_	||_
||_g|_|	dur2dd�}	|	|_
t�|_|
rA|j�|
�|g|_i|_i|_|�|j
d�|_g|_i|_d|j
|_|�|jd�|_|j�d	t�|dur�|�|j
|d
@�|�|j|d
@�i|_i|_d|_i|_i|_ |dur�||j d<i|_!i|_"dS)
aBegin a new transaction

        Begins a new transaction that allows rolling back writes in the event of
        an exception.

        * `after`: called after the transaction has been committed
        * `createmode`: the mode of the journal file that will be created
        * `releasefn`: called after releasing (with transaction and result)

        `checkambigfiles` is a set of (path, vfs-location) tuples,
        which determine whether file stat ambiguity should be avoided
        for corresponded files.
        rrNcSsdS�Nr)�tr�successrrr�<lambda>�sz&transaction.__init__.<locals>.<lambda>sw+r�w�%d
i�Fs
001-userhooks)#r
�_usages�_report�_opener�copy�_vfsmap�_after�
_offsetmap�set�	_newfiles�_journal�	_undoname�_queue�
_releasefn�_checkambigfiles�update�_names�changes�hookargs�open�_file�_backupentries�
_backupmap�_backupjournal�_backupsfile�write�version�chmod�_filegenerators�_pendingcallback�_anypending�_finalizecallback�_validatecallback�_postclosecallback�_abortcallback)rr+r,r-�journalname�undoname�after�
createmode�	validator�	releasefnr0�namerrr�__init__xsP

ztransaction.__init__cCsd�|j�}d||j|jfS)N�/z*<transaction name=%s, count=%d, usages=%d>)r%rWr
rH�rrprrr�__repr__�s�ztransaction.__repr__cCs|jr	|��dSdSrB)rQ�_abort�rrrr�__del__�s�ztransaction.__del__cCs
|jduSrB�rfrvrrr�	finalized�s
ztransaction.finalizedcCs|j�g�dS)z�delay registration of file entry

        This is used by strip to delay vision of strip offset. The transaction
        sees either none or all of the strip actions to be done.N)rSr'rvrrr�
startgroup�sztransaction.startgroupcCs(|j��}|D]
\}}|�||�qdS)z�apply delayed registration of file entry.

        This is used by strip to delay vision of strip offset. The transaction
        sees either none or all of the strip actions to be done.N)rS�pop�	_addentry)r�qr1r2rrr�endgroup�s
�ztransaction.endgroupcCsP||jvs||jvs||jvrdS|jr |jd�||f�dS|�||�dS)z5record the state of an append-only file before updateN���)rPrNr]rSr'r|�r�file�offsetrrr�add�s


ztransaction.addcCs`||jvs||jvs||jvrdS|r||j|<n|j�|�|j�d||f�|j��dS)z3add a append-only entry to memory and on-disk stateN�%s%d
)rPrNr]r�r[r`�flushr�rrrr|s


ztransaction._addentryTrcCs�|jr
d}t�|��||jvs||jvs||jvrdS|j|}|�|�\}}d|j|f}|�	||�}	|�
|�rL|�|�}
|�|	�}tj
|
||d�nd}	|�|||	df�dS)aWAdds a backup of the file to the transaction

        Calling addbackup() creates a hardlink backup of the specified file
        that is used to recover the file in the event of the transaction
        aborting.

        * `file`: the file path, relative to .hg/store
        * `hardlink`: use a hardlink to quickly create the backup
        s/cannot use transaction.addbackup inside "group"Ns%s.backup.%s��hardlinkrF)rSrrrPrNr]rL�splitrQ�reljoinr)r%rr&�_addbackupentry)rr�r��location�msgr9�dirname�filename�backupfilename�
backupfiler:r;rrr�	addbackups"







ztransaction.addbackupcCsB|j�|�t|j�d|j|d<|j�d|�|j��dS)z0register a new backup entry and write it to diskr�%s%s%s%d
N)r\r'�lenr]r_r`r�)r�entryrrrr�:sztransaction._addbackupentrycCs|�|d|df�dS)z�register a temporary transaction file

        Such files will be deleted when the transaction exits (on both
        failure and success).
        rFN)r�)r�tmpfiler�rrr�registertmpAsztransaction.registertmprFcCs|||||f}||j|<dS)a]add a function to generates some files at transaction commit

        The `genfunc` argument is a function capable of generating proper
        content of each entry in the `filename` tuple.

        At transaction close time, `genfunc` will be called with one file
        object argument per entries in `filenames`.

        The transaction itself is responsible for the backup, creation and
        final write of such file.

        The `genid` argument is used to ensure the same set of file is only
        generated once. Call to `addfilegenerator` for a `genid` already
        present will overwrite the old entry.

        The `order` argument may be used to control the order in which multiple
        generator will be executed.

        The `location` arguments may be used to indicate the files are located
        outside of the the standard directory for transaction. It should match
        one of the key of the `transaction.vfsmap` dictionary.

        The `post_finalize` argument can be set to `True` for file generation
        that must be run after the transaction has been finalized.
        N�rc)r�genid�	filenames�genfunc�orderr��
post_finalizer�rrr�addfilegeneratorJs%ztransaction.addfilegeneratorcCs||jvr|j|=dSdS)z=reverse of addfilegenerator, remove a file generator functionNr�)rr�rrr�removefilegeneratorrs
�ztransaction.removefilegeneratorc
Cs"d}|tkrd}}n|tk}|tk}tt�|j��D]s\}}d}|\}}	}
}}|r-|r-q|r2|s2q|j|}
g}zK|	D]+}||7}|rN|j||d�d}n|j	||d�||f|j
v}|�|
|dd|d��q<|
|�|D]}|��qn|dd�=W|D]}|�
�q}q|D]}|�
�q�w|S)NFT)r�rF)�
atomictempr)�
GEN_GROUP_ALL�GEN_GROUP_POST_FINALIZE�GEN_GROUP_PRE_FINALIZErr�	iteritemsrcrLr�r�rUr'r�discard)r�suffix�group�any�	skip_post�skip_pre�idr�r�r�r�r�r�r9�filesrprr1rrr�_generatefilesxsF

�


�
�ztransaction._generatefilescCs||jvrdS|j�|�S�Nr)rPrN�get)rr�rrr�
findoffset�s
ztransaction.findoffsetcCsD|j�d�g}|j��D]}|�d�\}}|�|t|�f�q
|S)Nr�)r[�seek�	readlinesr�r'�int)rr.r6r��troffsetrrr�readjournal�sztransaction.readjournalcCs�||jvr|s	dS|j�|�||j|<n||jvr-|s'|j|=|j�|�n
||j|<nt|��|j�d||f�|j��dS)zn
        replace can only replace already committed entries
        that are not pending in the queue
        Nr�)rP�removerNr��KeyErrorr[r`r�r�rrr�replace�s

ztransaction.replacecCs,|jd7_|jd7_|j�|�|S)Nr)r
rHrWr'rsrrr�nest�sztransaction.nestcCsP|jdkr|jd8_|jr|j��|jdkr$|jdkr&|��dSdSdS)Nrr)r
rHrWr{rurvrrr�release�s

�ztransaction.releasecCs
|jdkSr�)r
rvrrr�running�s
ztransaction.runningcC�||j|<dS)z�add a callback to be called when the transaction is pending

        The transaction will be given as callback's first argument.

        Category is a unique identifier to allow overwriting an old callback
        with a newer callback.
        N)rd�r�category�callbackrrr�
addpending�sztransaction.addpendingcCsLt|j�}|D]}|j�|�|�}|jp||_q|j|jdd�O_|jS)zpwrite pending file to temporary version

        This is used to allow hooks to view a transaction before commits.pending)r�)rrdr{rer�)r�
categories�catr�rrr�writepending�s
ztransaction.writependingcCs
||jvS)z0check is a callback already exist for a categoryrx�rr�rrr�hasfinalize�s
ztransaction.hasfinalizecCr�)z�add a callback to be called when the transaction is closed

        The transaction will be given as callback's first argument.

        Category is a unique identifier to allow overwriting old callbacks with
        newer callbacks.
        Nrxr�rrr�addfinalize��	ztransaction.addfinalizecCr�)z�add or replace a callback to be called after the transaction closed

        The transaction will be given as callback's first argument.

        Category is a unique identifier to allow overwriting an old callback
        with a newer callback.
        N)rhr�rrr�addpostcloser�ztransaction.addpostclosecCs|j�|d�S)z1return a postclose callback added before, or NoneN)rhr�r�rrr�getpostclosesztransaction.getpostclosecCr�)aadd a callback to be called when the transaction is aborted.

        The transaction will be given as the first argument to the callback.

        Category is a unique identifier to allow overwriting an old callback
        with a newer callback.
        N)rir�rrr�addabortr�ztransaction.addabortcCr�)z�adds a callback to be called when validating the transaction.

        The transaction will be given as the first argument to the callback.

        callback should raise exception if to abort transactionN)rgr�rrr�addvalidatorsztransaction.addvalidatorcCs�|jdkrAt|j�D]	}|j||�q
d|_|jtd�|jr8|j}i|_t|�}|D]}|||�q,|js d|_|jtd�|jd8_|jdkrOdS|j��|j	��|j
D]R\}}}}||jvrs|rs|�d||f�q\|j|}	|s�|r�|	�
|�r�z|	�|�Wq\tttjfy�}
z|s��|�d|	�|�|
f�WYd}
~
q\d}
~
wwq\i|_t�|_|��|jr�|��d|_|j�|j�r�|j�|j�|j�|j�r�|j�|j�|j
D]T\}}}}||jvr�|r�|�d||f�q�|j|}	|�r7|	�
|��r7z|	�|�Wq�tttjf�y6}
z|�s �|�d|	�|�|
f�WYd}
~
q�d}
~
wwq�g|_
d|_|�|d�d|_t|j�}|D]
}|j||��qNd|_dS)	zcommit the transactionrN)r�rs.couldn't remove %s: unknown cache location %s
scouldn't remove %s: %s
�-couldn't remove %s: unknown cache location%s
T)r
rrgr�r�rfr�r[rr_r\rLrIr)r!r r"rrr%rNrOrP�
_writeundorMrJ�isfiler^rQrTrh)rr��	callbacksr�r�r6r1r7r8r9r4�_frrrr's�
�



�
������
����

ztransaction.closecCs|��dS)z�abort the transaction (generally called on error, or when the
        transaction is not explicitly committed before going out of
        scope)N)rurvrrr�abortysztransaction.abortcCs|jdurdSd|j}|j�|d�}|�dt�|jD]]\}}}}|s&q|s+d}nD||jvr<|r<|�d||f�q|j|}|�|�\}	}
|
�	|j
�sRJ|
��|
�|j
|jd�}|�|	|�}t
j|�|�|�|�dd	�|�d
||||f�q|��dS)z4write transaction data for possible future undo callNrrFrGrr�rTr�r�)rRrJrZr`rar\rLrIr��
startswithrQr�r�rr&r%r)r�undo_backup_path�undobackupfiler6r1r7r8�ur9�baserp�unamerrrr��s2

��
ztransaction._writeundoc
Cs�|��}d|_d|_|j��|j��z�|s=|js=|jr$|j�	|j�|j
r.|j�	|j
�Wd|_
|�|d�d|_dS|�t
d��z-t|j�D]	}|j||�qJd|_t|j
|j|j|j||jd|jd�|�t
d��Wn%ty�}z|�t
d��|�t
d�t�|��WYd}~nd}~wwWd|_
|�|d�d|_dSWd|_
|�|d�d|_dSd|_
|�|d�d|_w)NrFstransaction abort!
�r0srollback completed
s(rollback failed - please run hg recover
s(failure reason: %s)
)r�r
rHr[rr_r\r^rJr!rQrTrIrrrir?rLrU�
BaseExceptionrr()rr.r�r<rrrru�sb



��
����
�
�ztransaction._abort)NNNNNNrA)Tr)r)rrF)rA)&�__name__�
__module__�__qualname__rqrtrw�propertyryrrzr~r�r|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�rurrrrr@ws�
�_


	
!�'
,


	











Q
r@s8journal was created by a different version of Mercurial
c	CsBg}g}|�|��}|��}Wd�n1swY|D](}	z|	�d�\}
}|�|
t|�f�WqtyG|td�t�|	��Yqwd|}|�	|�r�|�|�}|��}|r�|ddd�}
|
dt
kro|t�n%|dd�D]}|r�|dd�}|�d�\}	}
}}|�|	|
|t|�f�qut
|||||||d	�dS)
a�Rolls back the transaction contained in the given file

    Reads the entries in the specified file, and the corresponding
    '*.backupfiles' file, to recover from an incomplete transaction.

    * `file`: a file containing a list of entries, specifying where
    to truncate each file.  The file should contain a list of
    fileoffset pairs, delimited by newlines. The corresponding
    '*.backupfiles' file should contain a list of filebackupfile
    pairs, delimited by .

    `checkambigfiles` is a set of (path, vfs-location) tuples,
    which determine whether file stat ambiguity should be avoided at
    restoring corresponded files.
    Nr�s couldn't read journal entry %r!
rrrs%drr�)rZr�r�r'r��
ValueErrorrr�bytestrr)ra�BAD_VERSION_MSG�boolr?)r,r-r�r+r0r.r/r3�linesr6r1r2�
backupjournal�ver�liner7r8rrr�rollback�sJ
���


�
�r�)TNrB)�
__future__rr#�i18nr�rrr�utilsrrar�r�r�rr?�
transactionalr@r�r�rrrr�<module>s,

�KV�

https://t.me/RX1948 - 2025