^ckddlZddlmZddlmZddlmZmZm Z m Z m Z mZmZmZmZddlmZdZdZd Zd Zd Zd ZddZdZdZdZdZdZdZ d dZ!dZ"d!dZ#dZ$ d"dZ%d!dZ&d!dZ' d#dZ( d$dZ)dS)%N)_)hex) errormatchmerge mergestatepathutilpycompat requirementsscmutilutil)hashutilFcNt|ddrdStj|jvS)N _has_sparseFT)getattrr SPARSE_REQUIREMENT)repos 2/usr/lib/python3/dist-packages/mercurial/sparse.py use_sparser!s.t]E** t  *d.? ??ctjdt||5t}t}t}d}d}|dD]\}|}|r|dr/|dr4|dd}|r||x|dkr3|r,||kr&tj td d |izd }|}|d krd }|}|r|6tj td ||dztd|dr*| td||dzG||^|||fcdddS#1swxYwYdS)zParse sparse config file content. action is the command which is trigerring this read, can be narrow, sparse Returns a tuple of includes, excludes, and profiles. z+sparse.parseconfig(ui, %d bytes, action=%s)NF #s %include s [include]s5%(action)s config cannot have includes after excludesactionTs [exclude]s4%(action)s config entry outside of section: %(line)s)rslines<add an [include] or [exclude] line to declare the entry type)hint/sPwarning: %(action)s profile cannot use paths starting with /, ignoring %(line)s ) rtimedcmlensetsplitstrip startswithaddrAbortrwarn) uirawactionincludesexcludesprofilescurrent havesectionlines r parseconfigr1+s 5s3xx  ;,;,555555 IIe$$0 "0 "D::<B 7%%i1BCC'GLL%%%%GMM#&&& .9i.. *Iy( OOI & & & OOI & & & OOH % % %5 &8 W Xx ''sDA&FFcfdjD}t}t}t}|D]%}t|\}}}||z}||z}||z}&|||fS)zDetermine the active sparse config rules. Rules are constructed by reading the current sparse config and bringing in referenced profiles from parents of the working directory. cZg|]'}|jk j|(Snullid changelogrA.0noders r z activeconfig..s@     4;   4    r)dirstateparentsr!rH) rrevs allincludes allexcludes allprofilesrAr+r,r-s ` r activeconfigrYs     M))++   D %%K%%K%%K  '5dC'@'@$(Hx x x  [ 00rTc|j}|d}|r|d}nd}||r|ttj|jd}||d<|rR|jd}ttj|}||d<d||fzS)zObtain the signature string for the current sparse configuration. This is used to construct a cache key for matchers. s signatures tempsignature0Nr9 tempsparse%s %s)_sparsesignaturecachegetrrsha1r:r;digest)r includetempcache signature tempsignaturer)s rconfigsignaturerfs  &E ,''I "233  []-B dh&6&6y&A&ABBIIKKLL 'l  4(""=11C c 2 2 9 9 ; ;<">???$$&&&&&rcxt|}|D]}||t||dSN)rrr%ru)r additionalr+rms raddtemporaryincludesry sE$T**H  Q4*****rcJt|r|jdsdS|}|js|js|js|jrdSt|d}|j }tj }g}t|}|D]W}||vrQ||sFtd}||tjd|||Xtj|||d|ddd|D]}||dd|jd|jtd} |j| t1|zdS) Nr\Frbs*dropping temporarily included sparse files. wantfiledata p1_tracked wc_trackedsAcleaned up %d temporarily added file(s) from the sparse checkout )rr:existsstatusmodifiedaddedremoveddeletedmatcherrSmergemod mergeresultrrraddfile mergestatemod ACTION_REMOVEappend applyupdates update_fileunlinkr^rjr(r ) rs sparsematchrSmresultdropped tempincludesfilemessagerDs rprunetemporaryincludesrs d  48??=#A#A AzQW QY$E222K}H"$$GG(..L!! 8  KK$5$5 EFFG OOD-"=tW M M M NN4   gtDz4:u5 GGTeFFFFHOOM"""$$&&&    C GNN3\***+++++rcpd|D}tjd|}tj||gS)zqReturns a matcher that returns true for any of the forced includes before testing against the actual matcher.cg|]}d|dfS)spathrrK)rPincludes rrRz'forceincludematcher..8s@@@G'3'@@@rr)matchmodincludematcher unionmatcher)rr+kindpatsrs rforceincludematcherr5s@A@x@@@H,S(;;N  .'!: ; ;;rc tstjS|r|dgkr%fdjD}t |}d|dttj |fz}j |}|r|Sg}|D]_} t|\}} } |s| r4tj jdg|| d} || P#t $rY\wxYw|stj}n0t#|d kr |d }ntj|}|rt'} t)|| }|j |<|S) zObtain a matcher for sparse working directories for the given revs. If multiple revisions are specified, the matcher is the union of all revs. ``includetemp`` indicates whether to use the temporary sparse profile. NcZg|]'}|jk j|(SrKrLrOs rrRzmatcher..Js@   t{"" N  t $ $"""rr{r] rsrelpath)rexcludedefaultrr)rralwaysrSrTrfrtmapr bytestr_sparsematchercacher_rHrrootrIOErrorr rrrr) rrUrbrdkeyresultmatchersrAr+r,r-rrs ` rrr=s d  !    4D6>>     --//     +>>>I i3x/?+F+F!G!GH HC  % ) )# . .F  H +9$+D+D (Hh )8 )".I$$& (((    D  1"" X!  !&x00;,T22 $V\::$*DS! Ms:A D DDc t|sdSd|D}t||}|rdSt }i}|r6t||g} n#t||g} g} |D]\} } | \} }}|| | | r| || <n{| tj kr| | | || <nP|r"| j s| | | || <n,| tj kr| || <n| |vrtj||f|| <|r8| tj kr(|\}}}}}| |s| |t| dkra|jt%dt| zt'|| t)j}d}|d}| D]J} | |vrD|d| }|| tj|df|K|j5t)j|||d|ddd|j}|tjgD]\} }}|| d d  dddn #1swxYwYt?|d }||z}|ru|ss|}|D]\} || }| | }|s,|r*|| }tj|dfd f|| <F|r|stjgd f|| <]| |dS) zAFilter updates to only lay out files that match the sparse rules.Nc6g|]}|SrK)rA)rPpctxs rrRz(filterupdatesactions..s 555dtxxzz555rrsCtemporarily included %d file(s) in the sparse checkout for merging s%temporarily adding to sparse checkoutFr|r}Trr)!rrTrrr!p1rAfilemapr%r ACTION_MERGErno_op ACTION_FORGETrr r(rrryrrmanifestr ACTION_GETflagsrS parentchanger getactionsrrY setactions) rwctxmctx branchmergeroldrevsoldsparsematchfiles prunedactionsrtemporaryfilesrr*typeargsrDf1f2famoveanctmresultr wctxmanifestfctxrSrr-changedprofilesmfoldnews rfilterupdatesactionsrzs d  55dllnn555GT7++N EEEM2dTWWYY]]__$566 dTXXZZL11 N))** f dC $ ;t   K"(M$   ]/ / /  ! !$ ' ' '"(M$    K: -%%d+++&, d# ]0 0 0"(M$   T\\#0#>c"JM$   *4=#===$( !BBc;r?? *%%b))) >Q  *  .!!  "    T>222')):Dz**,, "  D|##Dz$'  !,ZZ\\5) ] ' ' ) ) M M  !T T "     }H$,$7$7)*%% M M eS$$Tdt$LLLL M M M M M M M M M M M M M M M M D!!!$H&O M{ M ]]__ M MD .&&C+d##C M3 M!,EN' d##  MS M'4'BB&L d# }%%%%%s.A-L((L,/L,ct}||j||j||jt |}d}|D]:}||s-|jtd|z| };|r!tj td|j }|d} g} g} g} | } t| }tj}|D]}||}||}|r|r|r|r||vr| |}|j|r9||t&j|fd| |||t&j|dfd| ||r|r|sA|s?||vr;| |||vr"||t&jgdd}| D]/}|jtd|z| }0|r!tj td|D]8\}}||vr/||}||}|r|s| |9tj|||d|ddd| D]}||d d | D]}||dd | D]}||d d d | | | fS) a Refreshes working directory by taking sparse config into account. The old status and sparse matcher is compared against the current sparse matcher. Will abort if a file with pending changes is being excluded or included unless ``force`` is True. Fspending changes to '%s' s2could not update sparseness due to pending changesr|rsjcannot change sparseness due to pending changes (delete the files or use --force to bring them back dirty)Nr}Tr)rrpossibly_dirty)r!r@rrrrr(r'rrr&rSrrrrwvfsrrr ACTION_EXECrrritemsrr)r origstatusorigsparsematchforcependingrabortfrSrBrlookuprrrrrrrflstates r refreshwdirrseeG NN:&''' NN:#$$$ NN:%&&&$--K E {1~~  GLL7881< = = =IE  k C D D   }H t*C E FG B GGE"$$GLLod##k$  L L L LTX5E5E$By%% #m&?"LLL d####-2RK T"""" L# Ls L3 L48;K;K NN4 7""m&A2sKKK E  Q344t;<<<   k 5      ~~''%% eu}}!/$''C+d##C %3 %t$$$  gtDz4:u5 EETdtDDDDGGTeFFFF   Td4      '6 !!rc8||}t||d}|t|zr6|}t |}t |||dt|dS)z1Perform actions after a working directory commit.rTrN)rHrAr!rrrrr)rrQrBr-rrs r aftercommitrRs t*CdCGGII..q1H#ciikk"""C[[]] !$--D*oTBBBB4     rcp|5|jd}t|j|d\}}} |} t |} t|j} tj | vr;|r9|j tj tj |nFtj | vr8|j tj tj | t||||t|| | |cdddS#t $r\|j| kr=|j|xj| zc_tj |t|||| wxYw#1swxYwYdS)z5Update the sparse config and working directory state.r9rN)lockr:r;r1r(rrr!r rdiscardr writereporequirementsr%ror Exceptionrj) rr+r,r-rremovingr) oldincludes oldexcludes oldprofiles oldstatusoldmatch oldrequiress r_updateconfigandrefreshwdirrcs ""hy))0; GS)1 1 - [+KKMM 4==$+,,   *k 9 9h 9   % %l&E F F F  )$ / / / /  ,K ? ?   ! !,"A B B B  )$ / / /  h( ; ; ;tYFFF7""""""""8    K//!'')))!![0!!-d333 k; D D D   9""""""""""s%C;F+$EA&F((F++F/2F/c |5|j5|jd}t |j|d\}}}|s|s dddddddSt|tt||dddn #1swxYwYddddS#1swxYwYdS)zClears include/exclude rules from the sparse config. The remaining sparse config only has profiles, if defined. The working directory is refreshed, as needed. r9Nr) wlockrSrr:r;r1r(rr!)rrr)r+r,r-s r clearrulesrs OOt}1133OOhy))'247C'K'K$(H    OOOOOOOOOOOOOO $D#%%NNNNOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOs@C:B9) C,B9- C9B= =CB= CCCc |5|j5|jd}t |j|d\}}}t|\}} } d} |D]} tj tj | d5} | }dddn #1swxYwYt |j|d\}}}t|t|zt|z}| ||z | || z | || z t|t|zt|z|krd} dx}x}}d}| r]t|| z }t||z }t|| z }ttt||||| }t!|j||||g|Rdddn #1swxYwYddddS#1swxYwYdS) zImport sparse config rules from files. The updated sparse config is written out and the working directory is refreshed, as needed. r9Fsrb)modeNTr)rrrr)rrSrr:r;r1r(rYr posixfile expandpathreadr r@rr printchanges)roptspathsrr)r+r,r- aincludes aexcludes aprofileschangedrlrk iincludes iexcludes iprofilesoldsize profilecount includecount excludecountfcountss rimportfromfilesr s ( ( t}1133( ( hy))'247C'K'K$(H*6t*<*<' 9i  A 2 2??? 2ggii               /:i// +Iy)(mmc(mm3c(mmCG OOI 1 2 2 2 OOI 1 2 2 2 OOI 1 2 2 28}}s8}},s8}}z7updateconfig..normalize_pats..s066#27==%%666666rspaths cannot be absolute:r) anyrr&rrgetcwdr _patsplitcwdrelativepatternkindsr canonpathr) patsrcwdabspatskindpatkindraprusereporootpathss rnormalize_patsz$updateconfig..normalize_patss6666666 Bk!$?"@"@AAA   4;;==#DG , ,$.w== c8;;;t|)-6$++3(:Lc3;;BNN2&&&&NN7++++Nr)rrN)rrrSrr:r;r1r(r!difference_updater@r rrr)rrrrresetdelete enableprofiledisableprofilerr!r) oldinclude oldexcluder newinclude newexclude newprofilesr"rr r r s` ` r updateconfigr-s I I tyy{{I I DM$>$>$@$@I I hy)).9 GS)/ / + J   +JJ%%KKZJZJk**K      *!.)) .))'''77&}55 $$V,,,$$V,,,%%n555'"""=)))'""";455 + %9 9  : 233c  #7 7  : 233c  #7 7    '         GT<| FM    OI I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I sYI8I G7I = I  I I I I  I8 I$ $I8'I$ (I88I<?I<c|d|5}|||jdt d|||jdt d|||jdt d||s~||jdt d |||jd t d |||jd t d |ddddS#1swxYwYdS)z/Print output summarizing sparse config changes.r9sprofiles_addedsProfiles changed: %d sinclude_rules_addedsInclude rules changed: %d sexclude_rules_addedsExclude rules changed: %d s files_addedsFiles added: %d s files_droppedsFiles dropped: %d sfiles_conflictingsFiles conflicting: %d N) formatter startitem condwriteverboserisplain) r(rrr r rr conflictingfms rrr)s i & &$"  J  ' ( (     J " , - -     J " , - -     zz||  LL NA.B,C,CU    LL ,a0F.G.G    LL $,--    ?$$$$$$$$$$$$$$$$$$sD%E  E E )T)NT)F)FF)rKrKFrKrKrKFF)rrrrrr)*ri18nrrQrrrrrrr rr r r r rutilsrenabledrr1r7rHrYrfrorrruryrrrrrrrrr r-rrKrrr:s|                        @@@B,B,B,L;;;9(9(9(x111211114'''*!!!''' +++",",",J<<<::::zp&p&p&fb"b"b"b"J!!!$?D&&&&R O O O O . . . . h     Y Y Y Y ~ //////r