o ]Lb9@sddlmZddlZddlZddlZddlZddlmZmZm Z m Z m Z ddlm Z ddd Z ejd Zer/usr/lib/python3/dist-packages/mercurial/revlogutils/docket.pymake_uid&srsHGTEST_UUIDFILEc Cs\zttdd}|}Wdn1swYWnty9}z|jtjkr-d}WYd}~nd}~wwtjrBt |}ndd|D}d}t dd}|D]}|d ?}||@d >} || |}qRt } tjrt| j |d d n| || |d } |dksJtd| } t| } ttd}|| Wd| S1swY| S)Nrb)modes04css|]}t|VqdSN)ord).0crrr @szmake_uid..r#11111111111111111111111111111111111r#r )versionr z>Lwb)openstable_docket_filereadstripIOErrorerrnoENOENTrispy3iterintrandomRandomseed getrandbitsstructpackrr write)rfr,inst iter_seedint_seedlow_maski high_partlow_partrrawpnewrrrr4sD           s BBBBBBLLLLLLcz>BLc@seZdZdZ               d(ddZdd Zd d Zd)d dZddZddZ d)ddZ ddZ ddZ d)ddZ eddZejddZeddZejd dZed!d"Zejd#d"Zd*d$d%Zd+d&d'ZdS), RevlogDocketzmetadata associated with revlogFNrrcCs||_t||_d|_|j|_|j|_|j|_ ||_ ||_ ||_ ||_ ||_| |_t|t|@r3Jt|t| @r=Jt|t| @rGJ| | ksMJ| | ksSJ||ksYJ| |_| |_| |_| |_||_||_|rz|j|_|j|_|j|_n |j|_|j|_|j|_||_dS)NF)_version_headerbool _read_only_dirtyradix_radix _docket_file_pathopener_opener _index_uuid_older_index_uuids _data_uuid_older_data_uuids_sidedata_uuid_older_sidedata_uuidsset_initial_index_end_pending_index_end_initial_data_end_pending_data_end_initial_sidedata_end_pending_sidedata_end _index_end _data_end _sidedata_enddefault_compression_header)selfrevlog use_pendingversion_header index_uuidolder_index_uuids data_uuidolder_data_uuids sidedata_uuidolder_sidedata_uuids index_endpending_index_enddata_endpending_data_end sidedata_endpending_sidedata_endrXrrr__init__ss@      zRevlogDocket.__init__cC"|jdur t|_d|j|jfS)z=file path to the current index file associated to this docketN %s-%s.idx)rHrrCrYrrrindex_filepath zRevlogDocket.index_filepathcC*|j|jf}|jd|t|_|S)z\switch index file to a new UID The previous index UID is moved to the "older" list.r)rHrUrIinsertrrmrYoldrrrnew_index_file zRevlogDocket.new_index_fileTcc2|jD]\}}|s|dkrd|j|fVqdS)z>yield file path to older index files associated to this docketrrkN)rIrCrY include_emptyuuidsizerrrold_index_filepaths  z RevlogDocket.old_index_filepathscCrj)zlenrHrIrJrKrLrMrXappendS_HEADERr/ S_OLD_UIDjoin) rYrofficial_index_endofficial_data_endofficial_sidedata_enddatasuryrrrr!sT       zRevlogDocket._serialize)FNNrNrNrrrrrrrN)T)FFF)__name__ __module__ __qualname____doc__rirmrsrzr}r~rrrrpropertyrcsetterrergr0rrrrrr=psR 6          r=cCsD|d@}|tjtjfvrdStj|j}t|||d}d|_|S)z?given a revlog version a new docket object for the given revlogiN)r\rXT) r REVLOGV2 CHANGELOGV2r compengines _compengine revlogheaderr=rA)rZr\ rl_versioncompdocketrrrdefault_docketUsrc CsZg}g}td|D]}|tj}|t|q |D]\}}||}|||fq|S)Nr)rangerryrunpack) get_datacount all_sizesall_uidsr6r:uid_size file_sizeuidrrr_parse_old_uidsds  rFcstdtj}tjgfdd}t|}t|}t|}||}t|} t|| } t|} || } t|} t|| }t|}||}t|}t||}t|}t|}t|}t|}t|}t|}t|}t|f|||| | ||||||||||d}|S)zBgiven some docket data return a docket object for the given revlogNcsfd|tkrd}|d|tf;}t|dd|}d|7<|S)z/utility closure to access the `size` next bytesrs'docket is too short, expected %d got %d)rrAbort)ryrr:roffsetrrrxs zparse_docket..get_data)r[r\r]r^r_r`rarbrcrdrerfrgrhrX)rrryr(nextrr=)rZrr[headerriheaderr\index_uuid_sizer]older_index_uuid_countr^data_uuid_sizer_older_data_uuid_countr`sidedata_uuid_sizeraolder_sidedata_uuid_countrb index_sizepending_index_size data_sizepending_data_size sidedata_sizepending_sidedata_sizerXrrrr parse_docketqsX    r)r r) __future__rr%r r*r.rrrrrr renvirongetr!StructINDEX_HEADER_FMTrrobjectr=rrrrrrrs$     6 f