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/thread-self/root/lib64/python2.7/site-packages/mercurial/chgserver.pyc
�
1�3\c@@s�dZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZmZmZmZmZmZmZddlmZejZd�Zd	d
ddgZd(gZejdej�Zd�Zd�Z d�Z!de"fd��YZ#d�Z$d�Z%de"fd��YZ&d)d*d+gZ'd!ej(fd"��YZ)d#�Z*d$�Z+d%e"fd&��YZ,d'�Z-dS(,sRcommand server extension for cHg

'S' channel (read/write)
    propagate ui.system() request to client

'attachio' command
    attach client's stdio passed by sendmsg()

'chdir' command
    change current directory

'setenv' command
    replace os.environ completely

'setumask' command (DEPRECATED)
'setumask2' command
    set umask

'validate' command
    reload the config and check if the server is up to date

Config
------

::

  [chgserver]
  # how long (in seconds) should an idle chg server exit
  idletimeout = 3600

  # whether to skip config or env change checks
  skiphash = False
i(tabsolute_importNi(t_(t
commandservertencodingterrort
extensionstnodetpycompattutil(tprocutilcC@s"tjtjt|��j��S(s return sha1 hexdigest for a list(Rthexthashlibtsha1tstrtdigest(titems((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyt	_hashlistGstaliasteoltextdiffRtcommandssshow.aliasprefixs~\A(?:
                    CHGHG
                    |HG(?:DEMANDIMPORT|EMITWARNINGS|MODULEPOLICY|PROF|RCPATH)?
                    |HG(?:ENCODING|PLAIN).*
                    |LANG(?:UAGE)?
                    |LC_.*
                    |LD_.*
                    |PATH
                    |PYTHON.*
                    |TERM(?:INFO)?
                    |TZ
                    )\Zc
C@s�g}x$tD]}|j|j|��q
Wx-tD]%\}}|j|j||��q4Wt|�}dtjkr�dh}n	t�}gtjj	�D]3\}}t
j|�r�||kr�||f^q�}tt|��}	|d |	d S(s�return a quick hash for detecting config/env changes

    confighash is the hash of sensitive config items and environment variables.

    for chgserver, it is designed that once confighash changes, the server is
    not qualified to serve its client and should redirect the client to a new
    server. different from mtimehash, confighash change will not mark the
    server outdated and exit since the user can have different configs at the
    same time.
    tCHGHGtHGi(
t_configsectionstappendtconfigitemst_configsectionitemstconfigRRtenvirontsett	iteritemst_envretmatchtsorted(
tuitsectionitemstsectiontitemtsectionhashtignoredtktvtenvitemstenvhash((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyt_confighashes
	-cC@s�gtj|�D]\}}|^q}y!ddlm}|j|�Wntk
r\nXtjg}x<|D]4}y|jtj|��Wqpt	k
r�qpXqpWt
t|��S(s�get a list of paths that should be checked to detect change

    The list will include:
    - extensions (will not cover all files for complex extensions)
    - mercurial/__version__.py
    - python binary
    i(t__version__(RtR-RtImportErrorRt
sysexecutabletinspectt
getabsfilet	TypeErrorR!R(R"tntmtmodulesR-tfiles((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyt_getmtimepaths�s(


cC@s d�}tt||��d S(sWreturn a quick hash for detecting file changes

    mtimehash calls stat on given paths and calculate a hash based on size and
    mtime of each file. mtimehash does not read file content because reading is
    expensive. therefore it's not 100% reliable for detecting content changes.
    it's possible to return different hashes for same file contents.
    it's also possible to return a same hash for different file contents for
    some carefully crafted situation.

    for chgserver, it is designed that once mtimehash changes, the server is
    considered outdated immediately and should no longer provide service.

    mtimehash is not included in confighash because we only know the paths of
    extensions after importing them (there is imp.find_module but that faces
    race conditions). We need to calculate confighash without importing.
    cS@s?y'tj|�}|tj|jfSWntk
r:nXdS(N(toststattST_MTIMEtst_sizetOSError(tpathtst((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyttrystat�s

i(Rtmap(tpathsR@((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyt
_mtimehash�s	t	hashstatecB@s)eZdZd�Zedd��ZRS(sCa structure storing confighash, mtimehash, paths used for mtimehashcC@s||_||_||_dS(N(t
confighasht	mtimehasht
mtimepaths(tselfRERFRG((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyt__init__�s		cC@sW|dkrt|�}nt|�}t|�}td||f�t|||�S(Nsconfighash = %s mtimehash = %s
(tNoneR8R,RCt_logRD(R"RGRERF((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pytfromui�sN(t__name__t
__module__t__doc__RItstaticmethodRJRL(((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyRD�s	c@s/d|jf���fd��Y��|�S(Ntchguic@s8eZd��fd�Zd�Zd�fd�ZRS(c@sAt�|�j|�|r4t|d��|_n	�|_dS(Nt_csystem(tsuperRItgetattrRR(RHtsrc(RQtcsystem(s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyRI�scS@s�||jk	sLtj|jd�sL|jj�tjj�ksL|jrktj|d|d|d|�S|j�|j	|tj
|�|�S(NtfilenoRtcwdtout(tfoutRtsafehasattrRWR	tstdoutt_finoutredirectedtsystemtflushRRtshellenviron(RHtcmdRRXRY((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyt
_runsystem�s	
c	@s0|j|tj|�dddi�d6�tS(Nttypetpagertcmdtabletattachio(RRR	R`tTrue(RHRatenv(Rf(s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyt	_runpager�sN(RMRNRJRIRbRi((RfRQRV(s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyRQ�s	(t	__class__(tsrcuiRVRf((RfRQRVs9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyt	_newchgui�s%cC@skddlm}|jj�}x3ddddgD]}t||t||��q2Wtj|d�rv|j|_n|j	||�}|j
||d�xr|j�D]d\}}}|j||�}	d	|	ks�|	d
ks�|	j
d�r�q�n|j||||	�q�W|d}
|
r3tjj|
�p6d}
|d
}|j||d|
�\}}
||
fS(Ni(tdispatchtfinRZtferrRRRRt:s--configt$RXt
repositorytwd(R.RmRjtloadtsetattrRTRR[RRt_earlyparseoptst_parseconfigt
walkconfigtconfigsourcet
startswitht	setconfigR9R>trealpathRJt	_getlocal(RktargsRmtnewuitatoptionsR$tnametvaluetsourceRXtrpathR>tnewlui((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyt
_loadnewui�s$'

tchanneledsystemcB@s)eZdZd�Zdddd�ZRS(s�Propagate ui.system() request in the following format:

    payload length (unsigned int),
    type, '',
    cmd, '',
    cwd, '',
    envkey, '=', val, '',
    ...
    envkey, '=', val

    if type == 'system', waits for:

    exitcode length (unsigned int),
    exitcode (int)

    if type == 'pager', repetitively waits for a command name ending with '
'
    and executes it defined by cmdtable, or exits the loop if the command name
    is empty.
    cC@s||_||_||_dS(N(tin_RYtchannel(RHR�RYR�((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyRIs		R^c
C@s�|tj|�tjj|p!d�g}|jd�|j�D��dj|�}|jj	t
jd|jt
|���|jj	|�|jj�|dkr|jjd�}t
jd|�\}|dkr�tjtd���nt
jd	|jjd��\}	|	S|d
kr�x�tr�|jj�d }|sIPn|rw||krwtd|�||�q&tjtd
�|��q&Wntjd|��dS(Nt.cs@s%|]\}}d||fVqdS(s%s=%sN((t.0R(R)((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pys	<genexpr>sss>cIR^is>Isinvalid responses>iRdi����spager subcommand: %ssunexpected command: %ssinvalid S channel type: %s(R	tquotecommandR9R>tabspathtextendRtjoinRYtwritetstructtpackR�tlenR_R�treadtunpackRtAbortRRgtreadlineRKtProgrammingError(
RHRaRRXRcReR~tdatatlengthtrc((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyt__call__s.*(
!	 N(RMRNRORIRJR�(((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyR��s	tcinRntrbtcoutRZtwbtcerrRotchgcmdservercB@s�eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
ejjj�Zejied6ed
6ed6e
d6e	d6e
d6�ejed�r�d�Zeed<nRS(cC@s�tt|�jt|t||d�|j�|||�||_t|_g|_	||_
||_|dk	r�|j
j�|_
tj|j
d<ndS(NtStvalidate(RSR�RIRlR�Rft
clientsocktFalset_ioattachedt_oldiosRDtbaseaddressRJtcapabilitiestcopyR�(RHR"trepoRnRZtsockRDR�((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyRI8s
					cC@s7tt|�j�|jj�|j�t|_dS(N(RSR�tcleanupR"R_t
_restoreioR�R�(RH((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyR�Es

c
C@sx|jjtjddd��tj|jj��}td|�|j}|j	�|j
�x�t|t�D]�\}\}}}|dks�t
�t||�}tj||j��tj|�|jr�qrn|dkr�|}nF|j�rd}	nd}	tj|j�||	�}t|||�t|||�qrWt|_|jjtjdt|���d	S(
s{Attach to client's stdio passed via unix domain socket; all
        channels except cresult will no longer be used
        s>cItIisreceived fds: %r
iRoi����s>iN(R�tsendallR�R�RtrecvfdsRWRKR"R_t_saveiotzipt_iochannelstAssertionErrorRTR9tdup2tcloseR�tisattytfdopenRuRgtcresultR�R�(
RHt	clientfdsR"tfdtcntfntmodetfptnewfptbufsize((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyRfMs.	

%
				cC@s�|jr
dS|j}xctD][\}}}t||�}t||�}tj|j��}|jj|||f�qWdS(N(R�R"R�RTR9tdupRWR(RHR"R�R�t_modetchR�R�((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyR�us		c	C@s�|j}x�t|jt�D]�\\}}}\}}}t||�}||k	rb|j�ntj||j��tj|�t	|||�t	|||�qW|j2dS(N(
R"R�R�R�RTR�R9R�RWRu(	RHR"R�R�R�R�R�R�R�((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyR�s	1

cC@s�ddlm}|j�}yt|j|�\|_}Wn�tjk
r�}|j|jj|�|jj	�|j
jd�dStjk
r�}|jjt
d�|�|jr�|jjt
d�|j�n|jj	�|j
jd�dSXtj||jj�}g}|j|jjkryt|j|jj�}|jd|�|jjry|jd�qyn|j|jjkr�t|j|j�}|jd	|�ntd
|�|j
jdj|�p�d�dS(s�Reload the config and check if the server is up to date

        Read a list of '' separated arguments.
        Write a non-empty list of '' separated instruction strings or ''
        if the list is empty.
        An instruction string could be either:
            - "unlink $path", the client should unlink the path to stop the
              outdated server.
            - "redirect $path", the client should attempt to connect to $path
              first. If it does not work, start a new server. It implies
              "reconnect".
            - "exit $n", the client should exit directly with code n.
              This may happen if we cannot parse the config.
            - "reconnect", the client should close the connection and
              reconnect.
        If neither "reconnect" nor "redirect" is included in the instruction
        list, the client can continue with this server after completing all
        the instructions.
        i(Rmsexit 255Ns
abort: %s
s(%s)
s	unlink %st	reconnectsredirect %ss
validate: %s
s(R.Rmt	_readlistR�R"Rt
ParseErrort_formatparsetwarnR_R�R�R�RthintRDRLRGRFt_hashaddressR�RERRKR�(RHRmR~tluitinsttnewhashtinststaddr((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyR��s8
	 
cC@s5|j�}|sdStd|�tj|�dS(s�Change current directory

        Note that the behavior of --cwd option is bit different from this.
        It does not affect --config parameter.
        Nschdir to %r
(t_readstrRKR9tchdir(RHR>((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyR��s
cC@s|j|jd��dS(sChange umask (DEPRECATED)iN(t	_setumaskt_read(RH((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pytsetumask�scC@s>|j�}t|�dkr-td��n|j|�dS(sChange umaskis(invalid mask length in setumask2 requestN(R�R�t
ValueErrorR�(RHR�((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyt	setumask2�scC@s5tjd|�d}td|�tj|�dS(Ns>Iissetumask %r
(R�R�RKR9tumask(RHR�tmask((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyR��scC@sD|j}g|_ztt|�j�SWd|j�||_XdS(N(R�RSR�t
runcommandR�(RHtglobaloldios((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyR��s		
cC@s�|j�}ytd�|D��}Wntk
rEtd��nXtdt|j���tjj�tjj	|�dS(stClear and update os.environ

        Note that not all variables can make an effect on the running process.
        cs@s!|]}|jdd�VqdS(t=iN(tsplit(R�ts((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pys	<genexpr>�ss"unexpected value in setenv requestssetenv: %r
N(
R�tdictR�RKR!tkeysRRtcleartupdate(RHtltnewenv((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pytsetenv�s

RfR�R�R�R�R�tsetprocnamecC@s+|j�}td|�tj|�dS(sChange process titlessetprocname: %r
N(R�RKR	R�(RHR�((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyR�s(RMRNRIR�RfR�R�R�R�R�R�R�R�R�RtserverR�R�R�RR[R	R�(((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyR�7s,	
		(	
		4							cC@sd|tj�fS(Ns	%s.%d.tmp(R9tgetpid(taddress((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyt_tempaddress
scC@sKtjj|�\}}|jdd�d}dtjj||�|fS(NR�iis%s-%s(R9R>R�R�(R�thashstrtdirnametbasename((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyR�
stchgunixservicehandlercB@sweZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�ZRS(
s"Set of operations for chg servicesicC@s1||_|jdd�|_tj�|_dS(Nt	chgservertidletimeout(R"t	configintt_idletimeoutttimet_lastactive(RHR"((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyRIs	cC@s2|j|�|j�|j|�|j�dS(N(t_inithashstatet_checkextensionst_bindt_createsymlink(RHR�R�((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyt
bindsockets


cC@se||_|jjdd�r4d|_||_dStj|j�|_t||jj	�|_dS(NR�tskiphash(
t_baseaddressR"t
configboolRJt
_hashstatet_realaddressRDRLR�RE(RHR�((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyR�&s			cC@s,|js
dStj�r(d|j_ndS(NR.(RRt	notloadedRF(RH((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyR�/s	cC@sXt|j�}tj||�tj|�|_|jtj	�tj
||j�dS(N(R�RRtbindunixsocketR9R:t_socketstattlistentsockett	SOMAXCONNtrename(RHR�ttempaddress((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyR�8s
cC@s[|j|jkrdSt|j�}tjtjj|j�|�tj||j�dS(N(	R�RR�R9tsymlinkR>R�RR(RHR	((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyR�Cs
cC@s_yFtj|j�}|j|jjkoD|tj|jtjkSWntk
rZtSXdS(N(R9R:Rtst_inoRR;R=R�(RHR?((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyt_issocketownerJs
cC@s$|j�sdStj|j�dS(N(RRt	tryunlinkR(RHR�((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pytunlinksocketRscC@s[|j�s'|jjd|j�tStj�|j|jkrW|jjd�tStS(Ns%s is not owned, exiting.
sbeing idle too long. exiting.
(	RR"tdebugRRgR�R�R�R�(RH((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyt
shouldexit[scC@stj�|_dS(N(R�R�(RH((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyt
newconnectiondscC@s%t|j|||||j|j�S(N(R�R"RR�(RHR�tconnRnRZ((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pytcreatecmdservergs(RMRNROtpollintervalRIR�R�R�R�R�RRRRR(((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyR�s														cC@sfdtjkrtjd=n|r;|jdddd�nt|�}tj|ddd|d|�S(NtCHGINTERNALMARKtbundletmainreporootR.R�toptsthandler(RRR{R�RtunixforkingserviceRJ(R"R�Rth((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pytchgunixserviceks
(Rsshow.aliasprefix(R�RnR�(R�RZR�(R�RoR�(.ROt
__future__RRR1R9treRR:R�R�ti18nRR.RRRRRRRtutilsR	tlogRKRRRtcompiletXRR,R8RCtobjectRDRlR�R�R�R�R�R�R�R�R(((s9/usr/lib64/python2.7/site-packages/mercurial/chgserver.pyt<module>(sH4
									7	�		V