HEX
Server: Apache
System: Linux p102.lithium.hosting 4.18.0-553.141.1.el8_10.x86_64 #1 SMP Fri Jul 10 17:48:02 UTC 2026 x86_64
User: bvzmoamr (9955)
PHP: 8.1.34
Disabled: syslog
Upload Files
File: //proc/self/root/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyc
�
1�3\c@@s�ddlmZddlZddlZddlZddlZddlmZddlm	Z	m
ZmZ
mZmZmZmZmZddlmZddlm	ZmZejd��Zed	�Zd
�Zd�Zejej�Z e!e"d�Z#d
�Z$d�Z%e%ej&�Z'de(fd��YZ)e)�Z&de(fd��YZ*d�Z+de(fd��YZ,ej-e&e!d��Z.ee"e!d�Z/dS(i(tabsolute_importN(t_(terrortlinelogtlocktmdifftnodetpycompattscmutiltutil(t
stringutili(RtrevmapcC@s
|j|�S(N(tfile(trepotpath((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyt_getflog$scC@s�|j|j�}|sMg|D]$}|j�|j�kr |^q }nx;|D]3}d|jkrTt|j|j��|_qTqTW|S(Nt_filelog(t	_changeidtparentsRt__dict__Rt_repoR(tftfollowtpltp((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyt_parents)s4
"cC@sj|j�}|jd�}|r>|jd�r>|d7}ngtj|�D]}||f^qN|fS(Ns
i(tdatatcounttendswithRtxrange(tfctxttextt	linecountti((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyt	_decorate?s

cC@sRxK|D]C\\}}}}}|dkr|d||!|d||+qqW|S(Nt=i((tparenttchildtblocksta1ta2tb1tb2tt((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyt_pairIs#cC@s�|r4t|t�r4|dk	r4t||�}n
||}|dkr�|j�dkri||}q�|j|d|j��}n\||}|dkr�|j�}n|j�}||j�kr�||_|||_	n|S(s2(repo, str, str) -> fctx

    get the filectx object from repo, rev, path, in an efficient way.

    if resolverev is True, "rev" is a revision specified by the revset
    language, otherwise "rev" is a nodeid, or a revision number that can
    be consumed by repo.__getitem__.

    if adjustctx is not None, the returned fctx will point to a changeset
    that introduces the change (last modified the file). if adjustctx
    is 'linkrev', trust the linkrev and do not adjust it. this is noticeably
    faster for big repos but is incorrect for some cases.
    tchangeidtlinkrevN(
t
isinstancetinttNonet
_revsingletrevtfilectxR.tintrorevRt
_changectx(R
R3Rt
resolverevt	adjustctxtctxRR5((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pytresolvefctxUs"


	cC@s4|jdd�jdd�jdd�jdd�S(	Ns.hg/s.hg.hg/s.l/s.l.hg/s.m/s.m.hg/s.lock/s	.lock.hg/(treplace(R((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyt	encodedir�s
c@sBtjt�fd�tjjD���}tj|�j�d S(Nc3@s$|]}|t�|�fVqdS(N(tgetattr(t.0tk(tdiffopts(s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pys	<genexpr>�si(	R
tpprinttsortedRR@tdefaultsthashlibtsha1t	hexdigest(R@t
diffoptstr((R@s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pythashdiffopts�s	tannotateoptscB@sDeZdZidd6ed6ed6Zd�Zejd��Z	RS(s�like mercurial.mdiff.diffopts, but is for annotate

    followrename: follow renames, like "hg annotate -f"
    followmerge: follow p2 of a merge changeset, otherwise p2 is ignored
    R@tfollowrenametfollowmergecK@s@x9|jj�D](\}}t|||j||��qWdS(N(RCt	iteritemstsetattrtget(tselftoptsR?tv((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyt__init__�scC@s�d}|js|d7}n|js2|d7}n|jdk	r�t|jtj�s\t�t|j�}|tkr�|d|7}q�n|p�dS(s?represent opts in a short string, suitable for a directory namettr0tm0R!tdefaultN(	RJRKR@R1R/RtAssertionErrorRHt_defaultdiffopthash(ROtresulttdiffopthash((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pytshortstr�s	
	
N(
t__name__t
__module__t__doc__R1tTrueRCRRR	t
propertycacheR[(((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyRI�s
	t_annotatecontextcB@seZdZd�Zed��Zed��Zd�ZeZd�Z	ed��Z
ed�Zdeed�Zd	�Zeed
�Zd�Zd�Zd
�Zdd�Zd�Zedd��Zdd�Zd�Zejd��Zejd��Zdd�ZRS(s{do not use this class directly as it does not use lock to protect
    writes. use "with annotatecontext(...)" instead.
    cC@sX||_|j|_||_||_||_||_d|_d|_i|_	dS(N(
R
tuiRRPtlinelogpatht
revmappathR1t_linelogt_revmapt
_node2path(ROR
RRcRdRP((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyRR�s							c	C@s�|jdkr�tjj|j�r�t|jd��L}ytjj	|j
��|_Wn#tjk
r}tj�|_nXWdQXq�tj�|_n|jS(Ntrb(ReR1tosRtexistsRctopent
linelogmodRtfromdatatreadtLineLogError(ROR((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyR�scC@s.|jdkr'tj|j�|_n|jS(N(RfR1t	revmapmodRRd(RO((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyR�scC@sx|jdk	r(|jj�d|_n|jdk	rtt|jd��}|j|jj��WdQXd|_ndS(Ntwb(RfR1tflushReRkRctwritetencode(ROR((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pytclose�s
cC@s1|j�|jj�t|j|jg�dS(s0delete linelog and revmap, useful for rebuildingN(RuRgtcleart_unlinkpathsRdRc(RO((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pytrebuild�s

cC@s9|jdkrtj|j�S|jj|jj�SdS(s6return last node in revmap, or None if revmap is emptyN(RfR1RptgetlastnodeRdtrev2hshtmaxrev(RO((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pytlastnode�scC@s�|j}ym|j|dt�}|jjj|j��}|rk|rk||krk|jj|�dk	S||kSWnt
k
r�tSXdS(sreturn True if the revmap / linelog is up-to-date, or the file
        does not exist in the master revision. False otherwise.

        it tries to be fast and could return false negatives, because of the
        use of linkrev instead of introrev.

        useful for both server and client to decide whether to update
        fastannotate cache or not.

        if strict is True, even if fctx exists in the revmap, but is not the
        last node, isuptodate will return False. it's good for performance - no
        expensive check was done.

        if strict is False, if fctx exists in the revmap, this function may
        return True. this is useful for the client to skip downloading the
        cache if the client's master is behind the server's.
        R7N(R|t_resolvefctxR_R
t	changelogRR.Rthsh2revR1tLookupError(ROtmastertstrictR|Rtlinknode((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyt
isuptodate�s	
cC@s"t|t�r0tj|jjj|��}n|j|�\}}|r�|jjr�|jj	d|j
tjt
j|d��f�n|j|||�Sd}|r�y|j|dtdt�}Wntk
r�q�X||jkr�d}q�n|g}|rN|j�dkr>tjtd�dtd���n|j|�n|}	i}
id|6}i}x�|	rc|	j�}
|
|
ksq|
|kr�qqn|
|jkr|jj|
j��}|jj|�|jj}||
j�f||
<qqn|j |
�}||
|
<xD|D]<}|j!|d	�d||<||
kr |	j|�q q WqqWt"�}|}
xJ|
r�|
|jkr�|j#|
�|
|
}|r�|d	}
qvd}
PqvW|dk	r�|j$|
�n|jjr7|r|jj	d
|j
t%|�f�q7|s7|jj	d|j
�q7n|jj|jj&�|}	d	}xE|	r�|	d}
|
|kr�|	j�q]nt}|
|
}x0|D](}||kr�t'}|	j|�q�q�W|s�q]n|	j�d}|
|k}|
|kst(�t)|
�}x�t*|�D]�\}}t+|j,||d|d��}|d	krj|rj|}nt-||||�}||dkr�||=||=q||cd8<qW|||
<|
|
=|r||jj.s
|d7}|jj/td
�|dt%|��nd}t%|�dkr;|j0j1r;|d	}n|dkrft+|j,d|d��}n|j2|
||�q]|r]|
j
�|j3|
j�<q]q]W|r�|jj4�ng||d	D]?\}}t|t�r�|jj5|�n	|j�|f^q�}|j6||||�S(s�incrementally update the cache so it includes revisions in the main
        branch till 'master'. and run annotate on 'rev', which may or may not be
        included in the main branch.

        if master is None, do not update linelog.

        the first value returned is the annotate result, it is [(node, linenum)]
        by default. [(node, linenum, path)] if showpath is True.

        if showlines is True, a second value will be returned, it is a list of
        corresponding line contents.
        s6fastannotate: %s: using fast path (resolved fctx: %s)
RR7R8scannot update linelog to wdir()thintsset fastannotate.mainbranchiis7fastannotate: %s: %d new changesets in the main branch
sBfastannotate: %s: linelog cannot help in annotating this revision
i����sbuilding cachettotaliRSN(7R/R0RthexR
R~tcanannotatedirectlyRbt	debugflagtdebugRR
RAR	tsafehasattrtannotatedirectlyR1R}R_R�RR3RtAbortRtappendtpopRRtannotatetannotateresultRt_parentfuncRNtsettaddt_checklastmasterheadtlenR{tFalseRWR"t	enumeratetlistt_diffblocksR,tquiettprogressRPRKt
_appendrevRgRsRzt_refineannotateresult(ROR3R�tshowpatht	showlinestdirectlytrevfctxt
masterfctxt	initvisittvisittpcachetneededthistRtllrevRYRRt
newmainbranchR�treadyR&tismainbranchtcurrR!tbst
bannotatedtfrtl((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyR�s�!

	
	

	


	




$	



 QcC@st}d}t|t�r�|dk	r�itd6tjd6jt|�d��|�}|dk	r�||j	f|j
kr�|}q�n|dkr|jr�dnt}|j|d|dt�}||j
k}|r|jr|j|dtdt�}qn||fS(s�(str) -> bool, fctx or node.
        return (True, f) if we can annotate without updating the linelog, pass
        f to annotatedirectly.
        return (False, f) if we need extra calculation. f is the fctx resolved
        from rev.
        ii(cS@sdS(N(R1(tx((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyt<lambda>�RSR.R8R7N(
R_R1R/R0tbytesRtbinRNR�RRt	_perfhackR}(ROR3RYRthshR8((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyR��s2$!cC@s�|j|dtdt�}||jkrC|g}d}xetr�|d}|j|�}|sePn|d|jkr�|dj�}Pn|j|d�q<Wtj�}	|	j|j�|	j	|	j
�tj�}
|
j|j�xit|�D]F}|j�}t
|j||��}|j|	|
||�|}q�Wn|j}	|j}
|	j�}
|j�}|
j|�}g|
D]-\}}||kr�|
j|�|f^q�}|r�|j||
�}n|r�|j||
|	�}||f}n|S(s
(rev : str) -> [(node : str, linenum : int, path : str)]

        the result has the same format with annotate, but include all (including
        deleted) lines up to rev. call this after calling annotate(rev, ...) for
        better performance and accuracy.
        R7R8RSi����i(R}R_RR�RR�RlRtcopyfromR�R{RptreversedR�R�t_doappendrevtgetalllinesRRRzt_addpathtoresultt
_resolvelines(ROR3R�R�R�tchaintaRRRRtbR&tlinesR�R�trR�RYtlinecontents((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pytannotatealllines�sF		

		:cC@s�g|D]}|j|d�^q}dgt|�}tjt�}x@tjt|��D])}|||||dfj|�q^Wxl|r�d}	yVxO|j	�D]A\\}
}}|j
|
�tj@r�q�n||dd}	Pq�WWnt
k
r|SX|	dkr
i}
x�|j	�D]�\\}
}}|
|
kr�||dd}	|jjr�|jjdtj|	�||f�n|j|	|j|
��}tj|j��}||
|
<nx |D]}|
|
|||<q�Wq$Wtd�|D��s	t�|S|jjdtj|	��|j|
�|j|	|j|
��}|j}tj|j��}t|�t|�kr�tjd��nxYt|�D]K\}}||}||kr�x||D]}|||<q�W||=q�q�Wq�W|S(sh(annotateresult) -> [line]. designed for annotatealllines.
        this is probably the most inefficient code in the whole fastannotate
        directory. but we have made a decision that the linelog does not
        store line contents. so getting them requires random accesses to
        the revlog data, since they can be many, it can be very slow.
        iis6fastannotate: reading %s line #%d to resolve lines %r
cs@s|]}|dk	VqdS(N(R1(R>R�((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pys	<genexpr>Dss+fastannotate: annotate %s to resolve lines
sunexpected annotated linesN(RR1R�tcollectionstdefaultdictR�RRR�RLtrev2flagRptsidebranchflagt
StopIterationRbR�R�RtshortR}trev2pathRt
splitnewlinesRtallRWR�R�tfaerrortCorruptedFileErrorR�(ROR�RRR�trevsRYtkey2idxsR!R�R3t_linenumtidxstrevlinestlinenumRR�tidxt	annotatedtlineR?((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyR�sZ&'		



	
c	C@s�t|t�r|}n|j�}|jj|�}|s[tjdtj|���n|jj|�t	j
@dkr�tjdtj|���n|jj|�g|jj
D]$\}}|jj|�|f^q�}|j||||�S(slike annotate, but when we know that f is in linelog.
        f can be either a 20-char str (node) or a fctx. this is for perf - in
        the best case, the user provides a node and we don't need to read the
        filelog or construct any filecontext.
        s%s is not in revmapis%s is not in revmap mainbranch(R/tstrRRRR�R�R�R�RpR�RR�R�RzR�(	RORR�R�R�R�R�R�RY((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyR�Ys			4cC@s�|r|j|�}n|r�t|t�r`|jj|�}|j||jj|��}n|}tj|j	��}t
|�t
|�kr�tj��n||f}n|S(snadd the missing path or line contents, they can be expensive.
        f could be either node or fctx.
        (
R�R/R�RRR}R�RR�RR�R�R�(RORYRR�R�R�RR�((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyR�os!cC@s#|j|j|j|||�dS(N(R�RR(RORR&R�((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyR��scC@stj|||jj�S(N(Rt	allblocksRPR@(ROR�R�((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyR��sc@s��fd�}g}i}|dk	r�xk|D]`\\}}	}
}}|dkr.|g||
|!D]!\}
}t|
t�sc|
^qc7}q.q.Wnt|�}||kr�|j|�nx|D]}
||
�||
<q�W�j|j�d|j��}|||<x�t|�D]�\\}}	}
}}|dkr@qn|dkrh|j	|||	|
|�qg||
|!D]1\}}t|t�r�|n|||f^qv}|j
|||	|�qWdS(s'append a revision to linelog and revmapc@spt|t�r!tjd��n|j�}�j|�}|dkrl�j|dtd|j	��}n|S(s
(fctx) -> intsf should not be an intt
sidebranchRN(
R/R0RtProgrammingErrorRRR1R�R_R(RR�R3(R(s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pytgetllrev�s$R#RN(R1R/R0R�tremoveR�RRR�treplacelinestreplacelines_vec(RRRR&R�R�tsiderevst
siderevmapR'R(R)R*topRR�R�R�tblines((Rs@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyR��s.
&
!
%Bc@sV�dkr�j�n��fd�}g|D]!\}}||||�f^q1S(s6(revmap, [(node, linenum)]) -> [(node, linenum, path)]c@sJ�jj|�}|dkrF�j�j|��}|�j|<n|S(N(RgRNR1R�R(tnodeidR(RRO(s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyt_getpath�s
N(R1R(ROR�RR�tnR�((RROs@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyR��scC@sg|dkrd}n-|jj|j��}|sBtj��n|jj|krctj��ndS(s:check if fctx is the master's head last time, raise if notiN(R1RRRR�tCannotReuseErrorRR{(RORR�((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyR��s	c@s.|jj�|jj���fd�}|S(s-> (fctx) -> [fctx]c@s)t|d��}�s%|d }n|S(NRi(R(RR(RKRJ(s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyR�s
(RPRJRK(ROR((RKRJs@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyR��scC@s|jjdd�S(Ntfastannotatetperfhack(Rbt
configbool(RO((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyR��scK@st|j||p|j|�S(N(R:R
R(ROR3Rtkwds((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyR}�sN( R\R]R^RRtpropertyRRRut__del__RxR|R_R�R1R�R�R�R�R�R�R�R�R�tstaticmethodR�R�R�R	R`R�R�R}(((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyRa�s0	
				#�	8	>			,	cC@s:x3|D]+}ytj|�Wqtk
r1qXqWdS(ssilent, best-effort unlinkN(R	tunlinktOSError(tpathsR((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyRw�s


t
pathhelpercB@sbeZdZed�Zed��Zed��Zd�Ze	j
d��Zed��ZRS(s9helper for getting paths for lockfile, linelog and revmapcC@s1tjjd|jt|��|_||_dS(NR�(RiRtjoinR[R<t_vfspathR(ROR
RRP((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyRR�scC@s"tjj|jjj|j��S(N(RiRtdirnameRtvfsR�R�(RO((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyR��scC@s|jjj|jd�S(Ns.l(RR�R�R�(RO((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyRc�scC@stj|jj|jd�S(Ns.lock(tlockmodRRR�R�(RO((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyR�scc@s�ddl}|j}tjtjj|��tj|tjtj	Bd�}|j
||j�z	dVWd|j
||j�tj
|�XdS(sgthe same as 'lock' but use flock instead of lockmod.lock, to avoid
        creating temporary symlinks.iNi�(tfcntlRcR	tmakedirsRiRR�RktO_RDONLYtO_CREATtflocktLOCK_EXtLOCK_UNRu(ROR�tlockpathtlockfd((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyt
_lockflock�s		cC@s|jjj|jd�S(Ns.m(RR�R�R�(RO((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyRds(
R\R]R^tdefaultoptsRRR�R�RcRt
contextlibtcontextmanagerRRd(((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyR��s	c
c@s�t|||�}tj|j�|j}|j}d}z�yG|j��5t|||||�}|rx|j	�n|VWdQXWnAt
k
r�|dk	r�|j	�n|jjd|��nXWd|dk	r�|j
�nXdS(scontext needed to perform (fast) annotate on a file

    an annotatecontext of a single file consists of two structures: the
    linelog and the revmap. this function takes care of locking. only 1
    process is allowed to write that file's linelog and revmap at a time.

    when something goes wrong, this function will assume the linelog and the
    revmap are in a bad state, and remove them from disk.

    use this function in the following way:

        with annotatecontext(...) as actx:
            actx. ....
    Ns+fastannotate: %s: cache broken and deleted
(R�R	R�R�RdRcR1RRaRxt	ExceptionRbR�Ru(R
RRPRxthelperRdRctactx((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pytannotatecontexts&		



cC@s[|j}|j}|jjddt�r3t}ntd|d|�}t||||�S(sdlike annotatecontext but get the context from a fctx. convenient when
    used in fctx.annotate
    R�tforcefollowR@RJ(Rt_pathRbR�R_RIR	(RRR@RxR
Rtaopts((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pytfctxannotatecontext3s			(0t
__future__RR�RRDRitmercurial.i18nRt	mercurialRRRlRR�RRRRR	tmercurial.utilsR
RSR�RRptlrucachefuncRR_RR"R,t	revsingleR2R�R1R:R<RHRRXtobjectRIRaRwR�RR	R
(((s@/usr/lib64/python2.7/site-packages/hgext/fastannotate/context.pyt<module>s6:
	
	
,		 	��/	'#