a +b]@s ddlmZddlZddlmZddlmZddlmZm Z m Z ddl m Z m Z mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z!m"Z"ddl#m$Z$m%Z%m&Z&ej'Z'ej(Z(ej)Z)ej*Z*ej+Z+ej,Z,ej-Z-ej.Z.ej/Z/ej0Z0ej1Z1ej2Z2e e fZ3d Z4d Z5d Z6e5fd d Z7ddZ8ddZ9ddZ:ddZ;ddZddZ?ddZ@d d!ZAd"d#ZBd$d%ZCd&d'ZDd(d)ZEd*d+ZFd,d-ZGd.d/ZHd0d1ZId2d3ZJd4d5ZKd6d7ZLd8d9ZMd:d;ZNdd?ZPejQZQeRZSeTZUeUd@dAdBZVeUdCdDdEZWeUdFdGdHdIdJdKZXeUdLdGdMdIdNdOZYddQdRZZeUdSdGdTdUdVZ[eUdWdGdTdXdYZ\dZd[Z]d\d]Z^eUd^dGd_dId`daZ_eUdbdGdTdcddZ`eUdedGdTdfdgZaeUdhdGdTdidjZbeUdkdGd_dIdldmZceUdndGdTdodpZdeUdqdGdTdrdsZedtduZfdvdwZgeUdxdGdTdydzZheUd{dGd_dId|d}ZieUd~dGdTddZjeUddGdTddZkeUddGdTddZleUddGdTddZmeUdddddZneUddGdTddZoeUddGd_dIddZpeUddGd_dIddZqdddZreUddGdTddZseUddGdTddZteUddGd_dIddZueUdddddZveUddGdTddZweUddGdGdddZxeUddPddIddZyeUddGdTddZzeUddGdTddZ{eUddGdTddZ|eUddGdGddddZ}dddZ~eUddGdTdd„ZeUddGdTddńZeUddGdTddȄZeUdɃdd˄ZeUddGdTdd΄ZeUdd_dddфZeUddGdTddԄZeUddGd_dIddׄZeUddGdTddڄZeUddGdGddd݄ZeUddGdTddZeUddGd_dIddZeUddGdGddddZeUddGdGdddZeUddGdTddZeUddGdTddZeUddGdTddZeUddGdTddZeUddGdHdIddZeUdddZddZeUddGdTddZeUddGdTddZeUddGdTddZeUddGdTdd ZeUd dGdTd d ZeUd dPd_dIddZeUddGdTddZeUddGdTddZddZeUddGdTddZddZeUddGdTddZeUd dGdTd!d"ZeUd#dGdTd$d%ZeUd&dGdTd'd(Z d)d*ZeUd+dGdGdd,d-ZeUd.dGdTd/d0ZeUd1dGdTd2d3ZeUd4dGdTd5d6ZeUd7dPdTd8d9ZeUd:dGdHdId;d<ZeUd=dGdTd>d?ZeUd@dGdTdAdBZeUdCdGdGddDdEZTeUdFdGdTdGdHZeUdIdGdGdddJdKZeUdLdGdTdMdNZejdOdPdQdPdRdPdSdPdTdPejdUZdVdWZeUdXdGdGd_ddYdZZeUd[d\d]Zd^d_ZeUd`dGdTdadbZddcddZeUdedGdTdfdgZeUdhdGdTdidjZeUdkdGdTdldmZeUdndGdTdodpZeUdqdGd_dIdrdsZeUdtdGddIdudvZdwdxZeUdydGdGddzd{Zd|d}ZeUd~dGdGddddZddZeUddGdGdddZee?eAe:e:eBeCeFeGeDeHeLeMeNeOePe^eee;dZeJeJdZeKeKdZÐddZĐdddZdddZŐddZƐddZeddeUeQȡZdS()absolute_importN)_getattr)binnullrevwdirrev)dagopdestutildiffutilencodingerrorgrephbisectmatchobsoleteobsutilpathutilphasespycompat registrarrepoview revsetlangscmutilsmartsetstackutil)dateutil stringutilurlutilsanysdefinefollowcCs:|sttdt|d||g|ddRd|iS)Nsmissing argumentrrorder)r ParseErrorrmethodsreposubsetxr"r)6/usr/lib64/python3.9/site-packages/mercurial/revset.pygetsetnsr+c CsN||}dD]8}||vrz|||WStjyFYq0qdS)N)sourcestransplant_sources rebase_source)extrarevrRepoLookupError)r&rr-labelr)r)r* _getrevsourcets r2cCstttj|SN)sortedrZrapplyZ maybebytestr)xsr)r)r*_sortedbsr6cCsN|sttdtt||}||vs>|tvrHt|trHt |gSt S)Ns$empty string is not a valid revision) rr#rrintrevZ revsymbol _virtualrevs isinstance fullreposetbasesetr%r)r)r* stringsets  r<cCs|tkr||@S||@SdS)z1argument is already a smartset, use that directlyN) followorderr%r)r)r* rawsmartsetsr>cCsFt|t||}t|t||}|r(|s.tSt|||||Sr3)r+r:r; _makerangesetfirstlast)r&r'r(yr"mnr)r)r*rangesets rEcCs"|dus Jt||d|j|SNr)r? changelogtiprevr%r)r)r*rangealls rIcCs.t|t||}|stSt||d||SrF)r+r:r;r?rA)r&r'rBr"rDr)r)r*rangepresrJcCs4t|t||}|stSt||||j|Sr3)r+r:r;r?r@rGrH)r&r'r(r"rCr)r)r* rangeposts rKcCs||krt|g}nx|tkr8t||t|t|g}nT|tkrbt|gt||j|d}n*||kr|t|||d}nt|||d}|tkr||@S||@SdSNr)r;r spansetlenrGrH defineorder)r&r'rCrDr"r0r)r)r*r?s "r?cCs2t|}tj|t|||t|||dd}||@S)NT)Z includepath)r:r Zreachablerootsr+)r&r'r(rBr"r0r5r)r)r*dagranges rPcCs*|tkrt}nt}t|t||||||Sr3anyorderr=r+r&r'r(rBr"Zyorderr)r)r*andsetsrTcCs*|tkrt}nt}t|t||||||Sr3rQrSr)r)r* andsmallysetsrUcCst||||t|||tSr3r+rRr&r'r(rBr"r)r)r* differencesetsrXcCsf|sJt|dkr&t|||d|St|d}t|||d||}t||||d|}||S)Nrr)rNr+ _orsetlist)r&r'r5r"pabr)r)r*rZs  rZcCsBt|}|stS|tkr0|t|t||t@St||||SdSr3)getlistr;r=rZr:rR)r&r'r(r"r5r)r)r*orsets r_cCs|t|||tSr3rVr%r)r)r*notsetsr`cCsFt|}|tvr$t||||||SddtD}t||dS)NcSsg|]}t|dkr|qSrrN.0r0r)r)r* zrelationset..) getsymbol relationskeysrUnknownIdentifier)r&r'r(rBr"relrelnamesr)r)r* relationsets rmcCsdd}d}||krdkr$nnd}|dkrBt|d | df}|dkr\t|d|df}||fS)aSplit range with bounds a and b into two ranges at 0 and return two tuples of numbers for use as startdepth and stopdepth arguments of revancestors and revdescendants. >>> _splitrange(-10, -5) # [-10:-5] ((5, 11), (None, None)) >>> _splitrange(5, 10) # [5:10] ((None, None), (5, 11)) >>> _splitrange(-10, 10) # [-10:10] ((0, 11), (0, 11)) >>> _splitrange(-10, 0) # [-10:0] ((0, 11), (None, None)) >>> _splitrange(0, 10) # [0:10] ((None, None), (0, 11)) >>> _splitrange(0, 0) # [0:0] ((0, 1), (None, None)) >>> _splitrange(1, -1) # [1:-1] ((None, None), (None, None)) NNr)rrr)minmax)r\r]Z ancdepthsZ descdepthsr)r)r* _splitrange srqcCsd}t||||||S)N)rangeallN)generationssubrel)r&r'r(rkr"zr)r)r*generationsrel*srucCst|tdtdtjd tjd d\}}t||\\}} \} } |durZ| durZtSt|t||} | sttS|dur| durt|| d|| } | t || d| | 7} n6|durt|| d|| } n| durt || d| | } || @S)Ns0relation subscript must be an integer or a ranges*relation subscript bounds must be integersr)ZdeffirstZdeflastF) getintrangerr Z maxlogdepthrqr;r+r: revancestorsrevdescendants)r&r'r(rkrtr"r\r]ZancstartZancstopZ descstartZdescstoprevssr)r)r*rs/s*  rscCsHt|}|tvr&t|||||||SddtD}t||dS)NcSsg|]}t|dkr|qSrarbrcr)r)r*reUrfz#relsubscriptset..)rgsubscriptrelationsrirrj)r&r'r(rBrtr"rkrlr)r)r*relsubscriptsetMs r|cCsttddS)Ns%can't use a subscript in this contextrr#rrWr)r)r* subscriptsetYsr~cOstjtdtdddS)Ns can't use a list in this contextssee 'hg help "revsets.x or y"')hintr})r&r'r5optsr)r)r*listset]srcCsttddS)Ns*can't use a key-value pair in this contextr})r&r'kvr"r)r)r* keyvaluepairdsrcslt|}|tvr>t|}t|ddr2|||||S||||SddfddtD}t||dS)NZ _takeorderFcSst|ddduS)N__doc__r)fnr)r)r*prfzfunc..csg|]\}}|r|qSr)r))rdrzrZkeepr)r*rerrfzfunc..)rgsymbolsritemsrrj)r&r'r\r]r"ffuncZsymsr)rr*rhs  rs _destupdatecCs2t|dd}|ttj|fit|dg@S)Nlimitscleanr) getargsdictr;r Z destupdaterZ strkwargs)r&r'r(argsr)r)r* _destupdates rs _destmergecCs4d}|durt|t||}|ttj||dg@S)N) sourceset)r+r:r;r Z destmerge)r&r'r(rr)r)r* _destmergesrs adds(pattern)T)safeweightcCst|td}t|||dS)zChangesets that add a file matching pattern. The pattern without explicit kind like ``glob:`` is expected to be relative to the current directory and match against a file or a directory. sadds requires a patternadded getstringr checkstatusr&r'r(patr)r)r*addss rsancestor(*changeset)g?cCs|tt|t||td}z|t|}Wnty@tYS0|D]}|||}qFt |}||vrvt|gStS)zA greatest common ancestor of the changesets. Accepts 0 or more changesets. Will return empty list when passed no args. Greatest common ancestor of a single changeset is that changeset. r") iterr_r:rRnext StopIterationr;ancestorrr7)r&r'r(ZreviterZancr0r)r)r*rs    rFcCs4t|t||}|stSt|||||}||@Sr3)r+r:r;r rw)r&r'r( followfirst startdepth stopdepthheadsrzr)r)r* _ancestorss rsancestors(set[, depth]))rcCst|dd}d|vr"ttdd}}d|vrVt|dd}|dkrRtd |}d |vrt|d td }|dkrttd |d }t|||d||dS)zChangesets that are ancestors of changesets in set, including the given changesets themselves. If depth is specified, the result only includes changesets up to the specified generation. s ancestorsset depth startdepthsets#ancestors takes at least 1 argumentN startdepths'ancestors expects an integer startdepthrnegative startdepthdepths"ancestors expects an integer depthnegative depthrrr)rrr#r getintegerrr&r'r(rrrrDr)r)r* ancestorss&  rs_firstancestorscCst|||ddSNTr)rr&r'r(r)r)r*_firstancestorssrc Cs~t}t|t||D]^}t|D]F}||}t|dkrBqt|dkr\ttd|d }q"| |q||@S)zAChangesets that are the Nth child of a changeset in set. rrs'revision in set has more than one child) setr+r:rangechildrenrNrr/rr.add) r&r'r(rDr"csr0icr)r)r* _childrenspecs     rc Cst|td}|dkr(t|||| |St}|j}t|t||D]T}t|D]<}z||d}WqPt j y|| }YqP0qP| |qD||@S)zg``set~n`` Changesets that are the Nth ancestor (first parents only) of a changeset in set. s~ expects a numberr)rrrrrGr+r:r parentrevsrWdirUnsupportedp1r.r) r&r'r(rDr"psclr0rr)r)r* ancestorspecs  rsauthor(string) cs<t|td}t|dd\}}|jfddd|fdS)zAlias for ``user(string)``.sauthor requires a stringF casesensitivecs|Sr3userr(matcherr&r)r*rrfzauthor..s Zcondreprrr_substringmatcherfilter)r&r'r(rDkindpatternr)rr*authors rsbisect(string)cCs*t|td}tt||}||@S)a Changesets marked in the specified bisect status: - ``good``, ``bad``, ``skip``: csets explicitly marked as good/bad/skip - ``goods``, ``bads`` : csets topologically good/bad - ``range`` : csets taking part in the bisection - ``pruned`` : csets that are goods, bads or skipped - ``untested`` : csets whose fate is yet unknown - ``ignored`` : csets ignored due to DAG topology - ``current`` : the cset currently being bisected sbisect requires a string)rrlowerrrget)r&r'r(statusstater)r)r*bisect"s rsbisectedcCs t|||Sr3)rrr)r)r*bisected6srsbookmark([name])c st|ddtd}|rt|dtd}t|\}}}t}|dkr||krZj|}j|d} | s~t td|| |  qt} t jD]\} } || r| | q| D]} | |  qnfdd jD}|th8}||@S) z{The named bookmark or all bookmarks. Pattern matching is supported for `name`. See :hg:`help revisions.patterns`. rrs"bookmark takes one or no argumentss)the argument to bookmark must be a stringliteralNsbookmark '%s' does not existcsh|]}|qSr)r.rcr&r)r* \rfzbookmark..)getargsrrr stringmatcherrZ _bookmarksZ expandnamerrr/rr.r iteritemsvaluesr) r&r'r(rZbmrrrZbmsZbmrevZ matchrevsnamer)rr*bookmark;s4    rsbranch(string or set)csjfddzt|dWntjy:Yn~0t\}}|dkr|r~|j fdddfdS d rt t d |n|j fd ddfdSt t|}t|D]}|q|j|j fd dfd ddS)z All changesets belonging to the given branch or the branches of the given changesets. Pattern matching is supported for `string`. See :hg:`help revisions.patterns`. cs4z|dWStjy.|YS0dSrF)rrbranchr0)getbir&r)r* getbranchlszbranch..getbranchrfrcs |Sr3r)rrrr)r*r~rfzbranch.. rsliteral:sbranch '%s' does not existcs |Sr3r)rrr)r*rrfcs|p|vSr3r)r)r]rrr)r*rrfcs dtS)Nrr6r))r]r)r*rrf)ZrevbranchcacheZ branchinforrr#rr branchmapZ hasbranchr startswithr/rr+r:rr __contains__)r&r'r(rrrzr0r))r]rrrrr&r*ras:     rsphasedivergent()cCs&t|ddtdt|d}||@S)zMutable changesets marked as successors of public changesets. Only non-public and non-obsolete changesets can be `phasedivergent`. (EXPERIMENTAL) rs!phasedivergent takes no argumentsphasedivergentrrobsmodgetrevs)r&r'r(phasedivergentr)r)r*rs rsbundle()cCs6z |jj}Wn ty,ttdYn0||@S)zIChangesets in the bundle. Bundle must be specified by the -R option.s$no bundle provided - specify with -R)rG bundlerevsAttributeErrorrAbortr)r&r'r(rr)r)r*bundles   rcsBtdkdgfdd}|j|dtfdS)zuHelper for status-related revsets (adds, removes, modifies). The field parameter says which kind is desired. rNcs|}drr2tjjg|dd<dd}dusJJsntdkrnd}|dur||vrdSntfdd|DsdSt | | }|dur||vrdSntfdd|DrdSdS) NrctxrFc3s|]}|VqdSr3r)rdrrCr)r* rfz/checkstatus..matches..Tc3s|]}|VqdSr3r)rrr)r*rrf) matchmodrrootgetcwdZanypatsrNfilesanyrrrnode)r(rfnamerfieldhassetmcacherr&rr*matchess&    zcheckstatus..matchessr)rpatkindrrZsysbytes)r&r'rrrr)rr*rs rc Cst|s tSt}|jj}|}|D]F}||kr2q$||\}}||vrP|||tkr$||vr$||q$t|Sr3)r;rrGrrorr) r&r'Z parentsetrZprminrevr0rp2r)r)r* _childrens   r s children(set)cCs$t|t||}t|||}||@S)z&Child changesets of changesets in set.)r+r:r )r&r'r(rzrr)r)r*rs rsclosed()cs(t|ddtd|jfddddS)zChangeset is closed.rsclosed takes no argumentscs |Sr3)Z closesbranchrrr)r*rrfzclosed..sr)rrrrr)rr*closeds r s_commonancestorheads(set)cCs0t|t||td}|jjt|}|t|@S)Nr)r+r:rRrGZ_commonancestorsheadslistr;)r&r'r( startrevsZancsr)r)r*_commonancestorheadssr scommonancestors(set)cCsBt|t||td}|stS|D]}|t|t|gM}q"|S)z8Changesets that are ancestors of every changeset in set.r)r+r:rRr;r rw)r&r'r(r r0r)r)r*commonancestorss rsconflictlocal()cCsZt|ddtdddlm}|j|}|rT|j|jrT||j |jh@St S)zThe local side of the merge, if currently in an unresolved merge. "merge" here includes merge conflicts from e.g. 'hg rebase' or 'hg graft'. rs conflictlocal takes no argumentsr mergestate) rrrreadactiverGhasnodelocalr.r;r&r'r(Z mergestatemodrr)r)r* conflictlocals   rsconflictother()cCsZt|ddtdddlm}|j|}|rT|j|jrT||j |jh@St S)zThe other side of the merge, if currently in an unresolved merge. "merge" here includes merge conflicts from e.g. 'hg rebase' or 'hg graft'. rs conflictother takes no argumentsrr) rrrrrrrGrotherr.r;rr)r)r* conflictother s   rscontains(pattern)d)rcs.t|tdfdd}|j|dfdS)a<The revision's manifest contains a file matching pattern (but might not modify it). See :hg:`help patterns` for information about file patterns. The pattern without explicit kind like ``glob:`` is expected to be relative to the current directory and match against a file exactly for efficiency. scontains requires a patterncsrts0tj}||vrndSn>|}tjjg|d}|D]}||rZdSqZdS)NTrF)rrr canonpathrrrmanifest)r(patsrrCrrr&r)r*r<s   zcontains..matchess r)rrrr&r'r(rr)rr*contains0s  r sconverted([id])csTdt|ddtd}|r,t|dtdfdd|jfdd d fd S) zChangesets converted from the given identifier in the old repository if present, or all converted changesets if no identifier is specified. Nrrs#converted takes one or no argumentssconverted requires a revisioncs.|dd}|duo,dup,|S)Nsconvert_revision)r-rr)r0source)r&r.r)r* _matchvalue\szconverted.._matchvaluecs|Sr3r)rr"r)r*rarfzconverted..sr)rrrrr&r'r(lr))r"r&r.r* convertedLs r&sdate(interval)cs4t|td}t||jfddd|fdS)z5Changesets within the interval, see :hg:`help dates`.sdate requires a stringcs|dSrFdaterZdmr&r)r*rlrfzdate..s r)rrrZ matchdater)r&r'r(dsr)r)r*r(es  r(s desc(string)cs<t|td}t|dd\}}|jfddd|fdS)zSearch commit message for string. The match is case-insensitive. Pattern matching is supported for `string`. See :hg:`help revisions.patterns`. sdesc requires a stringFrcs|Sr3 descriptionrrr)r*r}rfzdesc..s rr)r&r'r(r*rrr)rr*descps r-cCs4t|t||}|stSt|||||}||@Sr3)r+r:r;r rx)r&r'r(rrrrootsrzr)r)r* _descendantss r/sdescendants(set[, depth])cCst|dd}d|vr"ttdd}}d|vrVt|dd}|dkrRtd |}d |vrt|d td }|dkrttd |d }t|||d||dS)zChangesets which are descendants of changesets in set, including the given changesets themselves. If depth is specified, the result only includes changesets up to the specified generation. s descendantsrrs%descendants takes at least 1 argumentNrs)descendants expects an integer startdepthrrrs$descendants expects an integer depthrrr)rrr#rrr/rr)r)r* descendantss*   r0s_firstdescendantscCst|||ddSr)r/rr)r)r*_firstdescendantssr1sdestination([set])cs|durt|t||}nt|}t|D]^}t||}d}|dur,|durTt}||||vsn|vrz|q,|}t||}q>q,|jjfdddS)zChangesets that were created by a graft, transplant or rebase operation, with the given revisions specified as the source. Omitting the optional set is the same as passing all(). Ncs dtS)Nsrr)destsr)r*rrfzdestination..r) r+r:rr2r appendupdaterr)r&r'r(Zsourcesr0srcZlineager)r2r* destinations(    r7sdiffcontains(pattern)ncst|dd}d|vr"ttdt|dtd}t|tj}t fddt j |j ||ddfd d }|j|d |fd S) zSearch revision differences for when the pattern was added or removed. The pattern may be a substring literal or a regular expression. See :hg:`help revisions.patterns`. s diffcontainsspatterns&diffcontains takes at least 1 arguments&diffcontains requires a string patterncsSr3r)r)fmatchr)r*makefilematchersz%diffcontains..makefilematcherT)diffcs>d}t|gD]"\}}}}tt||drd}q|S)NFT)Z searchfilesr;rgrepmodZdifflinestates)r.foundrrZpstatesZstates)r:searcherr)r*testdiffs zdiffcontains..testdiffsr)rrr#rrrZsubstringregexpreMralwaysr<Z grepsearcheruir)r&r'r(rrZregexpr?r))r9r:r>r* diffcontainss    rDscontentdivergent()cCs&t|ddtdt|d}||@S)zh Final successors of changesets with an alternative set of final successors. (EXPERIMENTAL) rs#contentdivergent takes no argumentscontentdivergentr)r&r'r(contentdivergentr)r)r*rFs rFsexpectsize(set[, size]))r takeorderc Cs"t|dd}d}t|d}d}d|vs0d|vr>ttdt|dtd td ||\}}|dksn|dkr|ttd t|t||d|d }||krt||kst||krtd ||t|f}n(||krt||krtd|t|f}|rt||t kr||@S||@SdS)aReturn the given revset if size matches the revset size. Abort if the revset doesn't expect given size. size can either be an integer range or an integer. For example, ``expectsize(0:1, 3:5)`` will abort as revset size is 2 and 2 is not between 3 and 5 inclusive.s expectsizesset sizerrrfssizersinvalid set of argumentss6expectsize requires a size range or a positive integers"size range bounds must be integerss negative sizers8revset size mismatch. expected between %d and %d, got %ds)revset size mismatch. expected %d, got %dN) rrNrr#rrvr+r:r/r=) r&r'r(r"rZminsizemaxsizeerrr.r)r)r* expectsizes@     rJsextdata(source)cCs8t|dd}t|dtd}t||}|t|@S)z:Changesets in the specified extdata source. (EXPERIMENTAL)sextdatar,s(extdata takes at least 1 string argument)rrrrrZ extdatasourcer;)r&r'r(rr!datar)r)r*extdataFs  rLs extinct()cCs&t|ddtdt|d}||@S)zBObsolete changesets with obsolete descendants only. (EXPERIMENTAL)rsextinct takes no argumentssextinctr)r&r'r(Zextinctsr)r)r*extinctTs rMsextra(label, [value])cst|dd}d|vr"ttdt|dtddd|vrbt|dtdt\}fd d |jfd d d fdS)zChangesets with the given label in the extra metadata, with the given optional value. Pattern matching is supported for `value`. See :hg:`help revisions.patterns`. sextras label valueslabelsextra takes at least 1 arguments(first argument to extra must be a stringNsvalues)second argument to extra must be a stringcs(|}|vo&dup&|Sr3)r-)r0r-)r1rr&valuer)r*r"vs zextra.._matchvaluecs|Sr3r)rr#r)r*r{rfzextra..sr)rrr#rrrrr)r&r'r(rrr))r"r1rr&rNr*r-]s    r-sfilelog(pattern)c st|td}t}|j}t|s@t|j| |}|g}n4tj |j| |g|ddfdd|dD}|D]}| |}i} d} t |D]} | | } | | vr|| | q|| } | |vr|| q| durt| | d}d} ||D]}|||vr|||vrzD|||}|| vrf|| kr^|||} Wqn|| |<WntjyYqYn0qqqx||@S)aChangesets connected to the specified filelog. For performance reasons, visits only revisions mentioned in the file-level filelog, rather than filtering through all changesets (much faster, but doesn't include deletes or duplicate changes). For a slower, more accurate result, use ``file()``. The pattern without explicit kind like ``glob:`` is expected to be relative to the current directory and match against a file exactly for efficiency. sfilelog requires a patternNrc3s|]}|r|VqdSr3r)rrr)r*rrfzfilelog..rr)rrrrGrrrrrrrfiler rrZlinkrevrpryrevision readfilesZfilenoderZManifestLookupError)r&r'r(rrzrrrZflZknownZscanposfrrZlrstartr0rDr)rr*filelogsH            rTsfirst(set, [n]))rrGrcCst||||S)zAn alias for limit().)limitr%r)r)r*r@sr@c st||d}d}d|vr,t|t||d}d|vrt|dtd|}|durXdg}g}|D]^}||} |dur|dtj|j||g| dd} | fdd  | Dq`t ||} n(|durt|dg}t |||} || @S) Ns file startrevstartrevfiles%s expected a pattern.spath)rdefaultc3s|]}|VqdSr3)Z introfilectxrrr)r*rrfz_follow..)rr+r:rrrrrrextendrwalkr Zfilerevancestorsr;r.rw) r&r'r(rrrryZfctxsr0ZmctxrCrzr)rr*_follows,  $r\sfollow([file[, startrev]])cCst|||dS)z An alias for ``::.`` (ancestors of the working directory's first parent). If file pattern is specified, the histories of files matching given pattern in the revision given by startrev are followed, including copies. r!r\rr)r)r*followsr^ _followfirstcCst|||dddS)Nr_Trr]rr)r)r* _followfirstsr`s?followlines(file, fromline:toline[, startrev=., descend=False])cCs8t|dd}t|ddkr*ttdd}d|vrlt|t||d}t|dkrdttd|}t|d td }td }t ||||}t j t |dd td td\} } |||} d} d|vrt|dtd} | rtddt| | | Ddd} n tddt| | | Ddd} || @S)aChangesets modifying `file` in line range ('fromline', 'toline'). Line range corresponds to 'file' content at 'startrev' and should hence be consistent with file size. If startrev is not specified, working directory's parent is used. By default, ancestors of 'startrev' are returned. If 'descend' is True, descendants of 'startrev' are returned though renames are (currently) not followed in this direction. s followlinessfile *lines startrev descendslinesrs!followlines requires a line rangerXrVs(followlines expects exactly one revisionrWsfollowlines requires a patterns$followlines expects exactly one filers,followlines expects a line number or a ranges"line range bounds must be integersFsdescends"descend argument must be a booleancss|]\}}|VqdSr3rrdrZ _lineranger)r)r*r&szfollowlines..T)Ziterasccss|]\}}|VqdSr3rrar)r)r*r0s)rrNrr#rr+r:rArrZparsefollowlinespatternrZprocesslinerangervZfilectx getboolean generatorsetr ZblockdescendantsZblockancestors)r&r'r(rr.ryrmsgrZfromlineZtolineZfctxZdescendZrsr)r)r* followliness\      resnodefromfile(path)c Cst|td}t}z^t|d>}|D](}|}t||}|dur(||q(Wdn1sf0YWnJty} z2td} | |t | j f;} t | WYd} ~ n d} ~ 00|t|@S)zRead a list of nodes from the file at `path`. This applies `id(LINE)` to each line of the file. This is useful when the amount of nodes you need to specify gets too large for the command line. s nodefromfile require a file pathrbNscannot open nodes file "%s": %s)rrrropenstrip_noderIOErrorr Z strtolocalstrerrorrrr;) r&r'r(pathZ listed_revrlinerDrnexcrCr)r)r* nodefromfile;s  . rpsall()cCst|ddtd|t|@S)z&All changesets, the same as ``0:tip``.rsall takes no arguments)rrrMrr)r)r*getallTsrqs grep(regex)c szztt|tdWn>tjyV}z$ttdt|WYd}~n d}~00fdd}|j|dj fdS)zLike ``keyword(string)`` but accepts a regex. Use ``grep(r'...')`` to ensure special escape characters are handled correctly. Unlike ``keyword(string)``, the match is case-sensitive. sgrep requires a stringsinvalid match pattern: %sNcs:|}|||gD]}|r dSq dSNTF)rrr,search)r(reZgrr&r)r*rjs  zgrep..matchess r) r@compilerrrr#rZ forcebytestrrr)r&r'r(rtrr)rur*r\srs _matchfilesc sRt|ddd}gggd\|D]}t|d}|dd|dd}}|dkrf|q*|dkrz|q*|d kr|q*|d krdurtd |d krtq|q*|d kr܈durtd|q*td|q*sdtddDdgjjf dd}|j |dfdS)Nrs*_matchfiles requires at least one argumentrns%_matchfiles requires string argumentsrYp:si:sx:sr:s)_matchfiles expected at most one revisionrfsd:s-_matchfiles expected at most one default modesinvalid _matchfiles prefix: %ssglobcss|]}t|dkVqdS)rN)rrrdr[r)r)r*rrfz_matchfiles..c s|tkr|}n|}dr2rhdurhdur>|n}tjj|dd<d}|D]}||rtdSqtdS)Nr)includeexcluderrYTF)r rrrrr)r(rr0rCr rYroZgetfilesrZincrrr&r.r)r*rs& z_matchfiles..matchessCr) rrr4rr#r rrGrQr) r&r'r(r%argrzprefixrNrr)r|r* _matchfilestsV    rs file(pattern)cCs"t|td}t||dd|fS)zChangesets affecting files matched by pattern. For a faster but less accurate result, consider using ``filelog()`` instead. This predicate uses ``glob:`` as the default kind of pattern. sfile requires a patternstringrx)rrrrr)r)r*hasfiles rshead()csTt|ddtdt}|j|D]}|fdd|Dq*|t|@S)z!Changeset is a named branch head.rshead takes no argumentsc3s|]}|VqdSr3r)rdhrr)r*rrfzhead..)rrrrGrZ iterheadsr5r;)r&r'r(Zhslsr)rr*heads rs heads(set)cCs|tkr t}t|t|||d}d}t|vrTdd|dD}t|}|t|j |}|dur|| || tt |}||@S)z'Members of set with no children in set.rNcSsg|] }|qSr)rryr)r)r*rerfzheads..) rOr=r+r:r parentsrdiscardrGheadrevsdifference_updaterr;)r&r'r(r"ZinputsetZ wdirparentsrr)r)r*rs    rshidden()cCs&t|ddtdt|d}||@S)zHidden changesets.rshidden takes no argumentssvisible)rrrZ filterrevs)r&r'r(Z hiddenrevsr)r)r*hiddens rskeyword(string)cs4tt|tdfdd}|j|dfdS)zSearch commit message, user name, and names of changed files for string. The match is case-insensitive. For a regular expression or case sensitive search of these fields, use ``grep(regex)``. skeyword requires a stringcs2|}tfdd|||gDS)Nc3s|]}t|vVqdSr3r r)rdt)kwr)r*rsz+keyword..matches..)rrrr,)r0rrr&r)r*rs zkeyword..matchess r)r rrrrrr)rr*keywords rslimit(set[, n[, offset]])c Cst|dd}d|vr"ttdt|dtddd}|d krPttd t|d tdd d}|d kr~ttd t|t||d}||||}|t kr|dkr||@S||@S) z>First n members of set, defaulting to 1, starting from offset.rs set n offsetrs%limit requires one to three argumentsnslimit expects a numberr)rYrnegative number to selectsoffsetsnegative offset) rrr#rrrr+r:slicer=) r&r'r(r"rlimZofsosrr)r)r*rUs  rUslast(set, [n])cCst|ddtd}d}t|dkr4t|dtd}|dkrJttdt|t||d}|| d|}|t kr|dkr||@S|||@S)z'Last n members of set, defaulting to 1.rrYs"last requires one or two argumentsslast expects a numberrr) rrrNrrr#r+r:reverserr=)r&r'r(r"r%rrrr)r)r*rA4s  rAsmax(set)cCs^t|t||}z*|}||vr8t|gd||fdWSWntyLYn0td||fdS)z.Changeset with highest revision number in set.s Zdatarepr)r+r:rpr; ValueErrorr&r'r(rrCr)r)r*maxrevHs rsmerge()cs4t|ddtdjfdd}|j|ddS)zChangeset is a merge changeset.rsmerge takes no argumentscs>z|dtkWStjy8t|YS0dSrL)rrrrboolrrrr&r)r*ismerge^szmerge..ismergesr)rrrGr)r&r'r(rr)rr*mergeWsrs branchpoint()cst|ddtd|j}|s"tSt|dgt||jddD]0}||D] }|krZ|d7<qZqL|jfddddS) z$Changesets with more than one child.rsbranchpoint takes no argumentsr)rScs|dkSrLr)rZbaserevZ parentscountr)r*rxrfzbranchpoint..s r) rrrGr;rorNryrr)r&r'r(rr0r[r)rr* branchpointgsrsmin(set)cCs^t|t||}z*|}||vr8t|gd||fdWSWntyLYn0td||fdS)z-Changeset with lowest revision number in set.s r)r+r:ror;rrr)r)r*r|s rsmodifies(pattern)cCst|td}t|||dS)zChangesets modifying files matched by pattern. The pattern without explicit kind like ``glob:`` is expected to be relative to the current directory and match against a file or a directory. smodifies requires a patternmodifiedrrr)r)r*modifiess rsnamed(namespace)c st|ddtd}t|dtd}t|\}}}t}|dkrp|jvr^ttd|| j|n(t jD]\} }|| r|| |q|t} |D]>}| D].} | |j vr| fdd|| Dqq| th8} || @S) zThe changesets in a given namespace. Pattern matching is supported for `namespace`. See :hg:`help revisions.patterns`. rs#named requires a namespace argumentrs&the argument to named must be a stringrsnamespace '%s' does not existc3s|]}|VqdSr3rrdrDrr)r*rrfznamed..)rrrrrrnamesrr/rrrZ listnamesZ deprecatedr5nodesr) r&r'r(rnsrrrZ namespacesrrr)rr*nameds.    $ rc Csd}t|d|jjkr`z|jt|}WqtjyDt}Yqt t fy\d}Yq0nNz$t ||}|dur|j|}Wn(t yYntjyt}Yn0|S)zprocess a node inputNrY) rNZ nodeconstantsZnodelenrGr.rrrr LookupError TypeErrorrZresolvehexnodeidprefix)r&rDrnZpmr)r)r*ris"    ris id(string)cCsNt|ddtd}t|dtd}t||}|dur - ::). rrYsonly takes one or two argumentsrFcs g|]}|vr|vr|qSr)r)rdr.r0rzr)r*reszonly..)commonr) rGrrr+r:rNr;rr rxrZfindmissingrevs)r&r'r(rrr{resultsr)rr*onlys  rs origin([set])csR|durtt|}nt}fddfdd|D}|dh8}||@S)an Changesets that were specified as a source for the grafts, transplants or rebases that created the given revisions. Omitting the optional set is the same as passing all(). If a changeset created by these operations is itself specified as a source for one of these operations, only the source changeset for the first operation is selected. Ncs6t|}|durdSt|}|dur,|S|}qdSr3)r2)r.r6prevrr)r* _firstsrc s  zorigin.._firstsrccsh|] }|qSr)r)rc)rr)r*r,rfzorigin..)r+r:)r&r'r(r3or))rr&r*origins   rsoutgoing([path])c s4ddlm}m}t|ddtd}|r8t|dtdp:d}|rH|g}ng}t}tj |D]} | j pp| j }| j gf} | | g\} } | rfdd| D} |i|} zFj  |j| | d }Wd n1s0YW| n | 0||jqbjfd d |D}||@S) zChangesets not found in the specified destination repository, or the default push location. If the location resolve to multiple repositories, the union of all outgoing changeset will be used. r) discoveryhgrs"outgoing takes one or no argumentss#outgoing requires a repository pathrfcsg|]}|qSr)lookuprrr)r*reRrfzoutgoing..)Z onlyheadsNcsh|]}|qSr)rrcrr)r*r]rfzoutgoing..)rrrrrrrr Zget_push_pathsrCZpushloclocrZ addbranchrevspeerZsilentZfindcommonoutgoingcloser5missingrG)r&r'r(rrr%destr3rrlbranchesryZcheckoutroutgoingrr)rr*r3s2    &rs p1([set])c Cs|dur4||}|dkr.|t|g@StSt}|j}t|t||D]H}z|||dWqPt j y|||YqP0qP|t h8}||@S)z.css|]}|VqdSr3rryr)r)r*rrfzparents..) rrrGr5rr+r:rrr)r&r'r(rrZuprr0r)r)r*rs" rcGs|j|||S)z,helper to select all rev in phases) _phasecacheZ getrevset)r&r'targetsr)r)r*_phasesrs _phase(idx)cCs(t|ddd}t|dd}t|||S)Nrs_phase requires one argumentrs_phase expects a number)rrr)r&r'r(r%targetr)r)r*phasesrsdraft()cCs$t|ddtdtj}t|||S)zChangeset in draft phase.rsdraft takes no arguments)rrrdraftrr&r'r(rr)r)r*rsrssecret()cCs$t|ddtdtj}t|||S)zChangeset in secret phase.rssecret takes no arguments)rrrsecretrrr)r)r*rsrs stack([revs])cCsP|durt|}n4tg}t|t||D]}t||}||}q.||@S)zdExperimental revset for the stack of changesets or working directory parent. (EXPERIMENTAL) N)stackmodZgetstackrr;r+r:)r&r'r(ZstacksrPZ currentstackr)r)r*rs    rc Cs:zt|d}|dvrtWn$ttfy@ttdYn0t}|j}t|t ||D]}|dkrv| |q^|dkrz| | |dWn*tj y| || Yn0q^z(| |}|dtkr| |dWq^tj y.||}t|dkr*| |dYq^0q^||@S)z``set^0`` The set. ``set^1`` (or ``set^``), ``set^2`` First or second parent, respectively, of all changesets in set. r)rrrYs^ expects a number 0, 1, or 2rrY)intrrrr#rrrGr+r:rrrrr.rrrN) r&r'r(rDr"rrr0rr)r)r* parentspecs2     rs present(set)cCs0zt||||WStjy*tYS0dS)aAn empty set, if any revision in set isn't found; otherwise, all revisions in set. If any of specified revisions is not present in the local repository, the query is normally aborted. But this predicate allows the query to continue even in such cases. N)r+rr/r;r%r)r)r*presents r _notpubliccCs t|dddt||tjtjS)Nrs_notpublic takes no arguments)rrrrrrr)r)r* _notpublic srs"_phaseandancestors(phasename, set)c st|ddd}t|d}tt|d}tjtj}|d}||vr\td|||j j fdd}t j ||d } |d kr| fd d } || @S) NrYs)_phaseandancestors requires two argumentsrr)rdraftssecrets%r is not a valid phasenamecs|kSr3r)r)getphase minimalphaser&r)r*cutfunc(sz#_phaseandancestors..cutfunc)rrcs|kSr3r)r)rrr&r)r*r.rfz$_phaseandancestors..)rrgr+r:rrrrr#rrr rwr) r&r'r(rZ phasenamerzrZ phasenamemaprryr))rrrr&r*_phaseandancestorss$ rspublic()cCs t|ddtdt||tjS)zChangeset in public phase.rspublic takes no arguments)rrrrpublicrr)r)r*r2srsremote([id [,path]])c Csddlm}t|ddtd}d}t|dkr@t|dtd}|dkrT|d}d}t|dkrvt|dtd }|s~d }td ||j |\}}| |i|}| |} | |vr||  } | |vrt | gSt S) zLocal revision that corresponds to the given identifier in a remote repository, if present. Here, the '.' identifier is a synonym for the current local branch. r)rrrYs(remote takes zero, one, or two argumentsrXsremote requires a string idrfs!remote requires a repository pathsdefaultsremote)rrrrrNrrr Zget_unique_pull_pathrCrrr.r;) r&r'r(rr%qrrrrDr0r)r)r*remote:s,        rsremoves(pattern)cCst|td}t|||dS)zChangesets which remove files matching pattern. The pattern without explicit kind like ``glob:`` is expected to be relative to the current directory and match against a file or a directory. sremoves requires a patternremovedrrr)r)r*removes`s rs rev(number)cCs.zt|||WStjy(tYS0dS)z+Revision with the given numeric identifier.N)_revrr/r;rr)r)r*r.msr.s _rev(number)c Cst|ddtd}ztt|dtd}Wn$ttfyPttdYn0|tvrz|j |Wn$t yt td|Yn0|t |g@S)Nrsrev requires one argumentrsrev requires a numbersrev expects a numbersunknown revision '%d')rrrrrrrr#r8rGrrr/r;r$r)r)r*rvs rs revset(set)cCst||||S)aStrictly interpret the content as a revset. The content of this special predicate will be strictly interpreted as a revset. For example, ``revset(id(0))`` will be interpreted as "id(0)" without possible ambiguity with a "id(0)" bookmark or tag. )r+r%r)r)r*revsetpredicatesrsmatching(revision [, field])c st|ddtd}tt|ddg}t|dkrNt|dtd}g}|D]F}|dkrp|gd7}qV|dkr|d dg7}qV|d krd }||qVt|}d |vrd |vr| d gdfdd}t |}|j |dgfddfddfddfddfddfddfddfddfddfddd }|D]8} | | d} | durt td| | qZfd dfd!d"} |j| d#|fd$S)%aChangesets in which a given set of fields match the set of fields in the selected revision or set. To match more than one field pass the list of fields to match separated by spaces (e.g. ``author description``). Valid fields are most regular revision fields and some special fields. Regular revision fields are ``description``, ``author``, ``branch``, ``date``, ``files``, ``phase``, ``parents``, ``substate``, ``user`` and ``diff``. Note that ``author`` and ``user`` are synonyms. ``diff`` refers to the contents of the revision. Two revisions matching their ``diff`` will also match their ``files``. Special fields are ``summary`` and ``metadata``: ``summary`` matches the first line of the description. ``metadata`` is equivalent to matching ``description user date`` (i.e. it matches the main metadata fields). ``metadata`` is the default field which is used when no fields are specified. You can match more than one field at a time. rrYsmatching takes 1 or 2 argumentsrsmetadatas1matching requires a string as its second argument)user descriptiondatedifffilesauthorrsummaryr) phaseparentsrrbranchrrrsubstatercs,z |WSty&tYS0dSr3)indexrrN)r) fieldorderr)r* fieldkeyfuncs  zmatching..fieldkeyfunc)keycs |Sr3rrrr)r*rrfzmatching..cs |Sr3rrrr)r*rrfcs |Sr3r'rrr)r*rrfcs |Sr3r+rrr)r*rrfcs |Sr3)rrrr)r*rrfcs |Sr3)rrrr)r*rrfcs |Sr3)rrrr)r*rrfcs |jSr3)substaterrr)r*rrfcs|dSrF)r, splitlinesrrr)r*rrfcs"t|jtjddidS)NsgitT)r)r r;r Z diffalloptsrCrrr)r*rs) rrrrrrrrrrNs,unexpected field name passed to matching: %scsfddDS)Ncsg|] }|qSr)r)rrr)r*re rfz.matching....r)r) getfieldfuncsrr*r rfcsJD]@}|}d}tD]\}}||||krd}q|rdSqdSrr) enumerate)r(r.rrrDr)rgetinforyr)r*r szmatching..matchessr)rrr+r:rNrsplitr4rrr sortrrr#r) r&r'r(r%Z fieldlistfieldsrrZ_funcsinfoZgetfieldrr))rrrr&ryr*matchings`                    rs reverse(set)cCs"t||||}|tkr||S)zReverse order of set.)r+rOr)r&r'r(r"r%r)r)r*r srs roots(set)cs8t|t|||jjfdd}|j|dd@S)z2Changesets in set with no parent changeset in set.cs(|D]}d|kr|vrdSqdS)NrFTr))r0r[rrzr)r*r% s zroots..filtersr)r+r:rGrr)r&r'r(rr)rr*r. sr.cCs|Sr3rrr)r)r*r0 rfrcCs|Sr3r+rr)r)r*r1 rfcCs|Sr3rrr)r)r*r2 rfcCs|Sr3rrr)r)r*r3 rfcCs |dSrFr'rr)r)r*r4 rf)revrsdescrrrsnodecCst|dd}d|vr"ttdd}d|vr@t|dtd}g}|D]X}|}|d}|rn|d d }|tvr|d krttd t || ||fqLt |d krt d d|Drttdi}d|vrt dd|Dr|d|d<nttd|d||fS)z5Parse sort options into (set, [(key, reverse)], opts)ssortsset keys topo.firstbranchrs"sort requires one or two argumentsrskeysssort spec must be a string-rNtoposunknown sort key %rcss|]\}}|dkVqdSrNr)rdrrr)r)r*rP rfz_getsortargs..s7topo sort order cannot be combined with other sort keystopo.firstbranchcss|]\}}|dkVqdSrr)rr)r)r*rX rfs>topo.firstbranch can only be used when using the topo sort key) rrr#rrrr _sortkeyfuncsrZbytestrr4rNr)r(rrikeyflagsrZfkrrr)r)r* _getsortargs9 s>     rssort(set[, [-]key... [, ...]])c st|\}}}t|||}|r(|tkr,|St|dkr`|dddkr`|j|ddd|S|dddkrd}d|vrt||d}tt|jj |dd }|ddr| |Sfd d |D} t |D]\} } | jt | | d qtd d | DS)aSort set by keys. The default sort order is ascending, specify a key as ``-key`` to sort in descending order. The keys can be: - ``rev`` for the revision number, - ``branch`` for the branch name, - ``desc`` for the commit message (description), - ``user`` for user name (``author`` can be used as an alias), - ``date`` for the commit date - ``topo`` for a reverse topographical sort - ``node`` the nodeid of the revision The ``topo`` sort order cannot be combined with other sort keys. This sort takes one optional argument, ``topo.firstbranch``, which takes a revset that specifies what topographical branches to prioritize in the sort. rrr)rrr)rT)Zistopocsg|] }|qSr)r)rcrr)r*re rfzsort..)rrcSsg|] }|qSr)r)rdrr)r)r*re rf) rr+rOrNrr;r ZtoposortrGrrreversedr) r&r'r(r"rzrrryZ firstbranchZctxsrrr)rr*rf s,  rssubrepo([pattern])cspt|ddtd}dt|dkr4t|dtdtdgfddfd d }|j|d fd S) zChangesets that add, modify or remove the given subrepo. If no subrepo pattern is named, any subrepo changes are returned. rrs"subrepo takes at most one argumentNssubrepo requires a patterns .hgsubstatec3s,t\}}}|D]}||r|VqdSr3)rr)rrr[rCr)rr)r* submatches szsubrepo..submatchescs|}j||d}dur>|jp<|jp<|jS|jrVt|jS|jrt |j}| |j|D]&}|j ||j |krdSq|jrt|jSdS)N)rTF) rrrrrrrrrirr5r)r(rrzZsubsrlrCrr&rr)r*r s zsubrepo..matchess r)rrrNrrexactr)r&r'r(rrr)rr*subrepo s   rcsX|j}|jj|jfdd|fdd|DD}|dt||jjS)z(repo, smartset, [node] -> [node]) -> smartset Helper method to map a smartset to another smartset given a function only talking about nodes. Handles converting between rev numbers and nodes, and filtering. csh|] }|qSr)r)r)torevr)r*r rfz!_mapbynodefunc..c3s|]}|VqdSr3r)rc)tonoder)r*r rfz!_mapbynodefunc..N) Z unfilteredrGrZget_revrrrr;Z filteredrevs)r&rzrrrr))rrr*_mapbynodefunc s  $ rssuccessors(set)cs0tt|}fdd}t||}||@S)zNAll successors for set, including the given set themselves. (EXPERIMENTAL)cstj|Sr3)rZ allsuccessorsZobsstore)rrr)r*r rfzsuccessors..)r+r:r)r&r'r(rzrdr)rr* successors s  r csNtj|d\}}|dkrD|s8tfdd}n fdd}||fS)Nrrcst|vSr3rrzrr)r*r rfz#_substringmatcher..cs|vSr3r)r r r)r*r rf)rrr r)rrrrr)r r*r s   rs tag([name])cst|ddtd}|j|rt|dtd}t|\}}|dkr|jj|d}|durpt td||| h}qfdd | D}nfd d | D}||@S) zThe specified tag by name, or all tagged revisions if no name is given. Pattern matching is supported for `name`. See :hg:`help revisions.patterns`. rrstag takes one or no argumentss$the argument to tag must be a stringrNstag '%s' does not existcs"h|]\}}|r|qSr)rrdrrDrrr)r*r rfztag..cs"h|]\}}|dkr|qS)stiprr rr)r*r rf) rrrGrrrZ _tagscachetagsrrr/r.Ztagslist)r&r'r(rrrtnrzr)rr*tag s$ rstaggedcCs t|||Sr3)rrr)r)r*tagged srsorphan()cCs&t|ddtdt|d}||@S)z?Non-obsolete changesets with obsolete ancestors. (EXPERIMENTAL)rsorphan takes no argumentsorphanr)r&r'r(orphanr)r)r*r s rs unstable()cCsVt|dddt}|t|d|t|d|t|d|t|@S)z-Changesets with instabilities. (EXPERIMENTAL)rsunstable takes no argumentsrrrE)rrr5rrr;)r&r'r(Z _unstabler)r)r*unstable s rs user(string)cCs t|||S)zUser name contains string. The match is case-insensitive. Pattern matching is supported for `string`. See :hg:`help revisions.patterns`. )rrr)r)r*r$ srswdir()cCs4t|ddtdt|vs$t|tr.ttgStS)z!Working directory. (EXPERIMENTAL)rswdir takes no arguments)rrr r9r:r;rr)r)r*wdir. s rc Cst|d}|stS|j}g}t}|dD]}z*t|}d||ksP||vrTt|g} Wn ty|t|||t} Yn0| D]<}||vrq||vs|t vrt |t r| || |qq.t|S)Ninternal errors%d)rr;rGrrrrr<rOr8r9r:r4r) r&r'r(rzrrseenrr0ryr)r)r* _orderedlist8 s4    rs_listcCs,|tkr|t|t||@St|||SdSr3)r=rr:r%r)r)r*_listY srcsBt|dstSdddD}|tfdd|DS)NrcSsg|] }t|qSr))rrcr)r)r*ref rfz#_orderedintlist..rcsg|]}|vr|qSr)r)rcr r)r*reh rf)rr;rr&r'r(rr)r r*_orderedintlistb s  rs_intlistcCs,|tkr|t|t||@St|||SdSr3)r=rr:r%r)r)r*_intlistl srcsLt|dstS|jfdddD}|tfdd|DS)Nrcsg|]}t|qSr))r.rrcrr)r*rez rfz#_orderedhexlist..rcsg|]}|vr|qSr)r)rcr r)r*re| rf)rr;rGrrr))rrzr*_orderedhexlistu s rs_hexlistcCs,|tkr|t|t||@St|||SdSr3)r=rr:r%r)r)r*_hexlist sr )srangerrsrangepres rangepostsdagrangerssymbolsands andsmallyorsnots differencesrelations relsubscripts subscriptlistskeyvaluesfuncsancestorsparents parentpostssmartset)gs generationscsfdd}|S)Ncs6zt|WStjy0td|Yn0dS)Ns!ambiguous revision identifier: %s)rZ isrevsymbolrZAmbiguousPrefixLookupErrorZ InputError)symbolrr)r*r s zlookupfn..fnr))r&rr)rr*lookupfn s r%cCst||g|dS)z+Create a matcher for a single revision specr)matchany)rCspecrr)r)r*r srcs|sd dd}|St|s(ttdt|dkrFt|d}nddtfd d |Df}g}d}|r|| d |j }|r|| |rtj |||d }t |}t|}t|}t|S)aeCreate a matcher that will include any revisions matching one of the given specs If lookup function is not None, the parser will first attempt to handle old-style ranges, which may contain operator characters. If localalias is not None, it is a dict {name: definitionstring}. It takes precedence over [revsetalias] config section. NcSstSr3)r;)r&r'r)r)r*mfunc szmatchany..mfuncs empty queryrrr!)r"c3s|]}t|VqdSr3)rparse)rdrzrr)r*r rfzmatchany..s revsetalias)warn)N)allrr#rrNrr)tuplerZZ configitemsr*rZ expandaliasesZ foldconcatZanalyzeoptimize makematcher)rCZspecsrZ localaliasr(treealiasesr*r)rr*r& s.      r&csdfdd }|S)z)Create a matcher from an evaluatable treeNcs8|dur|durt}nt}|dur*t|}t|||Sr3)rOr=r:r+)r&r'r"r/r)r*r( szmakematcher..mfunc)NNr))r/r(r)r1r*r. s r.cCs2t|jD] \}}|t|<|jr t|q dS)z2Load revset predicates from specified registrarobjN)rrZ_tablerZ_safe safesymbolsr)rCZextnameZ registrarobjrrr)r)r* loadpredicate sr3)FNN)FNN)F)T)N)NN)Z __future__rr@Zi18nrrrrrrr rr r r r rrr<rrrrrrrrrrrrrrrrZutilsrrr rgrrrbr^rvrrr;rcrMr:r8rRrOr=r+r2r6r<r>rErIrJrKr?rPrTrUrXrZr_r`rmrqrursr|r~rrrrrr2r predicaterrrrrrrrrrrrrrrrrr rr r rrrr r&r(r-r/r0r1r7rDrFrJrLrMr-rTr@r\r^r`rerprqrrrrrrrUrArrrrrrrirrrrrrrrrrrrrrrrrrrrr.rrrr.r7Zbinnoderrrrrr rrrrrrrrrrrrr r$rhr{r%r&r.r3rZ i18nfunctionsr)r)r)r*s\   X(                          %  3   %                  !    /  )   +     !  ?      E       Z                      %       -          "    %          - .,          !    )