��c@s�dZddlZddlZddlZddlZddlZddlZddlZddlm Z m
Z
mZmZddl
mZdZd�Zd�Zd�Zd �Zd
�Zddd
ddddgZdS(sbrowse command output with an external pager
To set the pager that should be used, set the application variable::
[pager]
pager = less -FRX
If no pager is set, the pager extensions uses the environment variable
$PAGER. If neither pager.pager, nor $PAGER is set, no pager is used.
You can disable the pager for certain commands by adding them to the
pager.ignore list::
[pager]
ignore = version, help, update
You can also enable the pager only for certain commands using
pager.attend. Below is the default list of commands to be paged::
[pager]
attend = annotate, cat, diff, export, glog, log, qdiff
Setting pager.attend to an empty value will cause all commands to be
paged.
If pager.attend is present, pager.ignore will be ignored.
To ignore global commands like :hg:`version` or :hg:`help`, you have
to specify them in your user configuration file.
The --pager=... option can also be used to control when the pager is
used. Use a boolean value like yes, no, on, off, or use auto for
normal behavior.
i�N(tcommandstdispatchtutilt
extensions(t_tinternalcCs�tjtd�sLtj|d�t_|jtj�rHtjt_ndStj�\}}tj �}|dkr�tj
|�tj|tjj��|jtj�r�tj|tjj��ntj
|�dStj|tj
j��tj
|�tj
|�ytjddd|g�WnNtk
r{}|jtjkrutj|�}tj|d|�q|�nXdS(Ntforktwbis/bin/shs-c(Rtsafehasattrtostpopentsyststdoutt_isattytstderrtpipeRtclosetdup2tfilenotstdintexecvptOSErrorterrnotENOENTtshlextsplit(tuitptfdintfdouttpidtetargs((s//sys/lib/python2.7/site-packages/hgext/pager.pyt
_pagerfork8s0
cs�tj|dtdddtjdtjdtjdtj��t j
tjj���t j
tjj���t j�j
j�tjj��|jtj�r�t j�j
j�tjj��ntj���fd��}dS( Ntshelltbufsizei�t close_fdsRRRcsxtjtd�r+tjtjtj�n�jj�tj�t j
j��tj�t jj���j
�dS(NtSIGINT(RRtsignalR%tSIG_IGNRRR RRRRRtwait((tpagerRR(s//sys/lib/python2.7/site-packages/hgext/pager.pyt killpager_s
(t
subprocesstPopentTrueRtclosefdstPIPERRRR tdupRRRR
tatexittregister(RRR*((R)RRs//sys/lib/python2.7/site-packages/hgext/pager.pyt_pagersubprocessTs"%cCs0tjdkrt||�n
t||�dS(Nii(ii(Rtversion_infoR3R!(RR((s//sys/lib/python2.7/site-packages/hgext/pager.pyt _runpagerhscCs@dtjks|j�r dSd�}tjtd|�dS(Ns
--debuggerc Ss|jddtjjd��}|r|jddt�}|ddk}tj|d�}|s�|r||ks�||jdd�kr|r|jdd|j ��|jddt
�tjtd �r�jtj
tj�nt||�qn|||||�S(
NR)tPAGERtattendtautotignoreRt formattedtinteractivetSIGPIPE(tconfigR tenvirontgett
configlisttattendedRt parseboolt setconfigR:tFalseRR&R<tSIG_DFLR5( torigRtoptionstcmdtcmdfuncRR7R8talways((s//sys/lib/python2.7/site-packages/hgext/pager.pytpagecmdus!t_runcommand(RtargvR:RtwrapfunctionR(RRK((s//sys/lib/python2.7/site-packages/hgext/pager.pytuisetupqs cCs/tjjdddtd�td�f�dS(NtR)R8s2when to paginate (boolean, always, auto, or never)tTYPE(Rt
globaloptstappendR(R((s//sys/lib/python2.7/site-packages/hgext/pager.pytextsetup�s tannotatetcattdifftexporttglogtlogtqdiff(t__doc__R1RR R&R+RRt mercurialRRRRtmercurial.i18nRt
testedwithR!R3R5RORTRA(((s//sys/lib/python2.7/site-packages/hgext/pager.pyt<module>0sT"
|