��c@s�ddlZddlZddlZddlZddlmZd�Zd�Zdefd��YZ de fd��YZ
d e fd
��YZde fd��YZd
�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS(i�N(t_cCs6tj|�}y|jSWntk
r1|jSXdS(N(tutilt compileret
test_matchtAttributeErrortmatch(tpattm((s3/sys/lib/python2.7/site-packages/mercurial/match.pyt
_rematchers
cCs�t�}g}xp|D]h\}}|dkrk|sFtjd��ntj||�}|j|�qn|j||f�qW||fS(s?convert set: patterns into a list of files in the given contexttsets"fileset expression with no context(R RtAborttfilesett
getfilesettupdatetappend(tpatstctxtfsettothertkindtexprts((s3/sys/lib/python2.7/site-packages/mercurial/match.pyt_expandsetss
RcBs}eZggdeddd�Zd�Zd�Zd�Zd�Zd�Z d�Z
d�Zd �Zd
�Z
d�ZRS(
tglobc
s5||_||_g|_t|p'|�|_| |_t|_|r~t|d|||�}
t | |
d�\|_
�n|r�t|d|||�}
t | |
d�\|_�n|r�|t
�r�||_nt
|�|_|j�nc|rYt|||||�}
t|
�|_|jp5t|
�|_t | |
d�\|_�n|se|r�|r�|r����fd�}q���fd�}q|r���fd�}q�}nT|r�r��fd�}q�}n*|r�fd�}nd �}t|_||_t|j�|_d
S(s�build an object to match a set of file patterns
arguments:
root - the canonical root of the tree you're matching against
cwd - the current working directory, if relevant
patterns - patterns to find
include - patterns to include
exclude - patterns to exclude
default - if a pattern in names has no explicit type, assume this one
exact - patterns are actually literals
a pattern is one of:
'glob:<glob>' - a glob relative to cwd
're:<regexp>' - a regular expression
'path:<path>' - a path relative to repository root
'relglob:<glob>' - an unrooted glob (*.c matches C files in all dirs)
'relpath:<path>' - a path relative to cwd
'relre:<regexp>' - a regexp that needn't match the start of a name
'set:<fileset>' - a fileset expression
'<something>' - a pattern of the specified default type
Rs(?:/|$)t$cs#�|�o"�|�o"�|�S(N((tf(temtimtpm(s3/sys/lib/python2.7/site-packages/mercurial/match.pyt<lambda>Xscs�|�o�|�S(N((R(RR(s3/sys/lib/python2.7/site-packages/mercurial/match.pyRZscs�|�o�|�S(N((R(RR(s3/sys/lib/python2.7/site-packages/mercurial/match.pyR]scs�|�o�|�S(N((R(RR(s3/sys/lib/python2.7/site-packages/mercurial/match.pyRcscs�|�S(N((R(R(s3/sys/lib/python2.7/site-packages/mercurial/match.pyRhscSstS(N(tTrue(R((s3/sys/lib/python2.7/site-packages/mercurial/match.pyRjsN(t_roott_cwdt_filestboolt_anypatst_ctxtFalset_alwayst
_normalizet_buildmatcht
includepatt
excludepatt
isinstancetlisttexactt_rootstpatternspatRtmatchfnR t_fmap(tselftroottcwdtpatternstincludetexcludetdefaultR-tauditorRRR((RRRs3/sys/lib/python2.7/site-packages/mercurial/match.pyt__init__$sP cCs
|j|�S(N(R0(R2tfn((s3/sys/lib/python2.7/site-packages/mercurial/match.pyt__call__psccsx|jD]}|Vq
WdS(N(R!(R2R((s3/sys/lib/python2.7/site-packages/mercurial/match.pyt__iter__rscCsdS(sdcallback for each explicit file that can't be
found/accessed, with an error message
N((R2Rtmsg((s3/sys/lib/python2.7/site-packages/mercurial/match.pytbaduscCsdS(N((R2R((s3/sys/lib/python2.7/site-packages/mercurial/match.pytdirzscCsdS(N((R2R((s3/sys/lib/python2.7/site-packages/mercurial/match.pytmissing|scCs
||jkS(N(R1(R2R((s3/sys/lib/python2.7/site-packages/mercurial/match.pyR-~scCstj|j|j|�S(N(RtpathtoRR (R2R((s3/sys/lib/python2.7/site-packages/mercurial/match.pytrel�scCs|jS(N(R!(R2((s3/sys/lib/python2.7/site-packages/mercurial/match.pytfiles�scCs|jS(N(R#(R2((s3/sys/lib/python2.7/site-packages/mercurial/match.pytanypats�scCs|jS(N(R&(R2((s3/sys/lib/python2.7/site-packages/mercurial/match.pytalways�sN(t__name__t
__module__R%tNoneR:R<R=R?R@RAR-RCRDRERF(((s3/sys/lib/python2.7/site-packages/mercurial/match.pyR#sK R-cBseZd�ZRS(cCs tj||||dt�dS(NR-(RR:R(R2R3R4RD((s3/sys/lib/python2.7/site-packages/mercurial/match.pyR:�s(RGRHR:(((s3/sys/lib/python2.7/site-packages/mercurial/match.pyR-�sRFcBseZd�ZRS(cCs#tj|||g�t|_dS(N(RR:RR&(R2R3R4((s3/sys/lib/python2.7/site-packages/mercurial/match.pyR:�s(RGRHR:(((s3/sys/lib/python2.7/site-packages/mercurial/match.pyRF�st
narrowmatchercBs eZdZd�Zd�ZRS(sqAdapt a matcher to work on a subdirectory only.
The paths are remapped to remove/insert the path as needed:
>>> m1 = match('root', '', ['a.txt', 'sub/b.txt'])
>>> m2 = narrowmatcher('sub', m1)
>>> bool(m2('a.txt'))
False
>>> bool(m2('b.txt'))
True
>>> bool(m2.matchfn('a.txt'))
False
>>> bool(m2.matchfn('b.txt'))
True
>>> m2.files()
['b.txt']
>>> m2.exact('b.txt')
True
>>> m2.rel('b.txt')
'b.txt'
>>> def bad(f, msg):
... print "%s: %s" % (f, msg)
>>> m1.bad = bad
>>> m2.bad('x.txt', 'No such file')
sub/x.txt: No such file
cs��j�_�j�_|�_��_�j�_g�jD]-}|j|d�r@|t|�d^q@�_�j�_��fd��_ t
�j��_dS(Nt/ics�j�jd|�S(NRK(R0t_path(R;(tmatcherR2(s3/sys/lib/python2.7/site-packages/mercurial/match.pyR�s(RR RLt_matcherR&R!t
startswithtlenR#R0R R1(R2tpathRMR((RMR2s3/sys/lib/python2.7/site-packages/mercurial/match.pyR:�s 0cCs"|jj|jd||�dS(NRK(RNR?RL(R2RR>((s3/sys/lib/python2.7/site-packages/mercurial/match.pyR?�s(RGRHt__doc__R:R?(((s3/sys/lib/python2.7/site-packages/mercurial/match.pyRJ�s
cCst|d�dS(Ni(t _patsplitRI(R((s3/sys/lib/python2.7/site-packages/mercurial/match.pytpatkind�sc
CsGd|kr=|jdd�\}}|dkr=||fSn||fS(
sOSplit a string into an optional pattern kind prefix and the
actual pattern.t:itreRRQtrelglobtrelpathtrelretlistfilet listfile0R ( sresglobspathRWsrelpathRYRZR[sset(tsplit(RR8Rtval((s3/sys/lib/python2.7/site-packages/mercurial/match.pyRS�s
c s�dt����d}d}tj}���fd�}xV��kr���}�d7�|dkr|||�7}q@|dkr�|�dkr��d7�|d7}q�|d7}q@|d kr�|d
7}q@|dkr��}|�kr�|dkr|d7}nx*|�kr>�|d
kr>|d7}qW|�krX|d7}q���|!jdd�}|d�|ddkr�d|d}n|ddkr�d|}nd||f}q@|dkr�d7}|d7}q@|dkr|r|d7}|d8}q@|dkr7|r7|d7}q@|dkr�|�}|ro�d7�|||�7}q�|||�7}q@|||�7}q@W|S(s$convert a glob pattern into a regexpitcs��ko��S(N(((titnR(s3/sys/lib/python2.7/site-packages/mercurial/match.pytpeek�sis*?[{},\t*s.*s[^/]*t?t.t[s!]t]s\[s\s\\t!t^s%s[%s]t{s(?:t}t)t,t|(RPRVtescapetreplace( RtrestgroupRnRatctjtstufftp((R_R`Rs3/sys/lib/python2.7/site-packages/mercurial/match.pyt_globre�s`
cCs�|s
dS|dkr|S|dkr;dtj|�dS|dkrYdt|�|S|dkrvtj|�dS|d kr�|jd�r�|Sd
|St|�|S(s+convert a pattern into a regular expressionR^RVRQRhs(?:/|$)RWs(?:|.*/)RXRYs.*(RVRnRvRO(Rtnamettail((s3/sys/lib/python2.7/site-packages/mercurial/match.pyt_regexscsct||�\�}|s(d�jfSt||�\}��rY|��fd�fS|�fS(NR^cs|�kp�|�S(N((R(Rtmf(s3/sys/lib/python2.7/site-packages/mercurial/match.pyRs(Rt__contains__t_buildregexmatch(RRRxR((RRzs3/sys/lib/python2.7/site-packages/mercurial/match.pyR(s
cs}ygddjg|D]\}}t|||�^q�}t|�dkrVt�n|t|�fSWntk
r�t|�}|dkr��nt||d |�\}�t||d|�\}�|��fd�fStjk
rxxh|D]`\}}ytdt|||��Wq�jk
r[tj t
d�||f��q��j t
d���nXdS( s0build a matching function from a set of patternss(?:%s)Rmi Nics�|�p�|�S(N((R(tatb(s3/sys/lib/python2.7/site-packages/mercurial/match.pyR/ssinvalid pattern (%s): %ssinvalid patternN(tjoinRyRPt
OverflowErrorRR|RVterrorRR
R(RRxtkRuRtltpatatpatb((R}R~s3/sys/lib/python2.7/site-packages/mercurial/match.pyR|s&8
'cCsLg}x?g|D]}t||�^qD]\}}|d kr\tj||||�}n�|d
krztj|�}n�|dkr1y\tj|�} |dkr�| jd�} n| j�} g| D]}
|
r�|
^q�} Wn*tk
rtj t
d�|��nX|t| ||||�7}q)n|j||f�q)W|S(NRRXRWRQRZR[tsunable to read file list (%s)(sglobsrelpath(srelglobspath(slistfiles listfile0(
RStscmutilt canonpathRtnormpathtreadfileR\t
splitlinestEnvironmentErrorR
RR'R(tnamesR8R3R4R9RRuRRwRDR((s3/sys/lib/python2.7/site-packages/mercurial/match.pyR'8s&/#
cCs�g}x�|D]�\}}|dkr�g}xX|jd�D]G}d|ksqd|ksqd|ksqd|kruPn|j|�q;W|jdj|�p�d�q
|d
kr�|j|p�d�q
|jd�q
W|S(NRRKReRiRbRcRdRXRQ(srelpathspath(R\RR(R5trRRwR3Ru((s3/sys/lib/python2.7/site-packages/mercurial/match.pyR.Os0cCs+x$|D]\}}|dkrtSqWdS(NRRVRWRYR (sglobsresrelglobsrelresset(R(R5RRw((s3/sys/lib/python2.7/site-packages/mercurial/match.pyR#_s(RVR�RRti18nRRRtobjectRR-RFRJRTRSRvRyR(R|R'R.R#(((s3/sys/lib/python2.7/site-packages/mercurial/match.pyt<module>s"$ f,
8
|