��c@s�ddlmZddlZddlZddlZddlZddlZddlZddlZddl Z ddl
Z
ddlZddlZddl
Z
ddlZdefd��YZdS(i�(t_NtuicBseZd2d�Zd�Zd�Zd�Zd2ed2d2d�Zd2d2d�Z d�Z
d�Zed�Z
d �Zed
�Zd2ed�Zd2ed�Zeed
�Zd2ed�Zded�Zd2ed�Zed�Zed�Zed�Zd2d�Zd�Zd�Zd2d�Zd�Zed�Zd�Zd�Z d�Z!d�Z"d�Z#d �Z$d!�Z%d"d#�Z&d$d%�Z'dd&�Z(d2d2d'�Z)d(�Z*d)�Z+d*�Z,d+�Z-d,�Z.d2ed-�Z/d.�Z0d"d"d2d/�Z1d0�Z2d1�Z3RS(3cCs�g|_t|_|_|_|_t|_tj�|_ tj�|_
tj�|_t�|_
t�|_t|_|r'|j|_|j|_|j|_|j
j�|_
|jj�|_|j j�|_ |j
j�|_
|jj�|_|j|_|j|_|j�nZtj|_tj|_tj|_tj|_x'tj�D]}|j|dt�qdWdS(Nttrust(t_bufferstFalsetquiettverboset debugflagt
tracebackflagtTruet_reportuntrustedtconfigt_ocfgt_tcfgt_ucfgtsett_trustuserst_trustgroupst callhookstfouttferrtfintcopytenviront fixconfigtsyststdouttstderrtstdintostscmutiltrcpatht
readconfig(tselftsrctf((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyt__init__
s6
cCs
|j|�S(N(t __class__(R!((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyR0scCstj|||�S(N(t formatter(R!ttopictopts((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyR&3scCs�tj|�}tj|�r"tS|j|j}}d|ksMd|krQtStj|j�}tj|j �}||ks�||ks�|tj�kr�tS|j
r�|jtd�|||f�nt
S(Nt*s6not trusting file %s from untrusted user %s, group %s
(tutiltfstattisownerR RRtusernametst_uidt groupnametst_gidR
twarnRR(R!tfpR#tstttusersttgroupstusertgroup((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyt_trusted6s* c
Cs�yt|�}Wntk
r0|s*dS�nXtj�}|pX|pX|j||�}y*|j||d|d|�|j�Wn?tjk
r�} |r��n|jt d�t
| ��nX|j�r0x,dD]$}
|
|dkr�|d|
=q�q�Wx+|jd
�D]\}
}|d
|
=qWn|jd�rmx+|jd�D]\}
}|d|
=qOWn|r�|j
j|�|j
j|j�n|jj|�|jj|j�|dkr�tjjd�}n|jd|�dS(Ntsectionstremapsignored: %s
tdebugtfallbackencodingRtslashtlogtemplatetstylet tracebackRRtdefaultstaliast~troot(sdebugR<squietsslashR>R?s tracebacksverbose(topentIOErrorRR8treadtcloseterrortConfigErrorR1RtstrtplaintitemsR
tupdateRRtNoneRtpatht
expanduserR(R!tfilenameRDRR9R:R2tcfgttrustedtinsttktv((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyR IsD
!
c
Cs0|dkr&|ptj�}x|j|j|jfD]�x�|jd�D]�\}}|seqMnd|kr�|jtd�|||j d|�f�|j
dd�}ntj|�}tj
|�rtjj|�rtjjtjj||��}n|jd||�qMWq7Wn|dkr�jdd�|_|jp_|jdd�|_|jo~|jdd�|_|jr�|jr�t|_|_n|jp�|jdd t�|_|jdd
t�|_n|dkr,|jj|jdd��|jj|jdd
��ndS(Ntpathss%%s((deprecated '%%' in path %s=%s from %s)
t%RR;RRtreport_untrustedR@RTtuserstgroups(Nspaths(Nsui(Nstrusted(RORtgetcwdR
RRRMR1RtconfigsourcetreplaceR*t
expandpatht hasschemeRPtisabstnormpathtjoinRt
configboolRRRRR R
RRRNt
configlistR(R!RDtsectiontctntp((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyRts4#$cCs:|jj||�|jj||�|jj||�fS(N(RtbackupR
R(R!Rgtitem((s0/sys/lib/python2.7/site-packages/mercurial/ui.pytbackupconfig�scCs@|jj|d�|jj|d�|jj|d�dS(Niii(RtrestoreR
R(R!tdata((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyt
restoreconfig�scCs_|r|jj|||�n|jj|||�|jj|||�|jd|�dS(NRg(RRR
RR(R!Rgtnametvaluetoverlay((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyt setconfig�s
cCs|r|jp|jS(N(RR
(R!t untrusted((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyt_data�scCs|j|�j||�pdS(Ntnone(Rvtsource(R!RgRqRu((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyR^�sc Cs�t|t�r|}n |g}xH|D]:}|j|�j||d�}|dk r(|}Pq(q(W|}|jr�|r�|jr�|jj||�}|dk r�||kr�|jd|||f�q�n|S(Ns3ignoring untrusted configuration option %s.%s = %s
( t
isinstancetlistRvtgetRORR
RR;( R!RgRqtdefaultRut
alternatesRiRrtuvalue((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyR�s
cCs�|j||||�}|dkr(dStjj|�sGd|kr�|j|||�}d|kr�tjj|jd�d�}tjj|tjj |��}q�n|S(sEget a path config item, expanded relative to repo root or config files://t:iN(
RRORRPRbR^tdirnametrsplitRdRQ(R!RgRqR|RuRWR"tbase((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyt
configpath�s'cCs|j||d|�}|dkr(|St|t�r;|Stj|�}|dkr{tjtd�|||f��n|S(sPparse a configuration element as a boolean
>>> u = ui(); s = 'foo'
>>> u.setconfig(s, 'true', 'yes')
>>> u.configbool(s, 'true')
True
>>> u.setconfig(s, 'false', 'no')
>>> u.configbool(s, 'false')
False
>>> u.configbool(s, 'unknown')
False
>>> u.configbool(s, 'unknown', True)
True
>>> u.setconfig(s, 'invalid', 'somevalue')
>>> u.configbool(s, 'invalid')
Traceback (most recent call last):
...
ConfigError: foo.invalid is not a boolean ('somevalue')
s%s.%s is not a boolean ('%s')N( RRORytboolR*t parseboolRIRJR(R!RgRqR|RuRWtb((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyRe�scCsp|j||d|�}|dkr(|Syt|�SWn3tk
rktjtd�|||f��nXdS(s
parse a configuration element as an integer
>>> u = ui(); s = 'foo'
>>> u.setconfig(s, 'int1', '42')
>>> u.configint(s, 'int1')
42
>>> u.setconfig(s, 'int2', '-42')
>>> u.configint(s, 'int2')
-42
>>> u.configint(s, 'unknown', 7)
7
>>> u.setconfig(s, 'invalid', 'somevalue')
>>> u.configint(s, 'invalid')
Traceback (most recent call last):
...
ConfigError: foo.invalid is not an integer ('somevalue')
s%s.%s is not an integer ('%s')N(RROtintt
ValueErrorRIRJR(R!RgRqR|RuRW((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyt configint�s
ic
Cs|j||�}}|d
krBt|t�s5|S|}}nd}tjd|tj�}|r�|j�\}} | j�} t dddddd�j
| d�}nytt|�|�SWn3t
k
r�tjtd �|||f��nXd
S(s�parse a configuration element as a quantity in bytes
Units can be specified as b (bytes), k or kb (kilobytes), m or
mb (megabytes), g or gb (gigabytes).
>>> u = ui(); s = 'foo'
>>> u.setconfig(s, 'val1', '42')
>>> u.configbytes(s, 'val1')
42
>>> u.setconfig(s, 'val2', '42.5 kb')
>>> u.configbytes(s, 'val2')
43520
>>> u.configbytes(s, 'unknown', '7 MB')
7340032
>>> u.setconfig(s, 'invalid', 'somevalue')
>>> u.configbytes(s, 'invalid')
Traceback (most recent call last):
...
ConfigError: foo.invalid is not a byte quantity ('somevalue')
is([^kmbg]+?)\s*([kmg]?)b?$RVitmitgi@s#%s.%s is not a byte quantity ('%s')N(RRORyRKtretmatchtIR\tlowertdictR{R�tfloatR�RIRJR(
R!RgRqR|RutorigtstringtmultipleR�tkey((s0/sys/lib/python2.7/site-packages/mercurial/ui.pytconfigbytes s
*
cs���fd����fd���fd��|j||d|�}|dkrf|p`g}nt|t�r��|jd��}|dkr�|p�g}q�n|S(sparse a configuration element as a list of comma/space separated
strings
>>> u = ui(); s = 'foo'
>>> u.setconfig(s, 'list1', 'this,is "a small" ,test')
>>> u.configlist(s, 'list1')
['this', 'is', 'a small', 'test']
c s$t}xF|t|�krN||j�s;||dkrNt}|d7}q W|t|�krnd||fS|r�|jd�n||dkr�|dr��||dfS||dkr�dddkr�dd |||d<�||dfS|dc||7<�||dfS(Nt,itt"i�s\(RtlentisspaceR ROtappend(tpartststoffsett
whitespace(t_parse_plaint_parse_quote(s0/sys/lib/python2.7/site-packages/mercurial/ui.pyR�:s5
$csN|t|�kr�||dkr�|jd�|d7}x@|t|�kr{||j�sn||dkr{|d7}q<W�||fSx�|t|�kr&||dkr&||dkr|dt|�kr||ddkr|d7}|dcd7<n|dc||7<|d7}q�W|t|�kr��|d�}|s\d|d<n)d|d|d<|d }|j|�d||fS|d7}x0|t|�kr�||d kr�|d7}q�W|t|�kr4|dt|�kr$||dkr$|dcd7<|d7}qA|jd�n
d||fS�||fS(
NR�R�iR�s\i�it (R�R�(R�R�R�textendRO(R�R�R�t
real_parts(t_configlistR�(s0/sys/lib/python2.7/site-packages/mercurial/ui.pyR�Ks@"
%
%&
%&
cs\|jd�}|sgS�dgd}}}x%|rW||||�\}}}q3W|S(Ns ,R�i(trstrip(R�tparserR�R�(R�(s0/sys/lib/python2.7/site-packages/mercurial/ui.pyR�vs Rus ,
N(RRORyt
basestringtlstrip(R!RgRqR|Rutresult((R�R�R�s0/sys/lib/python2.7/site-packages/mercurial/ui.pyRf0s
+ cCs||j|�kS(s&tell whether section exists in config.(Rv(R!RgRu((s0/sys/lib/python2.7/site-packages/mercurial/ui.pythas_section�scCs�|j|�j|�}|jr�|r�|jr�x[|jj|�D]D\}}|jj||�|krD|jd|||f�qDqDWn|S(Ns3ignoring untrusted configuration option %s.%s = %s
(RvRMRR
RR
R{R;(R!RgRuRMRVRW((s0/sys/lib/python2.7/site-packages/mercurial/ui.pytconfigitems�s ccs[|j|�}xE|j�D]7}x.|j||�D]\}}|||fVq5WqWdS(N(RvR9R�(R!RuRSRgRqRr((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyt
walkconfig�scCs`dtjkr"dtjkr"tStjjdd�j�jd�}|r\|r\||kStS(s'is plain mode active?
Plain mode means that all configuration variables which affect
the behavior and output of Mercurial should be
ignored. Additionally, the output should be stable,
reproducible and suitable for use in scripts or applications.
The only way to trigger plain mode is by setting either the
`HGPLAIN' or `HGPLAINEXCEPT' environment variables.
The return value can either be
- False if HGPLAIN is not set, or feature is in HGPLAINEXCEPT
- True otherwise
tHGPLAINt
HGPLAINEXCEPTR�R�(RRRR{tstriptsplitR (R!tfeaturet
exceptions((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyRL�s$
cCshtjjd�}|d
krT|jdd�}|d
k rTtjj|�}qTn|d
krutjjd�}n|d
kr�|jdd�r�|jt d�dd
�}n|d
kr|j
�ry7dtj�t
j�f}|jt d �|�Wqtk
rqXn|s6tjt d
���nd|krdtjt d�t|���n|S(sAReturn default username to be used in commits.
Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL
and stop searching if one of these is set.
If not found and ui.askusername is True, ask the user, else use
($LOGNAME or $USER or $LNAME or $USERNAME) + "@full.hostname".
tHGUSERRR-tEMAILtaskusernamesenter a commit username:R|s%s@%ss&no username found, using '%s' instead
s+no username supplied (see "hg help config")s
susername %s contains a newline
N(RRR{RORRPt
expandvarsRetpromptRtinteractiveR*tgetusertsockettgetfqdnR1tKeyErrortAborttrepr(R!R6((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyR-�s(
"cCs|jstj|�}n|S(s>Return a short representation of a user name or email address.(RR*t shortuser(R!R6((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyR��s cCsxtj|�s0tjjtjj|d��r4|S|jd|�}|rn|dk rn|jd|�}n|pw|S(s:Return repository location relative to cwd or from [paths]s.hgRXN(R*RaRRPtisdirRdRRO(R!tlocR|RP((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyR`�s0cCs|jjg�dS(N(RR�(R!((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyt
pushbuffer�scCsdj|jj��S(s�pop the last buffer and return the buffered output
If labeled is True, any labels associated with buffered
output will be handled. By default, this has no effect
on the output returned, but extensions and GUI tools may
handle this argument and returned styled output. If output
is being buffered so it can be captured and parsed or
processed, labeled should not be set to True.
R�(RdRtpop(R!tlabeled((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyt popbuffer�s
cOsd|jr9|jdjg|D]}t|�^q�n'x$|D]}|jjt|��q@WdS(s�write args to output
By default, this method simply writes to the buffer or stdout,
but extensions or GUI tools may override this method,
write_err(), popbuffer(), and label() to style output from
various parts of hg.
An optional keyword argument, "label", can be passed in.
This should be a string containing label names separated by
space. Label names take the form of "topic.type". For example,
ui.debug() issues a label of "ui.debug".
When labeling output for a specific command, a label of
"cmdname.type" is recommended. For example, status issues
a label of "status.modified" for modified files.
i�N(RR�RKRtwrite(R!targsR(ta((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyR��s 0
cOs�yut|jdt�s(|jj�nx$|D]}|jjt|��q/Wt|jdt�st|jj�nWn:tk
r�}|jtj tj
tjfkr��q�nXdS(Ntclosed(tgetattrRRtflushRR�RKRFterrnotEPIPEtEIOtEBADF(R!R�R(R�RU((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyt write_errs
!cCsZy|jj�Wnttfk
r*nXy|jj�Wnttfk
rUnXdS(N(RR�RFR�R(R!((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyR�scCs&|jddt�rtStj|�S(NRtnontty(ReRR*tisatty(R!tfh((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyt_isattyscCs5|jddd�}|dkr1|j|j�S|S(s-is interactive input allowed?
An interactive session is a session where input can be reasonably read
from `sys.stdin'. If this function returns false, any attempt to read
from stdin should fail with an error, unless a sensible default has been
specified.
Interactiveness is triggered by the value of the `ui.interactive'
configuration variable or - if it is unset - when `sys.stdin' points
to a terminal device.
This function refers to input only; for output, see `ui.formatted()'.
RR�N(ReROR�R(R!ti((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyR�scCsEdtjkr;yttjd�SWq;tk
r7q;Xntj�S(s-how wide is the terminal in columns?
tCOLUMNS(RRR�R�R*t termwidth(R!((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyR�3s
cCsE|j�rtS|jddd�}|dkrA|j|j�S|S(s*should formatted output be used?
It is often desirable to format the output to suite the output medium.
Examples of this are truncating long lines or colorizing messages.
However, this is not often not desirable when piping output into other
utilities, e.g. `grep'.
Formatted output is triggered by the value of the `ui.formatted'
configuration variable or - if it is unset - when `sys.stdout' points
to a terminal device. Please note that `ui.formatted' should be
considered an implementation detail; it is not intended for use outside
Mercurial or its extensions.
This function refers to output only; for input, see `ui.interactive()'.
This function always returns false when in plain mode, see `ui.plain()'.
Rt formattedN(RLRReROR�R(R!R�((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyR�=sR�cCs�|j|j�r@yddl}|jWq@tk
r<q@Xn|j|�tj}tj}|jt_|j t_t
d�}|t_|t_tjdkr�|r�|ddkr�|d }n|S(Ni�R�s
s
(
R�Rtreadlinetread_history_filet ExceptionR�RRRRt raw_inputRtlinesep(R!R�R�toldintoldouttline((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyt _readlineYs"
%
tycCs�|j�s&|j|d|d�|Sy-|j|j|d��}|sN|S|SWn&tk
r{tjtd���nXdS(shPrompt user with msg, read response.
If ui is not interactive, the default is returned.
R�s
s ui.promptsresponse expectedN(R�R�R�tlabeltEOFErrorR*R�R(R!tmsgR|tr((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyR�ys
cCs�g|D]#}||jd�dj�^q}xXtr�|j|||�}|j�|krt|j|j��S|jtd��q3WdS(sVPrompt user with msg, read response, and ensure it matches
one of the provided choices. The index of the choice is returned.
choices is a sequence of acceptable responses with the format:
('&None', 'E&xec', 'Sym&link') Responses are case insensitive.
If ui is not interactive, the default is returned.
t&isunrecognized response
N(tindexR�R R�R�R(R!R�tchoicesR|R�trespsR�((s0/sys/lib/python2.7/site-packages/mercurial/ui.pytpromptchoice�s0 cCss|j�s|Sy6|j|j|p.td�d��tjd�SWn&tk
rntjtd���nXdS(Ns
password: s ui.promptR�sresponse expected(R�R�R�RtgetpassR�R*R�(R!R�R|((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyR��s%
cOs:|js6|jdd�d|d<|j||�ndS(sqwrite status message to output (if ui.quiet is False)
This adds an output label of "ui.status".
R�R�s
ui.statusN(RR{R�(R!R�R(((s0/sys/lib/python2.7/site-packages/mercurial/ui.pytstatus�s cOs.|jdd�d|d<|j||�dS(sewrite warning message to output (stderr)
This adds an output label of "ui.warning".
R�R�s ui.warningN(R{R�(R!R�R(((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyR1�scOs:|jr6|jdd�d|d<|j||�ndS(sfwrite note to output (if ui.verbose is True)
This adds an output label of "ui.note".
R�R�s ui.noteN(RR{R�(R!R�R(((s0/sys/lib/python2.7/site-packages/mercurial/ui.pytnote�s cOs:|jr6|jdd�d|d<|j||�ndS(srwrite debug message to output (if ui.debugflag is True)
This adds an output label of "ui.debug".
R�R�s ui.debugN(RR{R�(R!R�R(((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyR;�s c
Cs�tjdddddt�\}}z�tj|d�}|j|�|j�|j�}tj d||fdi|d 6d
tj
dtd�d
|j�t
|�}|j�}|j�Wdtj|�X|S(Ntprefixs
hg-editor-tsuffixs.txtttexttws%s "%s"RR�tonerrt errprefixsedit failedtout(ttempfiletmkstempR RtfdopenR�RHt geteditorR*tsystemR�RRRERGtunlink(R!R�R6tfdRqR#teditortt((s0/sys/lib/python2.7/site-packages/mercurial/ui.pytedit�s
cCs�|js|r�d kr*tj�}nt|ddd �}|d k r�tj|d�}tj|d�}tj|d|d�}|jddj |d �dj |�dj |��q�j
|d|d|dd|j�n|jp�S(
s�print exception traceback if traceback printing enabled or forced.
only to call in exception handler. returns true if traceback
printed.itcauseiis#Traceback (most recent call last):
R�i�tfileN(RRORtexc_infoR�R@t format_tbtformat_exception_onlyR�Rdtprint_exceptionR(R!texctforceRtcausetbtexctbtexconly((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyR@�s
cCsgtjdkrd}nd}tjjd�pf|jdd�pftjjd�pftjjd|�S( sreturn editor to usetplan9tEtvitHGEDITORRR�tVISUALtEDITOR(RtplatformRRR{R(R!R�((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyR��s c Cs�|dks|jrdS|r-d|}n|r@d|}n|rzd||}|jd||||||f�n|jd||||f�dS(sxshow a progress message
With stock hg, this is simply a debug message that is hidden
by default, but with extensions or GUI tools it may be
visible. 'topic' is the current operation, 'item' is a
non-numeric marker of the current position (i.e. the currently
in-process file), 'pos' is the current numeric position (i.e.
revision, bytes, etc.), unit is a corresponding unit label,
and total is the highest expected pos.
Multiple nested topics may be active at a time.
All topics should be marked closed by setting pos to None at
termination.
NR�gY@s%s:%s %s/%s%s (%4.2f%%)
s%s:%s %s%s
(RORR;(R!R'tposRltunitttotaltpct((s0/sys/lib/python2.7/site-packages/mercurial/ui.pytprogress�s
cOsdS(s�hook for logging facility extensions
service should be a readily-identifiable subsystem, which will
allow filtering.
message should be a newline-terminated string to log.
N((R!tserviceR�R(((s0/sys/lib/python2.7/site-packages/mercurial/ui.pytlogscCs|S(s%style msg based on supplied label
Like ui.write(), this just returns msg unchanged, but extensions
and GUI tools can override it to allow styling output without
writing it.
ui.write(s, 'label') is equivalent to
ui.write(ui.label(s, 'label')).
((R!R�R�((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyR�#s
N(4t__name__t
__module__ROR$RR&R8RR RRmRpR RtRvR^RR�ReR�R�RfR�R�R�RLR-R�R`R�R�R�R�R�R�R�R�R�R�R�R�R�R�R1R�R;RR@R�RRR�(((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyRs`# *" 'X
(ti18nRR�R�RR�R�RR�R@RRR*RIR&tobjectR(((s0/sys/lib/python2.7/site-packages/mercurial/ui.pyt<module>s`<
|