o ]Lb]@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@dAdBZVeUdCdDdEZWeUdFdGdHdIdJdKZXeUdLdGdMdIdNdOZY ddQdRZZeUdSdGdTdUdVZ[eUdWdGdTdXdYZ\dZd[Z]d\d]Z^eUd^dGd_dId`daZ_eUdbdGdTdcddZ`eUdedGdTdfdgZaeUdhdGdTdidjZbeUdkdGd_dIdldmZceUdndGdTdodpZdeUdqdGdTdrdsZedtduZfdvdwZgeUdxdGdTdydzZheUd{dGd_dId|d}ZieUd~dGdTddZjeUddGdTddZkeUddGdTddZleUddGdTddZmeUdddddZneUddGdTddZoeUddGd_dIddZpeUddGd_dIddZq dddZreUddGdTddZseUddGdTddZteUddGd_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~dGdGddddZddZeUddGdGdddZide<de=de>de?deAde:de:deBdeCdeFdeGdeDdeHdeLdeMdeNdeOePe^eee;dZeJeJdZeKeKdZÐddZĐdddZdddZŐddZƐddZeddeUeQȡZdS()absolute_importN)_getattr)binnullrevwdirrev)dagopdestutildiffutilencodingerrorgrephbisectmatchobsoleteobsutilpathutilphasespycompat registrarrepoview revsetlangscmutilsmartsetstackutil)dateutil stringutilurlutilsanysdefinefollowcCs:|s ttdt|d||g|ddRd|iS)Nsmissing argumentrrorder)r ParseErrorrmethodsreposubsetxr"r)2/usr/lib/python3/dist-packages/mercurial/revset.pygetsetns(r+c CsN||}dD]}||vr$z |||WStjy#YqwqdS)N)sourcestransplant_sources rebase_source)extrarevrRepoLookupError)r&rr-labelr)r)r* _getrevsourcets r2cCstttj|SN)sortedrrapply maybebytestr)xsr)r)r*_sortedbr8cCsN|s ttdtt||}||vs|tvr$t|tr$t |gSt S)Ns$empty string is not a valid revision) rr#rrintrev revsymbol _virtualrevs isinstance fullreposetbasesetr%r)r)r* stringsets  r@cCs|tkr||@S||@S)z1argument is already a smartset, use that directly) followorderr%r)r)r* rawsmartsetsrBcCsFt|t||}t|t||}|r|stSt|||||Sr3)r+r>r? _makerangesetfirstlast)r&r'r(yr"mnr)r)r*rangesets rIcCs"|dusJt||d|j|SNr)rC changelogtiprevr%r)r)r*rangealls rMcCs.t|t||}|s tSt||d||SrJ)r+r>r?rCrE)r&r'rFr"rHr)r)r*rangepresrNcCs4t|t||}|s tSt||||j|Sr3)r+r>r?rCrDrKrL)r&r'r(r"rGr)r)r* rangeposts rOcCs||kr t|g}n<|tkrt||t|t|g}n*|tkr1t|gt||j|d}n||kr>t|||d}nt|||d}|tkrN||@S||@SNr)r?r spansetlenrKrL defineorder)r&r'rGrHr"r0r)r)r*rCs "rCcCs2t|}tj|t|||t|||dd}||@S)NT) includepath)r>r reachablerootsr+)r&r'r(rFr"r0r7r)r)r*dagranges rVcCs*|tkrt}nt}t|t||||||Sr3anyorderrAr+r&r'r(rFr"yorderr)r)r*andsetsr[cCs*|tkrt}nt}t|t||||||Sr3rWrYr)r)r* andsmallysetsr\cCst||||t|||tSr3r+rXr&r'r(rFr"r)r)r* differencesetsr_cCsf|sJt|dkrt|||d|St|d}t|||d||}t||||d|}||S)Nrr)rRr+ _orsetlist)r&r'r7r"pabr)r)r*ras  racCs>t|}|s tS|tkr|t|t||t@St||||Sr3)getlistr?rArar>rX)r&r'r(r"r7r)r)r*orsets rfcCs|t|||tSr3r]r%r)r)r*notsetr9rgcCsBt|}|tvrt||||||SddtD}t||)NcSg|] }t|dkr|qSrrR.0r0r)r)r* zrelationset..) getsymbol relationskeysrUnknownIdentifier)r&r'r(rFr"relrelnamesr)r)r* relationsets  rucCsdd}d}||krdkrnnd}|dkr!t|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)rcrd ancdepths descdepthsr)r)r* _splitrange sr{cCsd}t||||||S)N)rangeallN)generationssubrel)r&r'r(rsr"zr)r)r*generationsrel*srcCst|tdtdtjd tjd d\}}t||\\}} \} } |dur-| dur-tSt|t||} | s:tS|durZ| durZt|| d|| } | t || d| | 7} || @S|durkt|| d|| } || @S| durxt || d| | } || @S)Ns0relation subscript must be an integer or a ranges*relation subscript bounds must be integersr)deffirstdeflastF) getintrangerr maxlogdepthr{r?r+r> revancestorsrevdescendants)r&r'r(rsr~r"rcrdancstartancstop descstartdescstoprevssr)r)r*r}/s.   r}cCsDt|}|tvrt|||||||SddtD}t||)NcSrhrirjrkr)r)r*rmUrnz#relsubscriptset..)rosubscriptrelationsrqrrr)r&r'r(rFr~r"rsrtr)r)r*relsubscriptsetMs  rcCttd)Ns%can't use a subscript in this contextrr#rr^r)r)r* subscriptsetYrcOstjtdtdd)Ns can't use a list in this contextssee 'hg help "revsets.x or y"')hintr)r&r'r7optsr)r)r*listset]srcCr)Ns*can't use a key-value pair in this contextr)r&r'kvr"r)r)r* keyvaluepairdrrcsht|}|tvrt|}t|ddr|||||S||||SddfddtD}t||)N _takeorderFcSst|ddduS)N__doc__r)fnr)r)r*pzfunc..csg|] \}}|r|qSr)r))rlrrkeepr)r*rmrrnzfunc..)rosymbolsritemsrrr)r&r'rcrdr"ffuncsymsr)rr*rhs   rs _destupdatecCs2t|dd}|ttj|fit|dg@S)Nlimitscleanr) getargsdictr?r destupdater strkwargs)r&r'r(argsr)r)r* _destupdates rs _destmergecCs4d}|durt|t||}|ttj||dg@S)N) sourceset)r+r>r?r destmerge)r&r'r(rr)r)r* _destmergesrs adds(pattern)T)safeweightcCt|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*adds rsancestor(*changeset)g?cCs|tt|t||td}z|t|}Wn ty tYSw|D] }|||}q#t |}||vr;t|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") iterrfr>rXnext StopIterationr?ancestorrr:)r&r'r(reviterancr0r)r)r*rs    rFcC4t|t||}|s tSt|||||}||@Sr3)r+r>r?r r)r&r'r( followfirst startdepth stopdepthheadsrr)r)r* _ancestors rsancestors(set[, depth]))rcCt|dd}d|vrttdd}}d|vr+t|dd}|dkr)td |}d |vrGt|d td }|dkrCttd |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(rrrrHr)r)r* ancestorss&  rs_firstancestorscCt|||ddSNTr)rr&r'r(r)r)r*_firstancestorsrc Cs~t}t|t||D]/}t|D]#}||}t|dkr!nt|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>rangechildrenrRrr/rr.add) r&r'r(rHr"csr0icr)r)r* _childrenspecs     rc Cst|td}|dkrt|||| |St}|j}t|t||D])}t|D]}z ||d}Wq(t j yE|| }Yq(w| |q"||@S)zg``set~n`` Changesets that are the Nth ancestor (first parents only) of a changeset in set. s~ expects a numberr)rrrrrKr+r>r parentrevsrWdirUnsupportedp1r.r) r&r'r(rHr"psclr0rr)r)r* ancestorspecs  rsauthor(string) c<t|td}t|dd\}}|jfddd|fdS)zAlias for ``user(string)``.sauthor requires a stringF casesensitivec|Sr3userr(matcherr&r)r*rrzauthor..s condreprrr_substringmatcherfilter)r&r'r(rHkindpatternr)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 rsbisectedcC t|||Sr3)rrr)r)r*bisected6 rsbookmark([name])c st|ddtd}|rot|dtd}t|\}}}t}|dkrI||kr-j|}j|d} | s?t td|| |  n2t} t jD] \} } || r_| | qR| D] } | |  qbn fdd 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.rkr&r)r* \zbookmark..)getargsrrr stringmatcherr _bookmarks expandnamerrr/rr.r iteritemsvaluesr) r&r'r(rbmrrrbmsbmrev matchrevsnamer)rr*bookmark;s8    rsbranch(string or set)csjfddzt|dWn tjyYn?wt\}}|dkrN|r?|j fdddfdS d rMt t d |n|j fd ddfdSt t|}t|D] }|qi|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`. cs0z|dWStjy|YSwrJ)rrbranchr0)getbir&r)r* getbranchls zbranch..getbranchrc |Sr3r)rrrr)r*r~ zbranch.. rsliteral:sbranch '%s' does not existcrr3r)rrr)r*rrcs|p |vSr3r)r)rdrrr)r*rc dtS)Nrr8r))rdr)r*rr)revbranchcache branchinforrr#rr branchmap hasbranchr startswithr/rr+r>rr __contains__)r&r'r(rrrr0r))rdrrrrr&r*ras>     rsphasedivergent()cC&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*r(s r(sbundle()cCs0z |jj}W||@Styttdw)zIChangesets in the bundle. Bundle must be specified by the -R option.s$no bundle provided - specify with -R)rK bundlerevsAttributeErrorrAbortr)r&r'r(r)r)r)r*bundles   r,csBtdkdgfdd}|j|dtfdS)zuHelper for status-related revsets (adds, removes, modifies). The field parameter says which kind is desired. rNcs|}dr rtjjg|dd<dd}dus%Js7tdkr7d}|durD||vrCdSntfdd|DsSdSt | | }|durn||vrldSdStfdd|Dr{dSdS) NrctxrFc3|]}|VqdSr3r)rlrrGr)r* z/checkstatus..matches..Tc3r/r3r)r0r1r)r*r2r3) matchmodrrootgetcwdanypatsrRfilesanyrrrnode)r(rfnamer8fieldhassetmcacherr&r1r*matchess,    zcheckstatus..matchessr)r4patkindrrsysbytes)r&r'rr=r@r)r<r*rs rc Cst|stSt}|jj}|}|D]#}||krq||\}}||vr(|||tkr5||vr5||qt|Sr3)r?rrKrrwrr) r&r' parentsetrprminrevr0rp2r)r)r* _childrens   rGs children(set)cCs$t|t||}t|||}||@S)z&Child changesets of changesets in set.)r+r>rG)r&r'r(rrr)r)r*rs rsclosed()cs(t|ddtd|jfddddS)zChangeset is closed.rsclosed takes no argumentsc |Sr3) closesbranchrrr)r*rrzclosed..sr)rrrrr)rr*closeds rJs_commonancestorheads(set)cCs0t|t||td}|jjt|}|t|@S)Nr)r+r>rXrK_commonancestorsheadslistr?)r&r'r( startrevsancsr)r)r*_commonancestorheadss rOscommonancestors(set)cCsBt|t||td}|stS|D] }|t|t|gM}q|S)z8Changesets that are ancestors of every changeset in set.r)r+r>rXr?r r)r&r'r(rMr0r)r)r*commonancestorss rPsconflictlocal()cCZt|ddtdddlm}|j|}|r*|j|jr*||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) rrrSreadactiverKhasnodelocalr.r?r&r'r( mergestatemodrSr)r)r* conflictlocal   r[sconflictother()cCrQ)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 argumentsrrR) rrrTrSrUrVrKrWotherr.r?rYr)r)r* conflictother r\r^scontains(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 patterncsttstj}||vrdSdS|}tjjg|d}|D] }||r7dSq.dS)NTr-F)r4rAr canonpathr5r6rmanifest)r(patsrrGrrr&r)r*r@<s   zcontains..matchess r)rrrr&r'r(r@r)rcr*contains0s  resconverted([id])csTdt|ddtd}|rt|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}|duodup|S)Nsconvert_revision)r-rr!)r0source)r&r.r)r* _matchvalue\szconverted.._matchvaluec|Sr3r)rrgr)r*razconverted..sr)rrrrr&r'r(lr))rgr&r.r* convertedLs rmsdate(interval)cs4t|td}t||jfddd|fdS)z5Changesets within the interval, see :hg:`help dates`.sdate requires a stringcs|dSrJdaterdmr&r)r*rlrzdate..s r)rrr matchdater)r&r'r(dsr)rpr*roes  ros desc(string)cr)zSearch commit message for string. The match is case-insensitive. Pattern matching is supported for `string`. See :hg:`help revisions.patterns`. sdesc requires a stringFrcrr3 descriptionrrr)r*r}rzdesc..s rr)r&r'r(rsrrr)rr*descps rvcCrr3)r+r>r?r r)r&r'r(rrrrootsrr)r)r* _descendantsrrxsdescendants(set[, depth])cCr)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#rrrxrr)r)r* descendantss*   rys_firstdescendantscCrr)rxrr)r)r*_firstdescendantsrrzsdestination([set])cs|dur t|t||}nt|}t|D]2}t||}d}|durH|dur*t}||||vs7|vr=|n |}t||}|dus#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(). Ncr)Nsrr)destsr)r*rrzdestination..r) r+r>rr2rLappendupdaterr")r&r'r(sourcesr0srclineager)r{r* destinations,     rsdiffcontains(pattern)ncst|dd}d|vrttdt|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) searchfilesr?rgrepmoddifflinestates)r.foundrr.pstatesstates)rsearcherr)r*testdiffs zdiffcontains..testdiffsr)rrr#rrrsubstringregexpreMr4alwaysr grepsearcheruir)r&r'r(rrregexprr))rrrr* diffcontainss    rscontentdivergent()cCr#)zh Final successors of changesets with an alternative set of final successors. (EXPERIMENTAL) rs#contentdivergent takes no argumentscontentdivergentr%)r&r'r(contentdivergentr)r)r*rs rsexpectsize(set[, size]))r takeorderc Cst|dd}d}t|d}d}d|vsd|vrttdt|dtd td ||\}}|dks7|dkr>ttd t|t||d|d }||krft||ksZt||krftd ||t|f}n||krzt||krztd|t|f}|rt||t kr||@S||@S)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 sizerrrssizersinvalid 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 %d) rrRrr#rrr+r>r/rA) r&r'r(r"rminsizemaxsizeerrr.r)r)r* expectsizes@    rsextdata(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)rrrrr extdatasourcer?)r&r'r(rrfdatar)r)r*extdataFs   rs extinct()cCr#)zBObsolete changesets with obsolete descendants only. (EXPERIMENTAL)rsextinct takes no argumentssextinctr%)r&r'r(extinctsr)r)r*extinctT rsextra(label, [value])cst|dd}d|vrttdt|dtddd|vr1t|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(|}|vodup|Sr3)r-)r0r-)r1rr&valuer)r*rgvs zextra.._matchvaluecrhr3r)rrir)r*r{rjzextra..sr)rrr#rrrrr)r&r'r(rrr))rgr1rr&rr*r-]s   r-sfilelog(pattern)c st|td}t}|j}t|s t|j| |}|g}ntj |j| |g|ddfdd|dD}|D]}| |}i} d} t |D]o} | | } | | vr^|| | qK|| } | |vrm|| qK| durt| | d}d} ||D]:}|||vr|||vrz|||}|| vr|| kr|||} Wn|| |<WqtjyYqwqqKq<||@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 patternNr-c3s|] }|r|VqdSr3r)r0r1r)r*r2zfilelog..rr)rrrrKr4rArr`r5r6rfilerLr:rlinkrevrxrrevision readfilesfilenoderManifestLookupError)r&r'r(rrrrr8flknownscanposfrrlrstartr0rHr)r1r*filelogsP       rsfirst(set, [n]))rrrcCt||||S)zAn alias for limit().)limitr%r)r)r*rDsrDc st||d}d}d|vrt|t||d}d|vrjt|dtd|}|dur,dg}g}|D]/}||} |dur@|dtj|j||g| dd} | fdd  | Dq0t ||} || @S|durwt|dg}t |||} || @S) Ns file startrevstartrevfiles%s expected a pattern.spath)r.defaultc3|] }|VqdSr3) introfilectxr0r-r)r*r2rz_follow..)rr+r>rrr4rr5r6extendrawalkr filerevancestorsr?r.r) r&r'r(rrrrfctxsr0mctxrGrr)r-r*_follows.  $ rsfollow([file[, startrev]])cCst|||dS) 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!rrr)r)r*followsr _followfirstcCst|||dddS)NrTrrrr)r)r* _followfirstsrs?followlines(file, fromline:toline[, startrev=., descend=False])cCs<t|dd}t|ddkrttdd}d|vr6t|t||d}t|dkr2ttd|}t|d td }td }t ||||}t j t |dd td td\} } |||} d} d|vrtt|dtd} | rtddt| | | Ddd} || @Stddt| | | 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 rangerrs(followlines expects exactly one revisionrsfollowlines 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 booleancs|] \}}|VqdSr3rrlr _lineranger)r)r*r2&  zfollowlines..T)iterasccsrr3rrr)r)r*r20r)rrRrr#rr+r>rErrparsefollowlinespatternrprocesslinerangerfilectx getboolean generatorsetr blockdescendantsblockancestors)r&r'r(rr.rrmsgr;fromlinetolinefctxdescendrsr)r)r* followliness^     rsnodefromfile(path)c Cst|td}t}z/t|d}|D]}|}t||}|dur(||qWdn1s3wYWntyX} ztd} | |t | j f;} t | d} ~ ww|t|@S)rs nodefromfile require a file pathrbNscannot open nodes file "%s": %s)rrrropenstrip_noderIOErrorr strtolocalstrerrorrr+r?) r&r'r(path listed_revrlinerHrnexcrGr)r)r* nodefromfile;s(    rsall()cCst|ddtd|t|@S)z&All changesets, the same as ``0:tip``.rsall takes no arguments)rrrQrr)r)r*getallRs rs grep(regex)c snz tt|tdWntjy%}z ttdt|d}~wwfdd}|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] }|rdSqdSNTF)r8rrusearch)r(regrr&r)r*r@hs  zgrep..matchess r) rcompilerrrr#r forcebytestrrr)r&r'r(rr@r)rr*rZsrs _matchfilesc sPt|ddd}gggd\|D]_}t|d}|dd|dd}}|dkr3|q|dkr=|q|d krG|q|d kr^durTtd |d kr[tq|q|d krndurktd|qtd|sydtddDdgjjf dd}|j |dfdS)Nrs*_matchfiles requires at least one argumentrvs%_matchfiles requires string argumentsr`p:si:sx:sr:s)_matchfiles expected at most one revisionrsd:s-_matchfiles expected at most one default modesinvalid _matchfiles prefix: %ssglobcss|] }t|dkVqdS)rN)r4rArlrbr)r)r*r2sz_matchfiles..c s|tkr |}n|}drr4dur4dur|n}tjj|dd<d}|D] }||rCdSq:dS)Nr)includeexcluder.rTF)r r8r4rr5r6)r(r8r0rGr rrgetfilesr>incr?rbr&r.r)r*r@s(  z_matchfiles..matchessCr) rrr}rr#r r9rKrr) r&r'r(rlargrprefixrr@r)rr* _matchfilesrsV    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 patternstringr)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)rlhrr)r*r2szhead..)rrrrKr iterheadsr~r?)r&r'r(hslsr)rr*heads  rs heads(set)cCs|tkrt}t|t|||d}d}t|vr*dd|dD}t|}|t|j |}|dur>| || tt |}||@S)z'Members of set with no children in set.rNcSg|]}|qSr)rrr)r)r*rmrzheads..) rSrAr+r>r parentsrdiscardrKheadrevsdifference_updaterr?)r&r'r(r"inputset wdirparentsrr)r)r*rs    rshidden()cCr#)zHidden changesets.rshidden takes no argumentssvisible)rrr filterrevs)r&r'r( hiddenrevsr)r)r*hiddenrr skeyword(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)rlt)kwr)r*r2s  z+keyword..matches..)r9r8rru)r0rr r&r)r*r@s zkeyword..matchess r)r rrrrrdr)rr*keywords rslimit(set[, n[, offset]])c Cst|dd}d|vrttdt|dtddd}|d kr(ttd 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)rrnegative number to selectsoffsetsnegative offset) rrr#rrrr+r>slicerA) r&r'r(r"rlimofsosrr)r)r*rs rslast(set, [n])cCst|ddtd}d}t|dkrt|dtd}|dkr%ttdt|t||d}|| d|}|t krE|dkrE||@S|||@S)z'Last n members of set, defaulting to 1.rr`s"last requires one or two argumentsslast expects a numberrr) rrrRrrr#r+r>reverserrA)r&r'r(r"rlrrrr)r)r*rE2s  rEsmax(set)cC^t|t||}z|}||vrt|gd||fdWSWn ty&Ynwtd||fdS)z.Changeset with highest revision number in set.s datarepr)r+r>rxr? ValueErrorr&r'r(rrGr)r)r*maxrevF rsmerge()cs4t|ddtdjfdd}|j|ddS)zChangeset is a merge changeset.rsmerge takes no argumentscs:z |dtkWStjyt|YSwrP)rrrrboolrFrrr&r)r*ismerge\s zmerge..ismergesr)rrrKr)r&r'r(r r)rr*mergeUsr!s branchpoint()cst|ddtd|j}|stSt|dgt||jddD]}||D]}|kr=|d7<q-q&|jfddddS) z$Changesets with more than one child.rsbranchpoint takes no argumentsr)rcs|dkSrPr)rbaserev parentscountr)r*rvrzbranchpoint..s r) rrrKr?rwrRrrr)r&r'r(rr0rbr)r"r* branchpointesr%smin(set)cCr)z-Changeset with lowest revision number in set.s r)r+r>rwr?rrr)r)r*rEzrrEsmodifies(pattern)cCr)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*modifiesrr'snamed(namespace)c st|ddtd}t|dtd}t|\}}}t}|dkr8|jvr/ttd|| j|nt jD] \} }|| rK| |q>t} |D]}| D]} | |j vro| fdd|| DqXqQ| 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 existc3rr3rrlrHrr)r*r2rznamed..)rrrrrrnamesrr/rrr  listnames deprecatedr~nodesr) r&r'r(rnsrrr namespacesrr)r)rr*nameds4      r/c Csd}t|d|jjkr2z |jt|}W|Stjy$t}Y|St t fy1d}Y|Swzt ||}|durF|j|}W|SW|St yRY|Stjy^t}Y|Sw)zprocess a node inputNr`) rR nodeconstantsnodelenrKr.rrrr LookupError TypeErrorrresolvehexnodeidprefix)r&rHrpmr)r)r*rs4    rs id(string)cCsNt|ddtd}t|dtd}t||}|durtSt|g}||@S)zBRevision non-ambiguously specified by the given hex string prefix.rsid requires one argumentrsid requires a stringN)rrrrr?)r&r'r(rlrHrresultr)r)r*node_s  r7snone()cCst|ddtdtS)zNo changesets.rsnone takes no arguments)rrr?rr)r)r*nonesr8s obsolete()cCr#)z6Mutable changeset with a newer version. (EXPERIMENTAL)rsobsolete takes no argumentssobsoleter%)r&r'r( obsoletesr)r)r*rrrsonly(set, [set])cs|j}t|ddtd}t|t||dt|dkr7s!tStt |dfdd| D}n t|t||d}t|j |d}||@S) aChangesets that are ancestors of the first set that are not ancestors of any other head in the repo. If a second set is specified, the result is ancestors of the first set that are not ancestors of the second set (i.e. :: - ::). rr`sonly takes one or two argumentsrFcs g|] }|vr|vr|qSr)r)rlr.ryrr)r*rms zonly..)commonr) rKrrr+r>rRr?rr rrfindmissingrevs)r&r'r(rrrresultsr)r;r*onlys  r?s origin([set])csR|dur tt|}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. Ncs4t|}|dur dS t|}|dur|S|}q r3)r2)r.rprevrr)r* _firstsrcs  zorigin.._firstsrcch|]}|qSr)r)rk)rAr)r*r*rzorigin..)r+r>)r&r'r(r|or))rAr&r*origins   rDsoutgoing([path])c s4ddlm}m}t|ddtd}|rt|dtdpd}|r$|g}ng}t}tj |D]X} | j p8| j }| j gf} | | g\} } | rSfdd| D} |i|} z#j |j| | d }Wd n1sswYW| n| w||jq1jfd 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 pathrcsg|]}|qSr)lookupr:rr)r*rmPzoutgoing..) onlyheadsNcsh|]}|qSr)rrkrr)r*r[rIzoutgoing..)rTrErFrrrrr get_push_pathsrpushloclocr addbranchrevspeersilentfindcommonoutgoingcloser~missingrK)r&r'r(rErFrldestr|rSrbranchesrcheckoutr]outgoingrCr)rr*rW1s6    rWs p1([set])c Cs|dur||}|dkr|t|g@StSt}|j}t|t||D]#}z |||dWq(t j yK|||Yq(w|t h8}||@S)zrrrrr)r&r'r(rbrrr0r)r)r*r_s rs p2([set])c Cs|dur-||}z|d}|dkr|t|g@WStWSty,tYSwt}|j}t|t||D]+}z || |dWq;t j yf||}t |dkrd||dYq;w|t h8}||@S)z=Second parent of changesets in set, or the working directory.Nrrr`)rr.r? IndexErrorrrKr+r>rrrrrRr)r&r'r(rrbrr0rr)r)r*rFus.       rFcCrr3)rr%r)r)r* parentposts rYsparents([set])c Cs|durdd||D}n6t}|j}|j}|j}t|t||D]!}z|||Wq$tjyE|dd||DYq$w|t h8}||@S)zU The set of all parents for all changesets in set, or the working directory. NcSsh|]}|qSr)rrr)r)r*rrzparents..css|]}|VqdSr3rrr)r)r*r2r3zparents..) rrrKr~rr+r>rrr)r&r'r(rruprr0r)r)r*rs rcGs|j|||S)z,helper to select all rev in phases) _phasecache getrevset)r&r'targetsr)r)r*_phaser^s _phase(idx)cCs(t|ddd}t|dd}t|||S)Nrs_phase requires one argumentrs_phase expects a number)rrr^)r&r'r(rltargetr)r)r*phases rasdraft()cC$t|ddtdtj}t|||S)zChangeset in draft phase.rsdraft takes no arguments)rrrdraftr^r&r'r(r`r)r)r*rc rcssecret()cCrb)zChangeset in secret phase.rssecret takes no arguments)rrrsecretr^rdr)r)r*rfrerfs stack([revs])cCsV|dur t|}||@Stg}t|t||D] }t||}||}q||@S)zdExperimental revset for the stack of changesets or working directory parent. (EXPERIMENTAL) N)stackmodgetstackrr?r+r>)r&r'r(stacksr currentstackr)r)r*rs    rc Cs.zt|d}|dvr tWnttfyttdwt}|j}t|t ||D]e}|dkr9| |q-|dkr_z | | |dWq-tj y^| || Yq-wz| |}|dtkrr| |dWq-tj y||}t|dkr| |dYq-w||@S)z``set^0`` The set. ``set^1`` (or ``set^``), ``set^2`` First or second parent, respectively, of all changesets in set. r)rrr`s^ expects a number 0, 1, or 2rr`)intrr3rr#rrrKr+r>rrrrr.rrrR) r&r'r(rHr"rrr0rr)r)r* parentspecs>      rls present(set)cCs,zt||||WStjytYSw)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. )r+rr/r?r%r)r)r*presents   rm _notpubliccCs t|dddt||tjtjS)Nrs_notpublic takes no arguments)rr^rrcrfrr)r)r* _notpublic sros"_phaseandancestors(phasename, set)c st|ddd}t|d}tt|d}tjtj}|d}||vr.td|||j j fdd}t j ||d } |d krU| fd d } || @S) Nr`s)_phaseandancestors requires two argumentsrr)rndraftssecrets%r is not a valid phasenamecs|kSr3r)r)getphase minimalphaser&r)r*cutfunc&rz#_phaseandancestors..cutfunc)rsrpcs|kSr3r)r)rcrqr&r)r*r,z$_phaseandancestors..)rror+r>rrcrfrr#r[rar rr) r&r'r(r phasenamerrf phasenamemaprsrr))rcrqrrr&r*_phaseandancestorss$ rwspublic()cCs t|ddtdt||tjS)zChangeset in public phase.rspublic takes no arguments)rrr^rpublicrr)r)r*rx0srxsremote([id [,path]])c Csddlm}t|ddtd}d}t|dkr t|dtd}|dkr*|d}d}t|dkr;t|dtd }|s?d }td ||j |\}}| |i|}| |} | |vri||  } | |vrit | 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)rFrr`s(remote takes zero, one, or two argumentsrsremote requires a string idrs!remote requires a repository pathsdefaultsremote)rTrFrrrRrrr get_unique_pull_pathrrOrHr.r?) r&r'r(rFrlqrTrUr]rHr0r)r)r*remote8s,        r{sremoves(pattern)cCr)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^rr}s rev(number)cCs*zt|||WStjytYSw)z+Revision with the given numeric identifier.)_revrr/r?rr)r)r*r.ks  r.s _rev(number)c Cst|ddtd}z tt|dtd}Wnttfy&ttdw|tvrDz|j |Wnt yCt td|w|t |g@S)Nrsrev requires one argumentrsrev requires a numbersrev expects a numbersunknown revision '%d')rrrkrr3rrr#r<rKr:rXr/r?rkr)r)r*r~ts r~s revset(set)cCr)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|dkr't|dtd}g}|D]#}|dkr8|gd7}q+|dkrC|d dg7}q+|d krId }||q+t|}d |vr`d |vr`| d gdfdd}t |}|j |dgfddfddfddfddfddfddfddfddfddfddd }|D]} | | d} | durt td| | qfd 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. rr`smatching takes 1 or 2 argumentsrsmetadatas1matching requires a string as its second argument)user descriptiondatedifffilesauthorrsummaryr) phaseparentsrrbranchrrrsubstatercs(z|WStytYSwr3)indexrrR)r) fieldorderr)r* fieldkeyfuncs    zmatching..fieldkeyfunc)keycrHr3rrrr)r*rrzmatching..crHr3rrrr)r*rrcrHr3rnrrr)r*rrcrHr3rtrrr)r*rrcrHr3)r8rrr)r*rrcrHr3)rrrr)r*rrcrHr3)rarrr)r*rrcs |jSr3)substaterrr)r*rs cs|dSrJ)ru splitlinesrrr)r*rrcs"t|jtjddidS)NsgitT)r)rLrr diffalloptsrrrr)r*rs) rrrrrrrrrrNs,unexpected field name passed to matching: %scsfddDS)Ncsg|]}|qSr)r)r0rr)r*rm rz.matching....r)r) getfieldfuncsrr*r scsJD] }|}d}tD]\}}||||krd}q|r"dSqdSr) enumerate)r(r.r`rrHr)rgetinforr)r*r@ szmatching..matchessr)rrr+r>rRrsplitr}rrrLsortrrr#r) r&r'r(rl fieldlistfieldsr=r_funcsinfogetfieldr@r))rrrr&rr*matchingsd                    rs reverse(set)cCs"t||||}|tkr||S)zReverse order of set.)r+rSr)r&r'r(r"rlr)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))r0rbrrr)r*r# s zroots..filtersr)r+r>rKrr)r&r'r(rr)rr*rw srwcC|Sr3rrr)r)r*r. rjrcCrr3rtrr)r)r*r/ rjcCrr3rrr)r)r*r0 rjcCrr3rrr)r)r*r1 rjcCs |dSrJrnrr)r)r*r2 r)revrsdescrrrsnodecCst|dd}d|vrttdd}d|vr t|dtd}g}|D],}|}|d}|r7|d d }|tvrK|d krKttd t || ||fq&t |d krit d d|Drittdi}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 %rcs|] \}}|dkVqdSrNr)rlrrr)r)r*r2N rz_getsortargs..s7topo sort order cannot be combined with other sort keystopo.firstbranchcsrrr)rr)r)r*r2V rs>topo.firstbranch can only be used when using the topo sort key) rrr#rrrr! _sortkeyfuncsrbytestrr}rRr9)r(rrqkeyflagsrfkrrr)r)r* _getsortargs7 s>    rssort(set[, [-]key... [, ...]])c st|\}}}t|||}|r|tkr|St|dkr0|dddkr0|j|ddd|S|dddkr_d}d|vrFt||d}tt|jj |dd }|ddr]| |Sfd d |D} t |D] \} } | jt | | d qltd 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)istopocsg|]}|qSr)r)rkrr)r*rm rzsort..)rrcSrr)r)rlrr)r)r*rm r) rr+rSrRrr?r toposortrKrrreversedr) r&r'r(r"rrrr firstbranchctxsrrr)rr*rd s,  rssubrepo([pattern])cspt|ddtd}dt|dkrt|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|Vq dSr3)rr)r)rrbrGr)rr)r* submatches szsubrepo..submatchescs|}j||d}dur|jp|jp|jS|jr+t|jS|jrWt |j}| |j|D]}|j ||j |krVdSqC|jret|jSdS)N)rTF) rrr:rr&r|r9rrqrr~r)r(rrsubsrrGrr&rr)r*r@ s  zsubrepo..matchess r)rrrRrr4exactr)r&r'r(rr@r)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. crBr)r)r()torevr)r*r rz!_mapbynodefunc..c3r/r3r)rk)tonoder)r*r2 r3z!_mapbynodefunc..N) unfilteredrKrget_revr:rrr? filteredrevs)r&rrrr6r))rrr*_mapbynodefunc s $ rssuccessors(set)cs0tt|}fdd}t||}||@S)zNAll successors for set, including the given set themselves. (EXPERIMENTAL)cstj|Sr3)r allsuccessorsobsstore)r,rr)r*r rtzsuccessors..)r+r>r)r&r'r(rrdr)rr* successors s  rcsNtj|d\}}|dkr"|stfdd}nfdd}||fS)Nrrcst|vSr3r rrr)r*r rtz#_substringmatcher..cs|vSr3r)rrr)r*r rj)rrr r)rrrrr)rr*r s    rs tag([name])cst|ddtd}|j|rSt|dtd}t|\}}|dkrC|jj|d}|dur8t td||| h}||@Sfdd | D}||@Sfd 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)rrlr rHrrr)r*r "ztag..cs"h|] \}}|dkr|qS)stiprrrr)r*r r) rrrKrrr _tagscachetagsrrr/r.tagslist)r&r'r(rrrtnrr)rr*tag s( rstaggedcCrr3)rrr)r)r*tagged rrsorphan()cCr#)z?Non-obsolete changesets with obsolete ancestors. (EXPERIMENTAL)rsorphan takes no argumentsorphanr%)r&r'r(orphanr)r)r*r rrs unstable()cCsVt|dddt}|t|d|t|d|t|d|t|@S)z-Changesets with instabilities. (EXPERIMENTAL)rsunstable takes no argumentsrr$r)rrr~r&r'r?)r&r'r( _unstabler)r)r*unstable s  rs user(string)cCr)zUser name contains string. The match is case-insensitive. Pattern matching is supported for `string`. See :hg:`help revisions.patterns`. )rrr)r)r*r" s rswdir()cCs4t|ddtdt|vst|trttgStS)z!Working directory. (EXPERIMENTAL)rswdir takes no arguments)rrr r=r>r?rr)r)r*wdir, s rc Cst|d}|s tS|j}g}t}|dD]I}zt|}d||ks(||vr*t|g} Wnty>t|||t} Ynw| D]}||vrHqA||vsU|t vrZt |t rZ| || |qAqt|S)Ninternal errors%d)rr?rKrrrkrr@rSr<r=r>r}r) r&r'r(rrrseenr r0rr)r)r* _orderedlist6 s4      rs_listcC(|tkr|t|t||@St|||Sr3)rArr>r%r)r)r*_listW  rcsBt|ds tSdddD}|tfdd|DS)NrcSsg|]}t|qSr))rkrkr)r)r*rmd rz#_orderedintlist..rcg|]}|vr|qSr)r)rkrr)r*rmf r)rr?rr&r'r(rr)rr*_orderedintlist` s rs_intlistcCrr3)rArr>r%r)r)r*_intlistj rrcsLt|ds tS|jfdddD}|tfdd|DS)Nrcsg|] }t|qSr))r.rrkrr)r*rmx sz#_orderedhexlist..rcrr)r)rkrr)r*rmz r)rr?rKrrr))rrr*_orderedhexlists s rs_hexlistcCrr3)rArr>r%r)r)r*_hexlist~ rrsranger|srangepres rangepostsdagrangerssymbolsands andsmallyorsnots differencesrelations relsubscripts subscriptlistskeyvalue)sfuncsancestorsparents parentpostssmartset)gs generationscsfdd}|S)Ncs.zt|WStjytd|w)Ns!ambiguous revision identifier: %s)r isrevsymbolrAmbiguousPrefixLookupError InputError)symbolrr)r*r szlookupfn..fnr))r&rr)rr*lookupfn s rcCst||g|dS)z+Create a matcher for a single revision specrG)matchany)rspecrHr)r)r*r r_rcs|s d dd}|St|sttdt|dkr#t|d}nddtfd d |Df}g}d}|rC|| d |j }|rL|| |rVtj |||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)rc3s|] }t|VqdSr3)rparse)rlrrGr)r*r2 rzmatchany..s revsetalias)warnr3)allrr#rrRrrtupler configitemsrr expandaliases foldconcatanalyzeoptimize makematcher)rspecsrH localaliasrtreealiasesrr)rGr*r s.     rcsdfdd }|S)z)Create a matcher from an evaluatable treeNcs8|dur |dur t}nt}|durt|}t|||Sr3)rSrAr>r+)r&r'r"rr)r*r szmakematcher..mfuncrvr))rrr)rr*r s rcCs2t|jD]\}}|t|<|jrt|qdS)z2Load revset predicates from specified registrarobjN)rr _tabler_safe safesymbolsr)rextname registrarobjrrr)r)r* loadpredicate s  r)FNN)F)Tr3rv) __future__rri18nrrrr:rrr rTr r r r rrrrrr4rr&rrrrrrrrrrgrutilsrrr rorrrrerrrr?rrQr>r<rXrSrAr+r2r8r@rBrIrMrNrOrCrVr[r\r_rarfrgrur{rr}rrrrrrrrr predicaterrrrrrrrrrrrrrr(r,rrGrrJrOrPr[r^rermrorvrxryrzrrrrrrr-rrDrrrrrrrrrrr rrrErr!r%rEr'r/rr7r8r?rDrWrrFrYrr^rarcrfrlrmrorwrxr{r}r.r~rrrwr:binnoderrrrrrrrrrrrrrrrrrrr$rprrrrrr  i18nfunctionsr)r)r)r*s   X(                          %  3   %                  !    /  )   +     ! ?      E        Z                     %        -         "    %          - . ,        !             )