File: //proc/thread-self/root/lib64/python2.7/site-packages/hgext/logtoprocess.pyc
�
1�3\c @@ sy d Z d d l m Z 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
d Z d � Z d S( s^ send ui.log() data to a subprocess (EXPERIMENTAL)
This extension lets you specify a shell command per ui.log() event,
sending all remaining arguments to as environment variables to that command.
Each positional argument to the method results in a `MSG[N]` key in the
environment, starting at 1 (so `MSG1`, `MSG2`, etc.). Each keyword argument
is set as a `OPT_UPPERCASE_KEY` variable (so the key is uppercased, and
prefixed with `OPT_`). The original event name is passed in the `EVENT`
environment variable, and the process ID of mercurial is given in `HGPID`.
So given a call `ui.log('foo', 'bar', 'baz', spam='eggs'), a script configured
for the `foo` event can expect an environment with `MSG1=bar`, `MSG2=baz`, and
`OPT_SPAM=eggs`.
Scripts are configured in the `[logtoprocess]` section, each key an event name.
For example::
[logtoprocess]
commandexception = echo "$MSG2$MSG3" > /var/log/mercurial_exceptions.log
would log the warning message and traceback of any failed command dispatch.
Scripts are run asynchronously as detached daemon processes; mercurial will
not ensure that they exit cleanly.
i ( t absolute_importN( t pycompat( t procutils ships-with-hg-corec @ sf t j r. d } | t j B� � f d � � n d � � d | j f � � f d � � Y� � | _ d S( Ni c
@ s; t j t j | � d t d t j | � d t d � �d S( Nt shellt envt close_fdst
creationflags( t
subprocesst PopenR t tonativestrt Truet tonativeenv( t scriptR ( t _creationflags( s8 /usr/lib64/python2.7/site-packages/hgext/logtoprocess.pyt runshellcommand@ s c S@ s� t j � } | r d St j d k r8 i t j d 6} n
i t d 6} zn t t j d � } t t j d � } t j t
j | � d t d | d | d
| d t
j | � d t | �Wd t j
d
� Xd S( Ni i t
preexec_fnt start_new_sessiont rt wR t stdint stdoutt stderrR R i ( i i ( t ost forkt syst version_infot setsidR
t opent devnullR R R R R t _exit( R R t pidt
newsessiont nullrfdt nullwfd( ( s8 /usr/lib64/python2.7/site-packages/hgext/logtoprocess.pyR H s
t logtoprocessuic @ s e Z � � f d � Z RS( c
@ s | j d | � } | r� | rl y | d | d } Wn! t t f k
rW | d } n X| f | d } n | } d � t | d � D� } d � | j � D� } t t j t j � j
� | | � d | d t t j
� � �} � | | � n t � | � j | | | � S( sp Map log events to external commands
Arguments are passed on as environment variables.
t logtoprocessi i c s@ s0 | ]&