Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/site-packages/hgext/blackbox.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�ܬQc@s�dZddlmZmZddlmZddlZddlZddlZiZ	ej
e	�Z
dZda
d�Zd�Zd�Ze
d	d
dded
�fged��d��ZdS(slog repository events to a blackbox for debugging

Logs event information to .hg/blackbox.log to help debug and diagnose problems.
The events that get logged can be configured via the blackbox.track config key.
Examples::

  [blackbox]
  track = *

  [blackbox]
  track = command, commandfinish, commandexception, exthook, pythonhook

  [blackbox]
  track = incoming

  [blackbox]
  # limit the size of a log file
  maxsize = 1.5 MB
  # rotate up to N log files when the current one gets too big
  maxfiles = 3

i�(tutiltcmdutil(t_Ntinternalcs,d|jf�fd��Y��|_dS(Nt
blackboxuics;eZejd��Zd�Z�fd�Zd�ZRS(cSs|jdddg�S(Ntblackboxttrackt*(t
configlist(tself((s2/sys/lib/python2.7/site-packages/hgext/blackbox.pyR+scs�fd�}�jdd�}�jddd�}|dkrtj|j��}|j|kr|j}|j��jddd	�}xIt	|d
d
d�D]1}|dd
||d
fdd
||f�q�W|d|d|dko�d��jdd�}qn|S(Ncs�ytj|�WnBtk
rU}|jtjkrV�jd||jf�qVnXy|rrtj||�nWnEtk
r�}|jtjkr��jd|||jf�q�nXdS(Ns warning: cannot remove '%s': %s
s(warning: cannot rename '%s' to '%s': %s
(tostunlinktOSErrorterrnotENOENTtdebugtstrerrortrename(toldpathtnewpathterr(R	(s2/sys/lib/python2.7/site-packages/hgext/blackbox.pytrotate0s		sblackbox.logtaRtmaxsizeiitmaxfilesiii�Rs%s.%dRs.1(
t	_bbopenertconfigbytesR
tfstattfilenotst_sizetnametcloset	configinttxrange(R	RtfpRtsttpathRti((R	s2/sys/lib/python2.7/site-packages/hgext/blackbox.pyt_openlogfile/s 	
c	s]t�|�j|||�d|jkr>||jkr>dStj|d�r\|j}nvtj|d�r�y|j�|_Wn<ttfk
r�}|j	d|j
�|`d|_nX|j}nt
}|rYtjdd�}tj�}|d|d}y|jd|||f�Wn'tk
rO}|j	d|j
�nX|a
ndS(	NRt	_blackboxRs*warning: cannot write to blackbox.log: %s
s%Y/%m/%d %H:%M:%Siis	%s %s> %s(tsupertlogRRtsafehasattrR'R&tIOErrorRRRRtNonetlastblackboxtdatestrtgetusertwrite(	R	teventtmsgtoptsRRtdatetusertformattedmsg(R(s2/sys/lib/python2.7/site-packages/hgext/blackbox.pyR)Os2	
	cSs|j|_dS(N(topenerR(R	trepo((s2/sys/lib/python2.7/site-packages/hgext/blackbox.pytsetrepors(t__name__t
__module__Rt
propertycacheRR&R)R9((R(s2/sys/lib/python2.7/site-packages/hgext/blackbox.pyR*s	 #(t	__class__(tui((Rs2/sys/lib/python2.7/site-packages/hgext/blackbox.pytwrapui)sKcCst|�dS(N(R?(R>((s2/sys/lib/python2.7/site-packages/hgext/blackbox.pytuisetupwscCs6|j�sdStj|d�r2|j|�ndS(NR9(tlocalRR*R9(R>R8((s2/sys/lib/python2.7/site-packages/hgext/blackbox.pyt	reposetupzss	^blackboxtltlimiti
sthe number of events to showshg blackbox [OPTION]...c
Os�tjj|jd��sdS|jd�}|jdd�}|j�jd�}d}g}xPt|�D]B}	||kr�Pnt	j
d|	�r�|d7}n|j|	�qnW|jdjt|���dS(	s&view the recent repository events
    sblackbox.logNRDtrs
is+^\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2} .*> .*i(
R
R$texiststjointgetR7treadtsplittreversedtretmatchtappendtstatus(
R>R8trevsR3RDRtlinestcounttoutputtline((s2/sys/lib/python2.7/site-packages/hgext/blackbox.pyR�s
(t__doc__t	mercurialRRtmercurial.i18nRR
R
RLtcmdtabletcommandt
testedwithR,R-R?R@RBR(((s2/sys/lib/python2.7/site-packages/hgext/blackbox.pyt<module>s$	N		


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.