\x89\x50\x4E\x47\x0D\x0A\x1A\x0A PNG  \x89\x50\x4E\x47\x0D\x0A\x1A\x0A  13\c@@sydZddlmZddlZddlZddlZddlZddlmZddl m Z dZ dZ dS(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(tabsolute_importN(tpycompat(tprocutilsships-with-hg-corec@sftjr.d}|tjBfdn dd|jffdY|_dS(Nic @s;tjtj|dtdtj|dtddS(Ntshelltenvt close_fdst creationflags(t subprocesstPopenRt tonativestrtTruet tonativeenv(tscriptR(t_creationflags(s8/usr/lib64/python2.7/site-packages/hgext/logtoprocess.pytrunshellcommand@scS@stj}|rdStjdkr8itjd6}n itd6}znttjd}ttjd}tj t j |dtd|d |d |d t j |d t|Wdtj d XdS(Niit preexec_fntstart_new_sessiontrtwRtstdintstdouttstderrRRi(ii(tostforktsyst version_infotsetsidR topentdevnullRRRR R t_exit(R Rtpidt newsessiontnullrfdtnullwfd((s8/usr/lib64/python2.7/site-packages/hgext/logtoprocess.pyRHs     tlogtoprocessuic@seZfdZRS(c @s |jd|}|r|rly|d|d}Wn!ttfk rW|d}nX|f|d}n|}dt|dD}d|jD}ttjtj j ||d|dt t j } || nt|j|||S(spMap log events to external commands Arguments are passed on as environment variables. t logtoprocessiics@s0|]&\}}dj|t|fVqdS(sMSG{0:d}N(tformattstr(t.0titm((s8/usr/lib64/python2.7/site-packages/hgext/logtoprocess.pys scs@s6|],\}}dj|jt|fVqdS(sOPT_{0}N(R$tupperR%(R&tkeytvalue((s8/usr/lib64/python2.7/site-packages/hgext/logtoprocess.pys stEVENTtHGPID(tconfigt TypeErrortKeyErrort enumeratet iteritemstdictt itertoolstchainRt shellenvirontitemsR%Rtgetpidtsupertlog( tselfteventtmsgtoptsR t formattedtmessagestmsgpairstoptpairsR(R"R(s8/usr/lib64/python2.7/site-packages/hgext/logtoprocess.pyR:hs$ (t__name__t __module__R:((R"R(s8/usr/lib64/python2.7/site-packages/hgext/logtoprocess.pyR"gs(Rt iswindowsRtCREATE_NEW_PROCESS_GROUPt __class__(tuitDETACHED_PROCESS((R R"Rs8/usr/lib64/python2.7/site-packages/hgext/logtoprocess.pytuisetup8s   "%( t__doc__t __future__RR4RRRt mercurialRtmercurial.utilsRt testedwithRJ(((s8/usr/lib64/python2.7/site-packages/hgext/logtoprocess.pyt!s