\x89\x50\x4E\x47\x0D\x0A\x1A\x0A PNG  \x89\x50\x4E\x47\x0D\x0A\x1A\x0A  13\c@@sddlmZmZddlmZddlmZmZmZddl m Z de fdYZ dZ d Zd Zd Zd Zd ZdZdZdZdddZdZde fdYZde fdYZdS(i(tabsolute_importtprint_functioni(t_(terrortpycompattutil(t stringutiltparsercB@sbeZd dZdZdZdZd dZddZdZ dZ d Z RS( cC@s||_||_d|_dS(N(t _elementst_methodstNonetcurrent(tselftelementstmethods((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pyt__init__ s  cC@s"|j}t|jd|_|S(sadvance the tokenizerN(R tnextt_iterR (R tt((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pyt_advance$s cC@st|j|jddd!S(s%True if next token may start new termiii(tanyRR (R ((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pyt _hasnewterm)scC@sN|jd|kr@tjtd|jd|jdn|jdS(s0make sure the tokenizer matches an end conditionisunexpected token: %siN(R Rt ParseErrorRR(R tm((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pyt_match,scC@sK|r"|jd|kr"d}n|j|}|rG|j|n|S(sDgather right-hand-side operand until an end condition or binding metiN(R R t_parseR(R tbindRtexpr((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pyt _parseoperand2s  ic C@s[|j\}}}|j|dd!\}}|rW|oD|j rW||f}nB|r}|d|j|df}ntjtd||x||j|jddkrV|j\}}}|j|d\}} | r|o|j r| |f}q|r7|d||j|df}qtjtd||qW|S(Niiisnot a prefix: %ssnot an infix: %s(RRRRRRRR ( R RttokentvaluetpostprimarytprefixRtinfixtsuffix((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pyR;s  !# cC@s;||_|j|j}|j\}}}||fS(s!generate a parse tree from tokens(RRRR (R t tokenitertresRRR((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pytparseQs    cC@sHt|ts|S|j|dg|dD]}|j|^q,S(s4recursively evaluate a parse tree using node methodsii(t isinstancettupleR teval(R ttreeR((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pyR)XscC@s)|j|}|jr%|j|S|S(s<parse tokens into a parse tree and evaluate if methods given(R&R R)(R R$R((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pyt__call__]s  N( t__name__t __module__R RRRRRRR&R)R+(((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pyRs       cC@sd}|jd\}}}|ry|j}|sHtjdnt|dkrltjdn|d}n|jd\}}}|j}|j}|r|stjdn||d|d|fSgd||fS( sParse spec of function arguments into (poskeys, varkey, keys, optkey) >>> splitargspec(b'') ([], None, [], None) >>> splitargspec(b'foo bar') ([], None, ['foo', 'bar'], None) >>> splitargspec(b'foo *bar baz **qux') (['foo'], 'bar', ['baz'], 'qux') >>> splitargspec(b'*foo') ([], 'foo', [], None) >>> splitargspec(b'**foo') ([], None, [], 'foo') s**sno **optkey name providedis!excessive **optkey names providedit*sno *varkey name providedN(R t partitiontsplitRtProgrammingErrortlen(tspectoptkeytpretseptposttpoststpres((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pyt splitargspecds"    c@s|\}}}}tfdt|Dt|} | t|krtjtdi|d6t|d6n| r| t|t|krtjtdi|d6t|t|d6ntj} x+t||| D]\} } | | | ss6%(func)s takes at least %(nargs)d positional argumentstfunctnargss5%(func)s takes at most %(nargs)d positional argumentsiis %(func)s got an invalid arguments5%(func)s got an unexpected keyword argument '%(key)s'tkeys;%(func)s got multiple values for keyword argument '%(key)s'i( Rt enumerateR2RRRRtsortdicttzip(ttreestfuncnametargspecR>tkeynodetposkeystvarkeytkeysR4tkwstarttargstkR=td((R>s6/usr/lib64/python2.7/site-packages/mercurial/parser.pyt buildargsdictsF!# !  )$    cC@sIytj|SWn1tk rD}tjtj|jnXdS(N(Rt unescapestrt ValueErrorRRRtbytestrtlower(tste((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pyRQscC@st|ts.|j|tj|fn|d|krttj|d}|j|d|ddj|ffnn|j|d|dfx)|dD]}t|||d|qW|dd|dddfg|d)dS(Niis(%s %s)t s(%sit)(R'R(tappendRtpprinttmaptjoint _prettyformat(R*t leafnodestleveltlinestrsRU((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pyR]s-cC@s6g}t||d|djd|D}|S(Nis cs@s#|]\}}d||VqdS(s N((R;tlRU((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pys s(R]R\(R*R^R`toutput((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pyt prettyformatsc@st|ts|S|d}|krN|ftfd|dDSg}|}x@|d|kr|d\}}|jt||}q]W|jt||j|tt|S(s_Flatten chained infix operations to reduce usage of Python stack >>> from . import pycompat >>> def f(tree): ... s = prettyformat(simplifyinfixops(tree, (b'or',)), (b'symbol',)) ... print(pycompat.sysstr(s)) >>> f((b'or', ... (b'or', ... (b'symbol', b'1'), ... (b'symbol', b'2')), ... (b'symbol', b'3'))) (or (symbol '1') (symbol '2') (symbol '3')) >>> f((b'func', ... (b'symbol', b'p1'), ... (b'or', ... (b'or', ... (b'func', ... (b'symbol', b'sort'), ... (b'list', ... (b'or', ... (b'or', ... (b'symbol', b'1'), ... (b'symbol', b'2')), ... (b'symbol', b'3')), ... (b'negate', ... (b'symbol', b'rev')))), ... (b'and', ... (b'symbol', b'4'), ... (b'group', ... (b'or', ... (b'or', ... (b'symbol', b'5'), ... (b'symbol', b'6')), ... (b'symbol', b'7'))))), ... (b'symbol', b'8')))) (func (symbol 'p1') (or (func (symbol 'sort') (list (or (symbol '1') (symbol '2') (symbol '3')) (negate (symbol 'rev')))) (and (symbol '4') (group (or (symbol '5') (symbol '6') (symbol '7')))) (symbol '8'))) ic3@s|]}t|VqdS(N(tsimplifyinfixops(R;R=(t targetnodes(s6/usr/lib64/python2.7/site-packages/mercurial/parser.pys si(R'R(RYRetreversed(R*Rftopt simplifiedR=Rbtr((Rfs6/usr/lib64/python2.7/site-packages/mercurial/parser.pyRes<  %  c@sF|krjSt|ts)|Stfd|DS(Nc3@s!|]}t|VqdS(N(t _buildtree(R;R=(t placeholdert replstack(s6/usr/lib64/python2.7/site-packages/mercurial/parser.pys .s(tpopR'R((ttemplateRlRm((RlRms6/usr/lib64/python2.7/site-packages/mercurial/parser.pyRk)s   cG@sat|ts!tjdntt|}t|||}|r]tjdn|S(sCreate new tree by substituting placeholders by replacements >>> _ = (b'symbol', b'_') >>> def f(template, *repls): ... return buildtree(template, _, *repls) >>> f((b'func', (b'symbol', b'only'), (b'list', _, _)), ... ('symbol', '1'), ('symbol', '2')) ('func', ('symbol', 'only'), ('list', ('symbol', '1'), ('symbol', '2'))) >>> f((b'and', _, (b'not', _)), (b'symbol', b'1'), (b'symbol', b'2')) ('and', ('symbol', '1'), ('not', ('symbol', '2'))) s placeholder must be a node tuplestoo many replacements(R'R(RR1tlistRgRk(RoRltreplsRmRj((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pyt buildtree0s c@s||krtSt|t s0t|t r4tS|kra|dkraj|tSt|t|kr}tStfdt||DS(Nic3@s-|]#\}}t||VqdS(N(t _matchtree(R;tpR=(tincompletenodestmatchesRl(s6/usr/lib64/python2.7/site-packages/mercurial/parser.pys Ns(tTrueR'R(tFalseRYR2tallRD(tpatternR*RlRuRv((RuRvRls6/usr/lib64/python2.7/site-packages/mercurial/parser.pyRsDs   cC@sW|dk r.t|t r.tjdn|g}t|||||rS|SdS(s If a tree matches the pattern, return a list of the tree and nodes matched with the placeholder; Otherwise None >>> def f(pattern, tree): ... m = matchtree(pattern, tree, _, {b'keyvalue', b'list'}) ... if m: ... return m[1:] >>> _ = (b'symbol', b'_') >>> f((b'func', (b'symbol', b'ancestors'), _), ... (b'func', (b'symbol', b'ancestors'), (b'symbol', b'1'))) [('symbol', '1')] >>> f((b'func', (b'symbol', b'ancestors'), _), ... (b'func', (b'symbol', b'ancestors'), None)) >>> f((b'range', (b'dagrange', _, _), _), ... (b'range', ... (b'dagrange', (b'symbol', b'1'), (b'symbol', b'2')), ... (b'symbol', b'3'))) [('symbol', '1'), ('symbol', '2'), ('symbol', '3')] The placeholder does not match the specified incomplete nodes because an incomplete node (e.g. argument list) cannot construct an expression. >>> f((b'func', (b'symbol', b'ancestors'), _), ... (b'func', (b'symbol', b'ancestors'), ... (b'list', (b'symbol', b'1'), (b'symbol', b'2')))) The placeholder may be omitted, but which shouldn't match a None node. >>> _ = None >>> f((b'func', (b'symbol', b'ancestors'), None), ... (b'func', (b'symbol', b'ancestors'), (b'symbol', b'0'))) s placeholder must be a node tupleN(R R'R(RR1Rs(RzR*RlRuRv((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pyt matchtreeQs " cC@sFt|jdkr7td|jd|jdfS|jdSdS(s;Compose error message from specified ParseError object is at %d: %siN(R2RMR(tinst((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pytparseerrordetailys"taliascB@seZdZdZRS(sParsed result of aliascC@s1||_||_||_||_t|_dS(N(tnameRMRt replacementRxtwarned(R RRMterrR((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pyRs     (R,R-t__doc__R(((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pyR~stbasealiasrulescB@seZdZdZdZdZedZedZ e dZ e dZ e dZ e dZe d Ze d Ze d Ze d Ze d ZRS(swParsing and expansion rule set of aliases This is a helper for fileset/revset/template aliases. A concrete rule set should be made by sub-classing this and implementing class/static methods. It supports alias expansion of symbol and function-call styles:: # decl = defn h = heads(default) b($1) = ancestors($1) - ancestors(default) tsymbolcC@std|jdS(Ns'%s' is not instantiatable(t TypeErrorR,(tcls((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pyt__new__scC@s tdS(s-Parse an alias name, arguments and definitionN(tNotImplementedError(R3((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pyRscC@s tdS(s9Return (name, args) if tree is a function; otherwise NoneN(R(R*((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pyt _trygetfuncsc@sjyj|}Wn&tjk r;}|d t|fSX|djkr|d}|jdr|d td|fS|d d fSj|}|rW|\}}|jdr|d td|fSt fd|Dr|d tdfSt |t t |kr3|d tdfS|g|D]}|d^q=d fS|d td fS( s Parse an alias declaration into ``(name, args, errorstr)`` This function analyzes the parsed tree. The parsing rule is provided by ``_parse()``. - ``name``: of declared alias (may be ``decl`` itself at error) - ``args``: list of argument names (or None for symbol declaration) - ``errorstr``: detail about detected error (or None) >>> sym = lambda x: (b'symbol', x) >>> symlist = lambda *xs: (b'list',) + tuple(sym(x) for x in xs) >>> func = lambda n, a: (b'func', sym(n), a) >>> parsemap = { ... b'foo': sym(b'foo'), ... b'$foo': sym(b'$foo'), ... b'foo::bar': (b'dagrange', sym(b'foo'), sym(b'bar')), ... b'foo()': func(b'foo', None), ... b'$foo()': func(b'$foo', None), ... b'foo($1, $2)': func(b'foo', symlist(b'$1', b'$2')), ... b'foo(bar_bar, baz.baz)': ... func(b'foo', symlist(b'bar_bar', b'baz.baz')), ... b'foo(bar($1, $2))': ... func(b'foo', func(b'bar', symlist(b'$1', b'$2'))), ... b'foo($1, $2, nested($1, $2))': ... func(b'foo', (symlist(b'$1', b'$2') + ... (func(b'nested', symlist(b'$1', b'$2')),))), ... b'foo("bar")': func(b'foo', (b'string', b'bar')), ... b'foo($1, $2': error.ParseError(b'unexpected token: end', 10), ... b'foo("bar': error.ParseError(b'unterminated string', 5), ... b'foo($1, $2, $1)': func(b'foo', symlist(b'$1', b'$2', b'$1')), ... } >>> def parse(expr): ... x = parsemap[expr] ... if isinstance(x, Exception): ... raise x ... return x >>> def trygetfunc(tree): ... if not tree or tree[0] != b'func' or tree[1][0] != b'symbol': ... return None ... if not tree[2]: ... return tree[1][1], [] ... if tree[2][0] == b'list': ... return tree[1][1], list(tree[2][1:]) ... return tree[1][1], [tree[2]] >>> class aliasrules(basealiasrules): ... _parse = staticmethod(parse) ... _trygetfunc = staticmethod(trygetfunc) >>> builddecl = aliasrules._builddecl >>> builddecl(b'foo') ('foo', None, None) >>> builddecl(b'$foo') ('$foo', None, "invalid symbol '$foo'") >>> builddecl(b'foo::bar') ('foo::bar', None, 'invalid format') >>> builddecl(b'foo()') ('foo', [], None) >>> builddecl(b'$foo()') ('$foo()', None, "invalid function '$foo'") >>> builddecl(b'foo($1, $2)') ('foo', ['$1', '$2'], None) >>> builddecl(b'foo(bar_bar, baz.baz)') ('foo', ['bar_bar', 'baz.baz'], None) >>> builddecl(b'foo($1, $2, nested($1, $2))') ('foo($1, $2, nested($1, $2))', None, 'invalid argument list') >>> builddecl(b'foo(bar($1, $2))') ('foo(bar($1, $2))', None, 'invalid argument list') >>> builddecl(b'foo("bar")') ('foo("bar")', None, 'invalid argument list') >>> builddecl(b'foo($1, $2') ('foo($1, $2', None, 'at 10: unexpected token: end') >>> builddecl(b'foo("bar') ('foo("bar', None, 'at 5: unterminated string') >>> builddecl(b'foo($1, $2, $1)') ('foo', None, 'argument names collide with each other') iit$sinvalid symbol '%s'sinvalid function '%s'c3@s"|]}|djkVqdS(iN(t _symbolnode(R;R(R(s6/usr/lib64/python2.7/site-packages/mercurial/parser.pys ssinvalid argument lists&argument names collide with each othersinvalid formatN( RRRR R}Rt startswithRRRR2tset(RtdeclR*R|RR?RMR((Rs6/usr/lib64/python2.7/site-packages/mercurial/parser.pyt _builddecls(M   $c@st|ts|S|d}|jkrT|ftfd|dDSt|dkslt|d}|krd}n+|jdrtjtd|n||fS(s%Mark alias arguments as ``_aliasarg``ic3@s!|]}j|VqdS(N(t _relabelargs(R;R=(RMR(s6/usr/lib64/python2.7/site-packages/mercurial/parser.pys siit _aliasargRsinvalid symbol '%s'( R'R(RR2tAssertionErrorRRRR(RR*RMRhtsym((RMRs6/usr/lib64/python2.7/site-packages/mercurial/parser.pyRs (   cC@s=|j|}|r$t|}n t}|j||S(sParse an alias definition into a tree and marks substitutions This function marks alias argument references as ``_aliasarg``. The parsing rule is provided by ``_parse()``. ``args`` is a list of alias argument names, or None if the alias is declared as a symbol. >>> from . import pycompat >>> parsemap = { ... b'$1 or foo': (b'or', (b'symbol', b'$1'), (b'symbol', b'foo')), ... b'$1 or $bar': ... (b'or', (b'symbol', b'$1'), (b'symbol', b'$bar')), ... b'$10 or baz': ... (b'or', (b'symbol', b'$10'), (b'symbol', b'baz')), ... b'"$1" or "foo"': ... (b'or', (b'string', b'$1'), (b'string', b'foo')), ... } >>> class aliasrules(basealiasrules): ... _parse = staticmethod(parsemap.__getitem__) ... _trygetfunc = staticmethod(lambda x: None) >>> builddefn = aliasrules._builddefn >>> def pprint(tree): ... s = prettyformat(tree, (b'_aliasarg', b'string', b'symbol')) ... print(pycompat.sysstr(s)) >>> args = [b'$1', b'$2', b'foo'] >>> pprint(builddefn(b'$1 or foo', args)) (or (_aliasarg '$1') (_aliasarg 'foo')) >>> try: ... builddefn(b'$1 or $bar', args) ... except error.ParseError as inst: ... print(pycompat.sysstr(parseerrordetail(inst))) invalid symbol '$bar' >>> args = [b'$1', b'$10', b'foo'] >>> pprint(builddefn(b'$10 or baz', args)) (or (_aliasarg '$10') (symbol 'baz')) >>> pprint(builddefn(b'"$1" or "foo"', args)) (or (string '$1') (string 'foo')) (RRR(RtdefnRMR*((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pyt _builddefn$s / c C@sd}}|j|\}}}|r7td}nGy|j||}Wn.tjk r}}t|}td}nX|r|i|jd6|d6|d6}nt||||S(s>Parse an alias declaration and definition into an alias objects4bad declaration of %(section)s "%(name)s": %(error)ss3bad definition of %(section)s "%(name)s": %(error)stsectionRRN( R RRRRRR}t_sectionR~( RRRtrepltefmtRRMRR|((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pytbuildZs  %cC@s@i}x3|D]+\}}|j||}|||js(R'R((RR*RMR((RMRs6/usr/lib64/python2.7/site-packages/mercurial/parser.pyRs  c @st|ts|Sj|}|dkrTtfd|DS|\}}|jr~tj|jn|krtjtdijd6|j d6nj ||j krj |j |j ss5infinite expansion of %(section)s "%(name)s" detectedRRsinvalid number of arguments: %d(R'R(RR RtAbortRRRRRYRRRnRMR2RtdictRD( RRR*RRRjRRbtresultR((RRRRs6/usr/lib64/python2.7/site-packages/mercurial/parser.pyRs2     !   +cC@s|j||giS(sExpand aliases in tree, recursively. 'aliases' is a dictionary mapping user defined aliases to alias objects. (R(RRR*((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pytexpandsN(R,R-RR RRRt staticmethodRRt classmethodRRRRRRRRR(((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pyRs  g6  N((t __future__RRti18nRtRRRtutilsRtobjectRR:RPRQR]RdReRkRrRsR R{R}R~R(((s6/usr/lib64/python2.7/site-packages/mercurial/parser.pyts"E ! <   O   (