c 0dZddlmZddlmZddlmZmZmZm Z m Z m Z m Z mZmZmZdZiZejeZdZdZdZd Zd Zd Zed d dgededfddgededfddgededfdddedfddgededfddgededfdd ged!edfdd"ded#fdd$ded%fdd&ded'fg ejzed(d)*d+Zd,S)-aG allow sparse checkouts of the working directory (EXPERIMENTAL) (This extension is not yet protected by backwards compatibility guarantees. Any aspect may break in future releases until this notice is removed.) This extension allows the working directory to only consist of a subset of files for the revision. This allows specific files or directories to be explicitly included or excluded. Many repository operations have performance proportional to the number of files in the working directory. So only realizing a subset of files in the working directory can improve performance. Sparse Config Files ------------------- The set of files that are part of a sparse checkout are defined by a sparse config file. The file defines 3 things: includes (files to include in the sparse checkout), excludes (files to exclude from the sparse checkout), and profiles (links to other config files). The file format is newline delimited. Empty lines and lines beginning with ``#`` are ignored. Lines beginning with ``%include `` denote another sparse config file to include. e.g. ``%include tests.sparse``. The filename is relative to the repository root. The special lines ``[include]`` and ``[exclude]`` denote the section for includes and excludes that follow, respectively. It is illegal to have ``[include]`` after ``[exclude]``. Non-special lines resemble file patterns to be added to either includes or excludes. The syntax of these lines is documented by :hg:`help patterns`. Patterns are interpreted as ``glob:`` by default and match against the root of the repository. Exclusion patterns take precedence over inclusion patterns. So even if a file is explicitly included, an ``[exclude]`` entry can remove it. For example, say you have a repository with 3 directories, ``frontend/``, ``backend/``, and ``tools/``. ``frontend/`` and ``backend/`` correspond to different projects and it is uncommon for someone working on one to need the files for the other. But ``tools/`` contains files shared between both projects. Your sparse config files may resemble:: # frontend.sparse frontend/** tools/** # backend.sparse backend/** tools/** Say the backend grows in size. Or there's a directory with thousands of files you wish to exclude. You can modify the profile to exclude certain files:: [include] backend/** tools/** [exclude] tools/tests/** )_)setattr) cmdutilcommandserror extensions logcmdutilmergepycompat registrarsparseutilsships-with-hg-corecxdt_t|t|t |dS)NT)r enabled _setupclone _setuplog _setupadd)uis ./usr/lib/python3/dist-packages/hgext/sparse.pyextsetuprds.FNOOO bMMM bMMMMMc |}t|sJ|turG||jvr(|j|}t||||n|jd}|tuG|tur!t t d||fzdS)ziReplace a filecache property with a new class. This allows changing the cache invalidation condition.rstype '%s' has no property '%s'N)callableobject__dict__r __bases__AttributeErrorr)clspropname replacementorigclsorigs rreplacefilecacher#lsG K    V   s| # #<)D C;;t#4#4 5 5 5 mA V   f}} / 0 0GX3F F   }rctjd}|ddd}tjt d|dS)Ns log|history)rsparseNs1limit to changesets affecting the sparse checkoutc||}|jdr/tjfd}||}|S)Nr&cn|}tfd|DS)Nc32K|]}| |VdS)N).0f sparsematchs r zD_setuplog.._initialrevs..ctxmatch..s0DD[[^^D1DDDDDDr)anyfiles)revctxrepor-s rctxmatchz1_setuplog.._initialrevs..ctxmatchs73iDDDDciikkDDDDDDr)optsgetr matcherfilter)r"r3woptsrevsr4r-s ` @r _initialrevsz_setuplog.._initialrevssvtD%   :>>) $ $ ) ...K E E E E E E;;x((D rs _initialrevs)rtableappendr wrapfunctionr )rentryr;s rrr~sY N> *E !HOO    JFFFFFrc |d |d|d|d}|s( ssr" fd}tjtd||||g|Ri|S)Nincludeexcludeenable_profilenarrowctj|id||g|Ri|S)NT)rArB enableprofileusereporootpaths)r updateconfigr3 unfiltered)r"r2argskwargsrFrBrAs r clonesparsez$_clonesparsecmd..clonesparsese   %%''+!%     4-d---f-- -rsupdate)r6rr>mergemod) r"rr3rJr5 narrow_patrLrFrBrAs @@@r_clonesparsecmdrOshhy!!Ghhy!!GHH-..M(##J  B7 Bg B B . . . . . . . )[AAA 4D (4 ( ( (4 ( ((rc.tjd}|dddgdf|dddgdf|dddgd ftjtjdt dS) Nscloner%renable-profilesenable a sparse profileincludesinclude sparse patternexcludesexclude sparse pattern)rr<r=r wrapcommandrO)rr?s rrrs N8 $E !HOOS+R1KLMMM !HOOS*b*CDEEE !HOOS*b*CDEEE8>8_EEEEErctjd}|ddd}tjtjd|dS)Nsaddr%)sr&Ns8also include directories of added files in sparse configc |drct}|D].}tj|\}}||/t j||t||||g|Ri|S)Nr )rA)r6setrsplitaddr rHlist) r"rr3patsr5dirspatdirnamebasenames r_addz_setupadd.._adds 88H   @55D " "$(JsOO!!!!!  dDJJ ? ? ? ?tB,t,,,t,,,r)rr<r=rrT)rr?ras rrrs[ N6 "E !HOO ---8>6488888rs debugsparseIrRs$include files in the sparse checkoutsPATTERNXrSs$exclude files in the sparse checkoutddeletesdelete an include/exclude rulefforceFs.allow changing rules even with pending changesrrQsenables the specified profilesdisable-profilesdisables the specified profiles import-rulessimports rules from a files clear-ruless"clears local include/exclude rulesrefreshs,updates the working after sparseness changesresetsmakes the repo full agains [--OPTION]T) helpbasicc tj|}|d}|d}|d}|d}|d}|d}|d} |d} |d } |d } tj|ddd } t |p |p| p| p|p|}t |t | g}|d kr!tjtd d |_ |dkr|j dr| |j ddztj|}|rM| td| d|dzdStjtd|rtj||||| | ||| |rtj||||| rtj||| r |}tjt.tj|| tj||}tj|||d|d |d|n#|wxYw|` dS)amake the current checkout sparse, or edit the existing checkout The sparse command is used to make the current checkout sparse. This means files that don't meet the sparse condition will not be written to disk, or show up in any working copy operations. It does not affect files in history in any way. Passing no arguments prints the currently applied sparse rules. --include and --exclude are used to add and remove files from the sparse checkout. The effects of adding an include or exclude rule are applied immediately. If applying the new rule would cause a file with pending changes to be added or removed, the command will fail. Pass --force to force a rule change even with pending changes (the changes on disk will be preserved). --delete removes an existing include/exclude rule. The effects are immediate. --refresh refreshes the files on disk based on the sparse rules. This is only necessary if .hg/sparse was changed by hand. --enable-profile and --disable-profile accept a path to a .hgsparse file. This allows defining sparse checkouts and tracking them inside the repository. This is useful for defining commonly used sparse checkouts for many people to use. As the profile definition changes over time, the sparse checkout will automatically be updated appropriately, depending on which changeset is checked out. Changes to .hgsparse are not applied until they have been committed. --import-rules accepts a path to a file containing rules in the .hgsparse format, allowing you to add --include, --exclude and --enable-profile rules in bulk. Like the --include, --exclude and --enable-profile switches, the changes are applied immediately. --clear-rules removes all local include and exclude rules, while leaving any enabled profiles in place. Returns 0 if editing the sparse checkout succeeds. rRrSrgsenable_profilesdisable_profiles import_ruless clear_rulesrerhrir%stoo many flags specifiedTrr& s/Temporarily Included Files (for merge/rebase): Ns@the debugsparse command is only supported on sparse repositories)rArBresetdeleterFdisableprofileforce)rp)addeddropped conflicting)r byteskwargsr6rcheck_at_most_one_argboolsumrAbortr _has_sparsevfsexistsstatusreadr readtemporaryincludesjoinrHimportfromfiles clearruleswlockmaplistlen refreshwdirr7 printchangesrelease)rr3r5rArBrprFro importrulesrrnrefreshrmactionrHcounttemporaryincludesrfcountss r debugsparsersgR   % %Dhhz""Ghhz""G HHX  EHH.//MXX011N((?++K.))J XXi Fhhz""G HHX  E  * o~zFP7PfPPP.L tF||, - -E qyyk!788999D zz 8??9 % %  IIdhmmI..6 7 7 7 & rs@@F&&&&&&                        "#  ) H % %   $GGG4)))2FFF999.     A5 6 6 AjMM      A5 6 6 AjMM      A/ 0 0 AjMM      A? @ @      A. / / AjMM      A/ 0 0 AjMM      A* + + AjMM   neQQ'L%M%MN    A= > >  hqq!=>>?q9tu:vAm}???@yyA??@yyyr