e,.W :ddlmZddlZddlZddlmZddlmZmZm Z ddl m Z m Z m Z mZmZmZmZddlmZddlmZmZmZmZmZddlmZerddlmZdd lm Z dd l!m"Z"m#Z#d d gZ$Gd d ee%e%e ee&e&fe%fZ'Gdd ee'eZ(dS))mmapN)defenc) parse_date Serializablealtz_to_utctz_str)ActorLockedFDLockFileassure_directory_existsto_native_path bin_to_hexfile_contents_ro_filepath)IteratorListTupleUnion TYPE_CHECKING)PathLike)SymbolicReference)BytesIO)GitConfigParserSectionConstraintRefLog RefLogEntryc>eZdZdZejdZdZdefdZ defdZ e defdZ e defdZ e defd Ze deeeffd Ze defd Zed ed edededededdfdZededdfdZdS)rz:Named tuple allowing easy access to the revlog data fieldsz^[0-9A-Fa-f]{40}$returnc*|S)z0Representation of ourselves in git reflog format)formatselfs /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/git/refs/log.py__repr__zRefLogEntry.__repr__/s{{}}c |j}|j}d|j|j|j|j|dt|d|jS)z8:return: a string suitable to be placed in a reflog filez{} {} {} <{}> {!s} {} {} r) actortimer oldhexsha newhexshanameemailrmessage)r!actr(s r"rzRefLogEntry.format3sWjy,33 N N H I G d1g & & L   r$c|dS)z=The hexsha to the commit the ref pointed to before the changerrr s r"r)zRefLogEntry.oldhexshaA Awr$c|dS)z@The hexsha to the commit the ref now points to, after the changer&rr s r"r*zRefLogEntry.newhexshaFr0r$c|dS)z Actor instance, providing accessrr s r"r'zRefLogEntry.actorKr0r$c|dS)zetime as tuple: * [0] = int(time) * [1] = int(timezone_offset) in time.altzone formatrr s r"r(zRefLogEntry.timePs Awr$c|dS)zRzMissing token: >) decodersplitlenr;repr_re_hexsha_onlymatchfindr _from_stringrr) r<r>line_strfieldsinfomsgr)r*hexsha email_endr'r(r8s r" from_linezRefLogEntry.from_linemsr ;;v&&a(( v;;!  q 4#DD [[A  ID##WZ^_gZhZhhii i"I BK  ), C CF&,,V44 C j!ABBB C IIc2&& ??/00 0"4Y](:#;<<$T)a-//%:;;iIy%$ 9JCPQQQr$N)__name__ __module__ __qualname____doc__recompilerK __slots__strr#rpropertyr)r*rr'rintr(r- classmethodr=bytesrUrr$r"rr(sDD bj!455OI#       3X3XuXeCHoXX V V V V  V  V V  V V V[ VRUR}RRR[RRRr$c~eZdZdZdZd deedfddffd Zd deedffdZd!dZ e deddfd Z e d d de fd Z e d ee defdeefdZe dededdfdZdeddfdZe d"deedddfdededede deddfdZd#dZd$dZd$dZxZS)%ra\A reflog contains RefLogEntrys, each of which defines a certain state of the head in question. Custom query methods allow to retrieve log entries by date or by other criteria. Reflog entries are ordered, the first added entry is first in the list, the last entry, i.e. the last change of the head or reference, is last in the list.)_pathNfilepathrcXtt||}|SN)superr__new__)r<rdinst __class__s r"rhzRefLog.__new__s%VS!!))#.. r$cD||_||dSdS)zInitialize this instance with an optional filepath, from which we will initialize our data. The path is also used to write changes back using the write() methodN)rc_read_from_file)r!rds r"__init__zRefLog.__init__s1    " " " " " r$c t|jdd}n#t$rYdSwxYw |||dS#|wxYw)NT)stream allow_mmap)rrcOSError _deserializeclose)r!fmaps r"rlzRefLog._read_from_files~ ,TZQUVVVDD    FF      d # # # JJLLLLLDJJLLLLs ((AA-c||S)z :return: a new RefLog instance containing all entries from the reflog at the given filepath :param filepath: path to reflog :raise ValueError: If the file could not be read or was corrupted in some wayr)r<rds r" from_filezRefLog.from_filess8}}r$refrcftj|jjdt |jS)z :return: string to absolute path at which the reflog of the given ref instance would be found. The path is not guaranteed to point to a valid file though. :param ref: SymbolicReference instancelogs)ospjoinrepogit_dirr path)r<rws r"r~z RefLog.paths'x(&.2J2JKKKr$rorc# Ktj}t|tr't |}t|t sJn|} |}|sdS||V8)a :return: Iterator yielding RefLogEntry instances, one for each line read sfrom the given stream. :param stream: file-like object containing the revlog in its native format or string instance pointing to a file to readTN)rrUr:r]rrreadlinestrip)r<ro new_entry_streamr>s r" iter_entrieszRefLog.iter_entriess ) fc " " /77Ggt,, , ,, ,G *##%%D )DJJLL)) ) ) )  *r$indexrct|d5}|dkrPt||cdddSt |dzD].}|}|std|dzd/t|cdddS#1swxYwYdS)a :return: RefLogEntry at the given index :param filepath: full path to the index file from which to read the entry :param index: python list compatible index, i.e. it may be negative to specify an entry counted from the end of the list :raise IndexError: If the entry didn't exist .. note:: This method is faster as it only parses the entry at index, skipping all other lines. Nonetheless, the whole file has to be read if the index is negative rbrNr&zIndex file ended at line z , before given index was reached)openrrU readlinesrranger IndexError)r<rdrfpir>s r"entry_atzRefLog.entry_atsD (D ! ! 7Rqyy",,R\\^^E-B-H-H-J-JKK 7 7 7 7 7 7 7 7 519%% h h{{}}h$%f1%f%f%fgggh ((66 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7sA C!(A,C!!C%(C%ct|}t|d|dd} |||dS#t $r|wxYw)zWrite the contents of the reflog instance to a file at the given filepath. :param filepath: path to file, parent directories are assumed to existTis_file)writeroN)r r r _serializecommit Exceptionrollback)r!rdlfdrs r"to_filezRefLog.to_filesx  $7777 XXDX . .  OOB    JJLLLLL    LLNNN  s )A$$ BT config_readerrr oldbinsha newbinshar-rc t|dkst|dkrtdt|d|dd}t |t r|}nt j|}tt| dt| d|ttj tj f|f} |rt|} | t!|d} | | t(| | n-#| | wxYw| S) aAppend a new log entry to the revlog at filepath. :param config_reader: configuration reader of the repository - used to obtain user information. May also be an Actor instance identifying the committer directly or None. :param filepath: full path to the log file :param oldbinsha: binary sha of the previous commit :param newbinsha: binary sha of the current commit :param message: message describing the change to the reference :param write: If True, the changes will be written right away. Otherwise the change will not be written :return: RefLogEntry objects which was appended to the log :note: As we are append-only, concurrent access is not a problem as we do not interfere with readers.z&Shas need to be given in binary formatTr rasciiab)rIr;r rHr:r committerrr rGr__timer(altzoner _obtain_lock_or_raiserrrencoderrs _release_lock) r<rrdrrr-r first_linerentrylffds r" append_entryzRefLog.append_entrys4 y>>R  3y>>R#7#7EFF F$7777]]4((+ mU + + 7%II 66I9%%,,W559%%,,W55UZ\\""EM2      #(##B  $ $ & & &h%%B #..v66777   """"   """" s ?F***Gcf|jtd||j|S)zUWrite this instance's data to the file we are originating from :return: selfNzBInstance was not initialized with a path, use to_file(...) instead)rcr;rr s r"rz RefLog.writeHs4 : abb b TZ    r$c|j}|D]7}||t8|Srf)rrrr)r!rores r"rzRefLog._serializeUsH  - -A E!((**##F++ , , , , r$cV||||Srf)extendr)r!ros r"rrzRefLog._deserialize^s' D%%f--... r$rf)rN)T)rr)rorrr)rVrWrXrYr\rrrhrmrlr`rvr]r~rrrrr_rrrraboolrrrrr __classcell__)rjs@r"rrs]RRIuXt^4##x~!6####     h[L*LsLLL[L*%Y(<"=*(;BW***[**777777[7<T"66U$57JDPQ66 6  6  66 666[6pr$))rrZr(r git.compatrgit.objects.utilrrrgit.utilrr r r r r ros.pathr~rztypingrrrrr git.typesrgit.refsrior git.configrr__all__r]r_rrrr$r"rs   ?>>>>>>>>>>>>>>******======== ] #dRdRdRdRdR%S%sCx#=>dRdRdRNRRRRRT+  RRRRRr$