
    q&f                     `    d dl Z d dlZd dlZd dlZd dlmZ d dlmZmZm	Z	 dZ
dZ G d d      Zy)    N)_)encodingpathutilutil   s   >Ic                   0    e Zd Zd Zd Zd Zd Zd Zd Zy)statec                    |j                   | _        |j                  | _        t	        j
                  |j                        | _        d | _        t        j                  d       | _        | j                  j                  dd      | _        | j                  j                  dd      | _        t!        | j                  j                  dd            | _        y )N	   fsmonitors   modes   walk_on_invalidates   timeout)vfs_vfsui_uir   normasprefixroot_rootdir
_lastclockr   filestat	_identityconfigmode
configboolwalk_on_invalidatefloattimeout)selfrepos     7/usr/lib/python3/dist-packages/hgext/fsmonitor/state.py__init__zstate.__init__   s    HH	77 --dii8t,HHOOL':	"&(("5"5/#
 TXX__\:FG    c                    	 | j                  dd      }t        j                  j                  |      | _        |j                  d      }t        |      dk  r9| j                  j                  ddt        |      z         | j                          y	 t        j                  t        |      d   }|t         k7  rG| j                  j                  dd|t         fz         | j                          	 |j#                          y|j                         j%                  d	      }t        |      d
k  rH| j                  j                  ddt        |             | j                          	 |j#                          y|d   }t'        j(                  t+        j,                               }||k7  rC| j                  j                  dd||fz         | j                          	 |j#                          y|d   }|d   }	|d
d }
|j#                          ||	|
fS # t        $ rB}t        j                  d       | _        |j
                  t
        j                  k7  r Y d }~yd }~ww xY w# |j#                          w xY w)N   fsmonitor.states   rb)NNNr   r   s6   fsmonitor: state file only has %d bytes, nuking state
r   s6   fsmonitor: version switch from %d to %d, nuking state
       sL   fsmonitor: state file truncated (expected 3 chunks, found %d), nuking state
sJ   fsmonitor: stored hostname "%s" different from current "%s", nuking state
      )r   IOErrorr   r   r   errnoENOENTfromfpreadlenr   log
invalidatestructunpack_versionformat_versionclosesplitr   
strtolocalsocketgethostname)r   fileinstversionbytesdiskversionr	   diskhostnamehostnameclock
ignorehash	notefiless              r   getz	state.get'   s(   	$99/7D --d3yy||q HHLL"$'$56
 OO#+	 --EaHKh& *-8(,CD
 !'B JJL? IIK%%e,E 5zA~ ;J	 !'( JJL' !8L**6+=+=+?@Hx' C#X./ !' JJL !HEqJaI JJLj)++}  	$!]]40DNzzU\\)#		$x JJLs8   H AI >A#I 3A"I 'I 	I8III+c                 >   || j                          y t        j                  j                  | j                  j                  d            }|| j                  k7  r| j                  j                  d       y 	 | j	                  dddd      }|5  |j                  t        j                  t         t"                     |j                  t%        j&                  t)        j*                               dz          |j                  |dz          |j                  |dz          |r1|j                  dj                  |             |j                  d       d d d        y # t        t        f$ r' | j                  j                  t        d             Y y w xY w# 1 sw Y   y xY w)Nr"   s1   skip updating fsmonitor.state: identity mismatch
s   wbT)
atomictemp
checkambigs-   warning: unable to write out fsmonitor state
r#   )r/   r   r   frompathr   joinr   r   debugr(   OSErrorwarnr   writer0   packr2   r3   r   r6   r7   r8   )r   r?   r@   rA   identityr9   s         r   setz	state.setj   sL   =OO ==))$))..9K*LMt~~%HHNNE 	99"Edt  D  	"JJv{{>8<=JJx**6+=+=+?@5HIJJuu}%JJzE)*

5::i01

5!	" 	"	 ! 	HHMM!MNO		" 	"s   8E CF3FFFc                     	 t        j                  t         j                  j                  | j                  dd             t        j                  d       | _        y # t
        $ r Y &w xY w)Ns   .hgr"   )	osunlinkpathrG   r   FileNotFoundErrorr   r   r   r   s    r   r/   zstate.invalidate   sO    	IIbggll4==&:LMN t, ! 		s   >A 	A'&A'c                     || _         y Nr   )r   r?   s     r   setlastclockzstate.setlastclock   s	    r    c                     | j                   S rV   rW   rT   s    r   getlastclockzstate.getlastclock   s    r    N)	__name__
__module____qualname__r   rB   rN   r/   rX   rZ    r    r   r	   r	      s#    HA,F">- r    r	   )r)   rP   r7   r0   mercurial.i18nr   	mercurialr   r   r   r3   r2   r	   r^   r    r   <module>ra      s8     	     { {r    