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 : |
o �]Lb�/ � @ s d Z ddlmZ ddlZddlmZ ddlmZmZm Z ddl mZ ejr8ddl mZmZ eefD ]Zes7J �q1G d d � d e�ZG dd� de�Zg Zi Z d&dd�Zdd� Zejdd� �Zdd� Zdd� Zeddded�ed�ed�d� ed d!dded"�d#� d$d%� ZdS )'a^ This file contains class to wrap the state for commands and other related logic. All the data related to the command state is stored as dictionary in the object. The class has methods using which the data can be stored to disk in a file under .hg/ directory. We store the data on disk in cbor, for which we use the CBOR format to encode the data. � )�absolute_importN� )�_)�error�pycompat�util)�cborutil)�Any�Dictc @ �@ e Zd ZdZdd� Zdd� Zdd� Zdd � Zd d� Zdd � Z dS )�cmdstatea� a wrapper class to store the state of commands like `rebase`, `graft`, `histedit`, `shelve` etc. Extensions can also use this to write state files. All the data for the state is stored in the form of key-value pairs in a dictionary. The class object can write all the data to a file in .hg/ directory and can populate the object data reading that file. Uses cbor to serialize and deserialize data while writing and reading from disk. c C s || _ || _dS )zorepo is the repo object fname is the file name in which data should be stored in .hg directory N)�_repo�fname)�self�repor � r �1/usr/lib/python3/dist-packages/mercurial/state.py�__init__9 s zcmdstate.__init__c C s | � � S )z=read the existing state file and return a dict of data stored)�_read�r r r r �read@ s z cmdstate.readc C sv t |t�s t�d��| jj| jddd��}|�d| � t� |�D ]}|�|� q!W d � dS 1 s4w Y dS )z�write all the state data stored to .hg/<filename> file we use third-party library cbor to serialize data to write in the file. s* version of state file should be an integers wbT)� atomictemps %d N) � isinstance�intr �ProgrammingErrorr �vfsr �writer �streamencode)r �version�data�fp�chunkr r r �saveE s ��"�z cmdstate.savec C sp | j �| jd��&}zt|�� � W n ty t�d��w t� |� � �d W d � S 1 s1w Y dS )ztreads the state file and returns a dictionary which contain data in the same format as it was before storings rbs# unknown version of state file foundr N)r r r r �readline� ValueErrorr �CorruptedStater � decodeallr )r r r r r r T s ��$�zcmdstate._readc C s t j| jj�| j�dd� dS )zdrop the state file if existsT)� ignoremissingN)r � unlinkpathr r �joinr r r r r �deletea s zcmdstate.deletec C s | j j�| j�S )z*check whether the state file exists or not)r r �existsr r r r r r+ e s zcmdstate.existsN) �__name__� __module__�__qualname__�__doc__r r r"