HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/hgext/fsmonitor/__pycache__/__init__.cpython-310.pyc
o

�]Lb��@s$dZddlmZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZddl
mZddlmZmZmZmZmZmZmZmZmZmZmZddlmZdd	lmZmZd
dl m!Z!m"Z"m#Z#dZ$iZ%e�&e%�Z&e&d
ddd�e&d
ddd�e&d
ddd�e&d
de'd�e&d
ddd�e&d
dddd�e&dddd�ddgZ(dd �Z)d!d"�Z*d#d$�Z+e!j�,�Z-e�.�p�e�/�Z0e�1e-�e�1e0�kZ2d%d&�Z3d@d'd(�Z4	)						dAd*d+�Z5Gd,d-�d-e6�Z7d.d/�Z8d0d1�Z9d2d3�Z:d4d5�Z;Gd6d7�d7e6�Z<d8d9�Z=				dBd:d;�Z>d<d=�Z?d>d?�Z@dS)Cab	Faster status operations with the Watchman file monitor (EXPERIMENTAL)

Integrates the file-watching program Watchman with Mercurial to produce faster
status results.

On a particular Linux system, for a real-world repository with over 400,000
files hosted on ext4, vanilla `hg status` takes 1.3 seconds. On the same
system, with fsmonitor it takes about 0.3 seconds.

fsmonitor requires no configuration -- it will tell Watchman about your
repository as necessary. You'll need to install Watchman from
https://facebook.github.io/watchman/ and make sure it is in your PATH.

fsmonitor is incompatible with the largefiles and eol extensions, and
will disable itself if any of those are active.

The following configuration options exist:

::

    [fsmonitor]
    mode = {off, on, paranoid}

When `mode = off`, fsmonitor will disable itself (similar to not loading the
extension at all). When `mode = on`, fsmonitor will be enabled (the default).
When `mode = paranoid`, fsmonitor will query both Watchman and the filesystem,
and ensure that the results are consistent.

::

    [fsmonitor]
    timeout = (float)

A value, in seconds, that determines how long fsmonitor will wait for Watchman
to return results. Defaults to `2.0`.

::

    [fsmonitor]
    blacklistusers = (list of userids)

A list of usernames for which fsmonitor will disable itself altogether.

::

    [fsmonitor]
    walk_on_invalidate = (boolean)

Whether or not to walk the whole repo ourselves when our cached state has been
invalidated, for example when Watchman has been restarted or .hgignore rules
have been changed. Walking the repo in that case can result in competing for
I/O with Watchman. For large repos it is recommended to set this value to
false. You may wish to set this to true if you have a very fast filesystem
that can outpace the IPC overhead of getting the result data for the full repo
from Watchman. Defaults to false.

::

    [fsmonitor]
    warn_when_unused = (boolean)

Whether to print a warning during certain operations when fsmonitor would be
beneficial to performance but isn't enabled.

::

    [fsmonitor]
    warn_update_file_count = (integer)
    # or when mercurial is built with rust support
    warn_update_file_count_rust = (integer)

If ``warn_when_unused`` is set and fsmonitor isn't enabled, a warning will
be printed during working directory updates if this many files will be
created.
�)�absolute_importN)�_)�hex)�open)�context�encoding�error�
extensions�	localrepo�merge�pathutil�pycompat�	registrar�scmutil�util)�match)�hashutil�
stringutil�)�
pywatchman�state�watchmanclientsships-with-hg-core�	fsmonitor�modeson)�defaultswalk_on_invalidateFstimeout�2sblacklistusers�watchman_exe�watchman�verboseT)r�experimental�experimental�fsmonitor.transaction_notifys
largefilesseolc
Cs�|�dtd�|�dd��t��}t�||�}d}z|�d�}|�dtd�t�	|d��Wntj
yF}zt�|�}WYd}~nd}~ww|�
|d	td
�|�|rUdSdS)
Nsfsmonitor-watchmans/fsmonitor checking for watchman binary... (%s)
rrsversionsfsmonitor-watchman-versions watchman binary version %s
�versionsfsmonitor-watchman-errors' watchman binary missing or broken: %s
rr)�writer�
configpath�tempfile�mkdtempr�client�commandr
�bytestr�Unavailabler�forcebytestr�	condwrite)�ui�fm�root�c�err�v�e�r4�:/usr/lib/python3/dist-packages/hgext/fsmonitor/__init__.py�debuginstall�s4
�
����r6cCs�t|tj�r<|jr |�dd�r dt�|�vr |�t�|�d�|jr'|��|�dd�r:|�ddt�|j	��dSdS|�ddt�|��dS)z5Exception handler for Watchman interaction exceptionsrrsillegal_fstypes�
sWatchman unavailable: %s
sWatchman exception: %s
N)
�
isinstancerr*�warn�
configboolrr+�
invalidate�log�msg)r-r�exr4r4r5�_handleunavailable�s$
���r?cCs&t��}|�t�|��t�|���S)z�Calculate hash for ignore patterns and filenames

    If this information changes between Mercurial invocations, we can't
    rely on Watchman information anymore and have to re-scan the working
    copy.

    )r�sha1�updater
�byterepr�sysbytes�	hexdigest)�ignorer@r4r4r5�_hashignore�srFc
Csxz|�t�}Wnty}z
tjt�|�dd��d}~wwz	|�td�}W|St	y;}zt�t�|���d}~ww)z�Fix path to match watchman and local filesystem encoding

    watchman's paths encoding can differ from filesystem encoding. For example,
    on Windows, it's always utf-8.
    swatchman encoding error)�hintN�strict)
�decode�_watchmanencoding�UnicodeDecodeErrorr�Abortrr+�encode�_fsencoding�UnicodeEncodeError)�path�decodedr3�encodedr4r4r5�_watchmantofsencodings
������rSc(
s����
��fdd�}|r|d�S�r|d�S�
j��s |d�S�
j}|��\}	}
}|	s7|jr3|d�Sd}	g}�
j��
j��rUt��|
krT|	dkrT|jrP|d�Sg}d}	ntj	�tj	��j
���	�}�
j�t��d	�rn�j�d
d��
j�
�D�}
�
jj}tj}tj}tj}tj}�
j�tj�
d}d}}���r�d
}tj	�n���r�d
}|s��
jr��
j�	d}nd�	�
����\�}}|o�|p�|}�fdd�|D�}|s�|s�|r݈D]}�|=q҈d=�Sz)�
j�|jd��
j�dgd�|	ddddggd�ggt|jd�|jd��}Wn#t�y)}zt �
j!||��
j�"�|d�WYd}~Sd}~ww|�#t$�%|d��|d�rI|j�rE|�&�|d�Sd
}g}�	�rU�
fdd ��D��t$j'd!k}|d"D]�}|d#}t(|t)��so|�*t+�}t,�rvt-|�}|�r|�.d!d$�}�	�r��
|�}�	|d
d
�}|�|<|d%}|d&} ||�}!d'|v�s�|�/d(��r�|d)�S| �s�|�v�r�|�v�r�|�sˆ|��r�d�|<�q^|!|k�r�|�v�r�|�sڈ|��r�d�|<�q^|!|k�s�|!|k�r|�v�r�|�s��|��r�|�|<�q^|�s�|��r�|��s|�|<�q^|�v�r!|�s�|��r!d�|<�q^�	�r1��	�
fd*d�|D�}����fd+d�|D�}"|�sw|�r\|"�0�fd,d-�|
D��|"�0�fd.d-�|D��nW|"�0��fd/d-�|
D��|"�0��fd0d-�|D��n<|�r�|"�0�fd1d-�t$�1��D��|"�0�fd2d-�|D��n|"�0��fd3d-�t$�1��D��|"�0��fd4d-�|D��t2j3�
j4d
d5�j5��fd6d�|"D�}#|#�6�|"�7|#�}$|$D]}%d�|%<�q�t8|#�}&t�9�fd7d�|#D��D]}'t:|&�}%|'�s�|%�v�r�|'�|%<�q�D]}�|=�q��d=�S)8z�Replacement for dirstate.walk, hooking into Watchman.

    Whenever full is False, ignored is False, and the Watchman client is
    available, use Watchman combined with saved state to possibly return only a
    subset of files.cs"�j�d|������dd�S)Ns'fsmonitor: fallback to core status, %s
T)�full)�_ui�debug)�reason)�ignoredr�orig�self�subrepos�unknownr4r5�bail'szoverridewalk.<locals>.bailsfull rewalk requestedslisting ignored filessclient unavailablesno clocksc:0:0signore rules changeds_mapcSs,h|]\}}|��dks|��dkr|�qS)�n���)�v1_state�v1_mtime)�.0�fr3r4r4r5�	<setcomp>Ps
�zoverridewalk.<locals>.<setcomp>FTNcsg|]
}�|d�s|�qS)rr4)rb�d)�	dirignorer4r5�
<listcomp>ssz overridewalk.<locals>.<listcomp>�.hg皙�����?squery)rsmtimessize�exists�namesnotsanyofsdirname)rkrhs	wholenamei�)sfieldsssinces
expressionssync_timeoutsempty_on_fresh_instancesexception during runsclocksis_fresh_instancesfresh instancecsi|]}�|�|�qSr4r4)rb�k)�normcaser4r5�
<dictcomp>�sz overridewalk.<locals>.<dictcomp>�\sfilesrk�/rrjs/.hg/s/.hgsnested-repo-detectedcs$h|]}�|��vr�|dd��qS�Tr4�rbrc)�foldmap�	normalizermr4r5rd�s

�cs0h|]}|�vr�|�r|�vs�|�s|�qSr4r4rr)�dmaprE�matchfn�resultsr4r5rd�s
 �c3��|]	}|�vr|VqdS�Nr4rr�rwr4r5�	<genexpr>���zoverridewalk.<locals>.<genexpr>c3rxryr4rrrzr4r5r{�r|c3�$�|]
}|�vr�|�r|VqdSryr4rr�rvrwr4r5r{�s��c3r}ryr4rrr~r4r5r{���"c3s �|]\}}|�vr|VqdSryr4�rbrc�strzr4r5r{�s��c3rxryr4rrrzr4r5r{�r|c3s(�|]\}}|�vr�|�r|VqdSryr4r�r~r4r5r{�s���c3r}ryr4rrr~r4r5r{r)�cachedcsg|]}�|�r|�qSr4r4rr)�auditr4r5rgscsg|]}�|��qSr4r4rr)�joinr4r5rg
s);�_watchmanclient�	available�_fsmonitorstate�get�walk_on_invalidate�_ignore�
_dirignorerFr�alwaysrv�_map�safehasattr�items�copymap�stat�S_IFMT�S_IFDIR�S_IFREG�S_IFLNK�_joinrm�isexact�prefix�
_checkcase�_normalizefile�
_walkexplicit�
settimeout�timeoutr(�int�	Exceptionr?rU�clearconnection�setlastclockr
rCr;�ossepr8�bytesrMrJ�_fixencodingrS�replace�endswithrA�	iteritemsr�pathauditor�_root�check�sort�
difference�iter�	statfiles�next)(rYrZrr[r\rXrTr]r�clock�
ignorehash�	notefiles�matchalways�nonnormalsetr��getkind�dirkind�regkind�lnkkind�fresh_instance�exact�	skipstep3�work�dirsnotfound�s�resultr>�switch_slashes�entry�fname�normed�fmode�fexists�kind�visit�	auditpass�	auditfailrc�nfr�r4)r�rfrursrErXr�rrvrtrmrYrwrZr[r\r5�overridewalk sX
��
����
��




���
�
��������
�
r��.c	 s�|}	|}
|}�fdd�}t|tj�r|}
n�|}
t|tj�r"|}n�|}|��du}|o3|
�dk}|p9t��}|oN|��oNt|tjtjf�oNdtj	v}z�j
jr[�j�
d�n
�j�
�j
jd��j��}Wn)ty�}z�j��t�j�j
|�|||||	|
||�WYd}~Sd}~ww|r�d}n|}|r�t|�}��|�|||||	|
||�}|\}}}}}}}|s�g}|
p�|jdu}�j
jdk�rJ|�sJd�j_�jj}d�j_�jj�jj}}ttjd��j_�j_z|||||	|
||�}Wd	�j_|�j_||�j_�j_nd	�j_|�j_||�j_�j_w�� ��||||||||g|�Wd�n	1�s<wY|\}}}}}}}t!�"|||||||�S)
Nc	s�zdtjvrtjd}t|d�}n	d}�j�|d�}Wnttfy1�j�td�|�YdSwz2t	t
||��D]#\}\}}t|�t|�kr]|�d|�|�d|�|�d|�q:W|�
�dS|�
�w)NsFSMONITOR_LOG_FILE�wbsfsmonitorfail.logswarning: unable to write to %s
s sets at position %d are unequal
swatchman returned: %r
sstat returned: %r
)r�environr�vfs�IOError�OSErrorr-r9r�	enumerate�zip�setr#�close)�l1�l2�fnrc�i�s1�s2�rZr4r5�_cmpsets's(

����z overridestatus.<locals>._cmpsetsr�s
HG_PENDINGriTsparanoidr�F)#r8r�	changectx�rev�matchmodr��workingcommitctx�memctxrr�r�r�r�r�r��getcurrentclockr�r�r?r-�
poststatus�addpostdsstatus�traversedir�mode�dirstate�_fsmonitordisable�quiet�fout�ferrr�os�devnull�wlockr�status) rYrZ�node1�node2rrX�cleanr\�listsubrepos�listignored�	listclean�listunknownr��ctx1�ctx2�working�
parentworking�updatestate�
startclockr>�stateunknown�ps�r�modified�added�removed�deletedrTr�r�r��rv2r4r�r5�overridestatuss�
���
���
��
�
���rc@seZdZdd�Zdd�ZdS)r�cCst�|�|_dSry)r
rC�_startclock)rZr�r4r4r5�__init__�szpoststatus.__init__cCsZ|��j��p	|j}t|��jj�}|j|j|j	|j
|j}|��j�|||�dSry)
�repor��getlastclockrrFr�r�rrrrr\r�)rZ�wctxr�r��
hashignorer�r4r4r5�__call__�s�����zpoststatus.__call__N)�__name__�
__module__�__qualname__rr
r4r4r4r5r��sr�cs*G�fdd�d|j���|_|�|�dS)NcsBeZdZdd�Z��fdd�Z��fdd�Z��fdd�Z�ZS)	z'makedirstate.<locals>.fsmonitordirstatecSs&d|_|j|_|j|_t�|�|_dS�NF)r�r�r��weakref�proxy�_repo)rZr	r4r4r5�_fsmonitorinit�sz6makedirstate.<locals>.fsmonitordirstate._fsmonitorinitcs8t�|�j}|jr||i|��St||g|�Ri|��Sry)�super�walkr�r��rZ�args�kwargsrY��	__class__�fsmonitordirstater4r5r�sz,makedirstate.<locals>.fsmonitordirstate.walkcs |j��t�|�j|i|��Sry)r�r;r�rebuild�rZrrrr4r5r��
z/makedirstate.<locals>.fsmonitordirstate.rebuildcs |j��t�|�j|i|��Sry)r�r;rrrr4r5r;�r z2makedirstate.<locals>.fsmonitordirstate.invalidate)rrrrrrr;�
__classcell__r4�r�rr5r�s
r)rr)r	r�r4r"r5�makedirstate�sr$cCs"||�}t�|d�rt||�|S)Ns_fsmonitorstate)rr�r$)rYrZ�dsr4r4r5�wrapdirstate�s
r&cCs6t�tjdt�tjrt�tdt	�t�t
dt�dS)N�dirstatessymlinks_update)r	�
wrapfilecacher
�localrepositoryr&r
�isdarwin�wrapfunctionr��wrapsymlinkr�
wrapupdate)r-r4r4r5�extsetup�s�r.cCsdz|||�Wzt�tj�|�d�WStyYSwzt�tj�|�d�Wwty1Yww)zyif we create a dangling symlink, also touch the parent dir
    to encourage fsevents notifications to work more correctlyN)r��utimerP�dirnamer�)rY�source�	link_namer4r4r5r,�s
���r,c@sNeZdZdZ				ddd�Zdd�Zdd	�Zd
d�Zddd
�Zddd�Z	dS)�state_updatea�This context manager is responsible for dispatching the state-enter
    and state-leave signals to the watchman service. The enter and leave
    methods can be invoked manually (for scenarios where context manager
    semantics are not possible). If parameters oldnode and newnode are None,
    they will be populated based on current working copy in enter and
    leave, respectively. Similarly, if the distance is none, it will be
    calculated based on the oldnode and newnode in the leave method.NFcCs8|��|_||_||_||_||_||_d|_d|_dSr)	�
unfilteredr	�name�oldnode�newnode�distance�partial�_lock�
need_leave)rZr	r5r6r7r8r9r4r4r5rs
	
zstate_update.__init__cCs|��dSry)�enterr�r4r4r5�	__enter__szstate_update.__enter__cCsh|jdur
|jd��|_|j��dur(t�|jd�r"|j��|_n|j��|_|�	dt
|j��|_|S)Nr�swlocknostateupdatesstate-enter)r6r	�node�currentwlockrr��wlocknostateupdater:r��_staterr;r�r4r4r5r<s
zstate_update.entercCs|rdnd}|j|d�dS)NTF)�abort)�exit)rZ�type_�value�tbrBr4r4r5�__exit__*szstate_update.__exit__cCs�z@|jr1|rdnd}|jdur|jd��|_|jdur&t|j|j|j�|_|jdt|j�|d�Wd|_|j	r?|j	�
�dSdSd|_|j	rM|j	�
�ww)Nsfailed�okr�sstate-leave)r�F)r;r7r	r>r8�calcdistancer6rArr:�release)rZrBr�r4r4r5rC.s&

�����zstate_update.exitrHc
Cs�t�|jd�s	dSz|jj�||j||jr|jnd||jd�d��WdStyA}z|jj	�
dd||�WYd}~dSd}~ww)	Ns_watchmanclientFr)srevsdistancesstatusspartial)rksmetadataTrsException %s while running %s
)rr�r	r�r(r5r8r9r�r-r<)rZ�cmd�
commithashr�r3r4r4r5rA>s*������zstate_update._state)NNNF)F)rH)
rrr�__doc__rr=r<rGrCrAr4r4r4r5r3�s
�
r3cCsF|j�||�}||��}t||��|�t||��|�}|Sry)�	changelog�ancestorr��abs)r	r6r7�anc�ancrevr8r4r4r5rI\s�rIc	
Ks�d}
d}|d��}||��}
|dus|��r"d}t|��||
�}
t|d||
|
|d��|||||||||fi|	��Wd�S1sFwYdS)NrTr�Fs	hg.update)r5r6r7r8r9)r>r�rIr4r3)rYr	r>�branchmerge�forcerO�
mergeancestor�labels�matcherrr8r9r6r7r4r4r5r-is8
��	�$�r-cCsH|j��D]}tj�tj�|j|d��r!d}|j�||�dSqdS)Nrhs:fsmonitor: sub-repository %r detected, fsmonitor disabled
TF)	�wvfs�listdirr�rP�isdirr�r/r-rV)r	rcr=r4r4r5�repo_has_depth_one_nested_repo�s�r[c	
st��}tD]}||vr��td�|�dSq|��r�|j�d�s)|j�d�r+dSt|�r1dSt	�	|�}|j
dkr=dSz
t�|j
|j�}Wnty`}z
t�||�WYd}~dSd}~ww||_||_t�|d�\}}|rvt||�G��fdd�d|j���|_dSdS)NsUThe fsmonitor extension is incompatible with the %s extension and has been disabled.
s.hgsubstates.hgsubsoffr'cs<eZdZ��fdd�Z��fdd�Z���fdd�Z�ZS)z reposetup.<locals>.fsmonitorrepocs$t�|�j}t||g|�Ri|��Sry)rr�rr�r�
fsmonitorrepor4r5r��sz'reposetup.<locals>.fsmonitorrepo.statuscst�|�j|i|��Sry)rr�rr\r4r5r@�sz3reposetup.<locals>.fsmonitorrepo.wlocknostateupdatec
s�t�|�j|i|�����dd�s�S�jdkr�S�j���fdd�}zd�_t|dd��_�j��|�_W�StyT}z|j	�
dd	|�WYd}~�Sd}~ww)
Nr r!rcs(�r���jr�j��d�_dSdSry)�stateupdaterCr4��l�origreleaser4r5�staterelease�s

�z<reposetup.<locals>.fsmonitorrepo.wlock.<locals>.statereleaseshg.transaction)r5rsException in state update %s
)rr�r:�held�	releasefnr^r3r<r�r-r<)rZrrrbr3)rr]r-r_r5r��s,�

����z&reposetup.<locals>.fsmonitorrepo.wlock)rrrr�r@r�r!r4�r]r-r#r5r]�sr])r	�enabled�
_blacklistr9r�localrX�existsr[rr�rr'r-r/r�r?r�r�r
�isfilecachedr$r)	r-r	�exts�ext�fsmonitorstater'r>r�r�r4rer5�	reposetup�sF����


��

%�rnrq)r�NNFFFF)NFNN)ArM�
__future__r�codecsr�r��sysr%r�mercurial.i18nr�mercurial.noder�mercurial.pycompatr�	mercurialrrrr	r
rrr
rrrrr��mercurial.utilsrr�rrr�
testedwith�configtable�
configitem�listrgr6r?rF�get_local_encodingrJ�getfilesystemencoding�getdefaultencodingrN�lookupr�rSr�r�objectr�r$r&r.r,r3rIr-r[rnr4r4r4r5�<module>s�f4


�������


|
�`
�*