^c$.ddlmZddlmZddlmZmZmZm Z m Z m Z m Z mZdZdZdZdZdZd Zd d Zd Zd ZdZd!dZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%d"dZ&dS)#)_)getattr)errormatchmerge mergestate requirementsscmutilsparseutils narrowspecsnarrowspec.dirstate)spath:s rootfilesin:cR|d}t|||fS)zReturns the normalized version of a pattern and kind. Returns a tuple with the normalized kind and normalized pattern. /)rstrip_validatepattern)kindpats 6/usr/lib/python3/dist-packages/mercurial/narrowspec.pynormalizesplitpatternr's- **T  CS 9cJt|dzS)z?Returns the number of lines in s, including ending empty lines.x)len splitlines)ss r _numlinesr1s" D$$&& ' ''rct|dkr!tjtd|d}d|vsd|vr!tjtddS)zValidates the pattern and aborts if it is invalid. Patterns are stored in the narrowspec as newline-separated POSIX-style bytestring paths. There's no escaping. rs,newlines are not allowed in narrowspec pathsr.s..s0"." and ".." are not allowed in narrowspec pathsN)rrAbortrsplit)r componentss rrr9sz~~k!KLLMMM4J zUj00k A B B   10rpathcXtj||\}}dt||zS)zyReturns the normalized version of a text-format pattern. If the pattern has no kind, the default will be added. s%s:%s)matchmod _patsplitr)pattern defaultkindrrs rnormalizepatternr'Ls0 "7K88ID# +D#66 66rc<d|D}t||S)aParses an iterable of patterns into a typed pattern set. Patterns are assumed to be ``path:`` if no prefix is present. For safety and performance reasons, only some prefixes are allowed. See ``validatepatterns()``. This function should be used on patterns that come from the user to normalize and validate them to the internal data structure used for representing patterns. c,h|]}t|S)r').0origs r z parsepatterns..`s! 3 3 3d D ! ! 3 3 3r)validatepatterns)patsress r parsepatternsr1Us* 4 3d 3 3 3CS Jrc tjdt|5t|tst jd|z|D]j}|tsNt j td|ztdd tzk ddddS#1swxYwYdS)aValidate that patterns are in the expected data structure and format. And that is a set of normalized patterns beginning with ``path:`` or ``rootfilesin:``. This function should be used to validate internal data structures and patterns that are loaded from sources that use the internal, prefixed pattern representation (but can't necessarily be fully trusted). z)narrowspec.validatepatterns(pats size=%d)s'narrow patterns should be a set; got %rs$invalid prefix on narrow pattern: %ss8narrow patterns must begin with one of the following: %ss, hintN) r timedcmr isinstancesetrProgrammingError startswithVALID_PREFIXESrrjoin)r/rs rr.r.es3 A3t99 M M$$$ (:TA   C>>.11 k=>>D-jj00 1   sBC  CCcd}t||z D] }||dzz } |dz }t|D] }||dzz } |S)Ns [include]  s [exclude] )sorted)includesexcludesoutputies rformatrDsi F Hx' ( (!e) nF H  !e) MrNcf|stjStj|dg|pg|pgS)Nrincludeexclude)r#neverr)rootrGrHs rrrsF  ~ > c2w}"gm   rctj||d\}}}|r!tjt dt |t |||fS)NsnarrowsJincluding other spec files using '%include' is not supported in narrowspec)r parseconfigrrrr.)uispec includepats excludepatsprofiless rrLrLst)/);Bi)P)P&Kh k ,     [!!![!!!  ##rcj|jt}t|j|SN)svfstryreadFILENAMErLrMreporNs rloadrYs+ 9  X & &D tw % %%rct|t|t||}|jt|dSrS)r.rDrTwriterV)rXrOrPrNs rsaver\sI[!!![!!! +{ + +DIOOHd#####rc|jt}|jt |dSrS)rTreadrVvfsr[DIRSTATE_FILENAMErWs rcopytoworkingcopyras2 9>>( # #DHNN$d+++++rctj|jvrdS|j}||t j|t||ddSNT)hardlink)r NARROW_REQUIREMENTrT tryunlinkr copyfiler;rV)rX backupnamerTs r savebackuprisf&d.??? 9DNN:M$))H%%tyy'<'> E '' 444E 5 '' 444 |   ! !%;LL|,,LL<(( '7 77rcD|D]}|j|dSrS)wvfs unlinkpath)rXfilesfs r_deletecleanfilesr s4    Q  rcXtj}|d}|D]S}|j|s7||t j||dfdTtj |||d|ddddS)NrFsnarrowspec updated)wctxmctx overwrite wantfiledata) r mergeresultmanifestrroaddfile mergestatemod ACTION_GETflags applyupdates)rXpctxrmresultmfrs r_writeaddedfilesrs!!G d    B y""  OO(!e$%        $Z $Z rct|ddrdS|jt}|jt }||kr0t jtdtddS)N_updatingnarrowspecFs"working copy's narrowspec is stales&run 'hg tracked --update-working-copy'r3) rrTrUrVr_r`r StateErrorr)rX storespecwcspecs rcheckworkingcopynarrowspecr'st*E22 !!(++I X  / 0 0F  3 4 4<==    rFc|jt}|jt}d|_t |j|\}}t |j|\}}t|j ||}t|j ||} tj | |} tj || } |j  | gddd\} } }| j| jz}| j}|r|| n|| t%||t'j|}t+|D]5}|j t-d||z6t+| jD]5}|j t-d||z6t+| jD]5}|j t-d||z6||zD]}|dd|d }tj| t7j|} fd || D}|D]}|ddd t?|||d|_d S) zupdates the working copy and dirstate from the store narrowspec When assumeclean=True, files that are not known to be clean will also be deleted. It is then up to the caller to make sure they are clean. TrF)subreposignoredcleanunknowns$not deleting possibly dirty file %s snot deleting unknown file %s snot deleting ignored file %s F) p1_tracked wc_trackedrcg|]}|v| Sr*r*)r+rdss r z%updateworkingcopy..`sKKKaq{{{{{r)rrpossibly_dirtyN) r_rUr`rTrVrrLrMrrJr#differencematcherdirstatestatusmodifiedaddedrextendrr getuipathfnr>rrr update_fileintersectmatchersr matcherrwalkr)rX assumecleanoldspecnewspec oldincludes oldexcludes newincludes newexcludesoldmatchnewmatch addedmatch removedmatchlookupr_mtime_boundary trackeddirtyruipathfnrrnewfilesrs @rupdateworkingcopyr4s h011Gi))G#D*47G<<K*47G<<KTY [IIIHTY [IIIH+Hh??J-hAAL B&(iir4tT'0''#FFO?V\1L LE$ VF###dE""""4((H L ! !    6 7 7((1++ E    FN # #KK q:;;hhqkkIJJJJ FN # #KK q:;;hhqkkIJJJJ \ !>> qUu==== :D+Jt8L8LMMJKKKK4==??// ;;KKKH QQ qTd4PPPPT4***$Dr)r!)NN)F)'i18nrpycompatrrrr#rrrr r r r rVr`r:rrrr'r1r.rDrLrYr\rarirmrprrrtrrrrrr*rrrs                     * (((   &7777    <$$$"&&&$$$,,, MMMFFF    QQQ### $8$8$8R   *    0%0%0%0%0%0%r