o ]LbL_@sddlmZddlZddlZddlmZddlmZmZddl m Z m Z m Z m Z mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZddlmZiZe eZ ddZ!d d Z"d d Z#d dZ$ddZ%e&ede%ddZ'ddZ(e dddgedfddgedfdddedfddged fdd!ded"fdd#ged$fdd%ded&fdd'ded(fdd)d*ed+fdd,ded-fg e j)ed.d*e j*d/d2d0d1Z+dS)3)absolute_importN)_)hexshort)bundle2cmdutilcommands discoveryencodingerrorexchange extensionshg narrowspecpathutilpycompat registrarrepairrepoview requirementssparseutilwireprototypes)urlutilcCsttjdt}|ddddtdf|ddddtdf|ddd dtd fd tvrO|ddd gtd f|dddgtdfttjdt}|ddddtdfttjdt dS)z@Wraps user-facing mercurial commands with narrow-aware versions.sclonenarrowNs%create a narrow clone of select filesdepths0limit the history fetched by distance from heads narrowspecsread narrowspecs from filessparseincludes&specifically fetch this file/directoryexcludes2do not fetch this file/directory, even if includedspullsarchive) r wrapcommandrtableclonenarrowcmdappendrenabled pullnarrowcmdarchivenarrowcmd)entryr)=/usr/lib/python3/dist-packages/hgext/narrow/narrowcommands.pysetup.s@   r+c sNtt}d}|rstjt|}| t d|zt |}Wnt yC} zt t d|t| jfd} ~ wwt||d\} } } | rWt t dt| t| dd<d| d | drfd d } ttd | }||||g|RitWdS1swYdS) zAWraps clone command, so 'hg clone' first wraps localrepo.clone().rsreading narrowspec from '%s' %cannot read narrowspecs from '%s': %sNrs9cannot specify other files using '%include' in narrowspecTrr cs(|||drd|d<dSdS)Nrgetorigpullopkwargsoptsr)r*pullbundle2extraprepare_widen}s  z5clonenarrowcmd..pullbundle2extraprepare_widen_pullbundle2extraprepare)r byteskwargsrnullcontextmanagerospathjoinr getcwdstatusrreadfileIOErrorr Abort strtolocalstrerrorr parseconfig ConfigErrorrvalidatepatternsextendr wrappedfunctionr strkwargs)r0uirepoargsr4wrappedextrapreparenarrowspecfilefilepathfdatainstincludesexcludesprofilesr5r)r3r*r#YsH    $r#csnt}tj|jvrfdd}ttd|}||||g|RiWdS1s0wYdS)z2Wraps pull command to allow modifying narrow spec.cs(|||drd|d<dSdS)Ndepthrr-r/r3r)r*r5s  z4pullnarrowcmd..pullbundle2extraprepare_widenr6N)rr8rNARROW_REQUIREMENTr rGr )r0rIrJrKr4rLr5r)r3r*r&s  $r&c Os|tj|jvr2|j\}}t|dg}t|dg}t||||\}}} |r,||d<|r2||d<|||g|Ri|S)z5Wraps archive command to narrow the default includes.includeexclude)rrU narrowpatssetr.rrestrictpatterns) r0rIrJrKr4 repo_includes repo_excludesrQrRunused_invalidr)r)r*r's   r'cs|jtjjvr|||Stj|jvrtt d|||d|d<j \}}||d<||d<|r9||d<|r?||d<tj |jvr`fdd  d |j D|d <|d sb|d =dSdSdS) N%server does not support narrow clonesTrsoldincludepatssoldexcludepats includepats excludepatscs&g|]}|jkrt|qSr))nodenullidr.0ctxrJr)r* s  z+pullbundle2extraprepare..::%lnknown)rJrrUr NARROWCAPremote capabilitiesr r@rrX ELLIPSESCAP1rYcommon)r0r1r2rVrWr)rfr*pullbundle2extraprepares,        ror6c  s4tj||tj||tj||d} |td|jtdtdt | j t | j d} g} | ,t | j | j D]} | tfdd| Dr_| | qDWdn1sjwYd| }td}tfd d||D}|r|td d }|jst ||kr|D] } |d t| qn|d|D] } |d t| q|td t |||stjtdtdd|3|r<fdd|D}d|vrtdd|}t|ddi}| r|tdn|td||dt j!||d| dWdn 1s7wYg}j"#D]X\}}}|$dr`|dd}|s^||qC|$dr|dd}t%t&'|h|g}d }|D]}(|}|sd}n |d!krnq{|s||qC)*d"U+|||D]}|td#|t,-j./|j"0|q|td$j12tj3d d%t4Wdn 1swYWdn 1swY5WddS1swYdS)&N commonincs,looking for local changes to affected paths s changesets)topicunittotalc3s"|] }|o | VqdSNr)rdf)newmatcholdmatchr)r* s z_narrow..sdescendants(%ln)svisiblec3s|] }j|VqdSru changelogrardrrfr)r*rzs  sTThe following changeset(s) or their ancestors have local changes not on the remote: %s s*...and %d more, use --verbose to list all slocal changes founds*use --force-delete-local-changes to ignore)hintcsg|]}j|qSr)r{r})unfir)r*rgsz_narrow...s(::%n) - %ln + null)develsstrip-obsmarkersFs%moving unwanted changesets to backup sdeleting unwanted changesets r)rrbackupsdata/smeta/iTsalls narrowings deleting %s s*deleting unwanted files from working copy ) assumeclean)6rmatchroot unfilteredr findcommonoutgoingr=r makeprogresslenmissingexcluded itertoolschain incrementanyfilesr$revsr filterrevslistverboserr StateErroruninterruptibleramaxrcleanconfigoverriderstripstore datafiles startswithsortedrdirsvisitdir destroying transaction setnarrowpatsr unlinkpathsvfsr; markremoveddirstate parentchangeupdateworkingcopycopytoworkingcopy destroyed)rIrJrkrq oldincludes oldexcludes newincludes newexcludesforceroutgoingprogress localnodesn revstostrip hiddenrevsvisibletostripmaxnodestostripurev overridestodeletetrwsizefiledirrrVdvisitr))rxryrJrr*_narrows                        $rcs|tfddtjD}|otjvotjv} fdd} ttd| } fdd} | _ dd i} |d }| )|rmj }| | }}||jjWdn1shwY| r| tj||d Wdn1swYnyg}|rfd d d|D}|}|d||d|||d}Wdn1swYtd|}|0j| dtj|jdd}tj||dWdn1swYWdn1swY|r!||||Wdn 1swYd,j  tt Wdn 1sFwYWdn1sVwYWddSWddS1sowYdS)Nc3s|]}|vVqdSrur))rdcap) remotecapr)r*rz\s z_widen..cs||||d<|d<dS)Nr_r`r)r/)rrr)r*r5hs  z-_widen..pullbundle2extraprepare_widenr6csdSru)rr))rrrJr)r*setnewnarrowpatstsz _widen..setnewnarrowpats)rs all-warningsFr)headscs"g|] }|jkr|qSr))rarbrcrfr)r*rgs z_widen..rhs narrow_widens03)s oldincludess oldexcludess newincludess newexcludess cgversions commonheadsrisellipsesswiden)source)opswidening)!rlrrSUPPORTED_ELLIPSESCAPrm ELLIPSESCAPr rGr rrrp1p2r setparentsrbpullrYcommandexecutor callcommandresulttransactionmanagerurlrIrrbundleoperationr processbundlerrr)rIrJrkrqrrrrellipsesremote isoldellipsesr5rLrrrndsrrknownebundle trmanagerrr))rrrrJr*_widenKs            .$rtrackedr addincludesnew paths to include removeincludesold paths to no longer includesauto-remove-includesFs.automatically choose unused includes to remove addexcludesnew paths to excludes import-rulessimport narrowspecs from a file removeexcludesold paths to no longer excludeclears*whether to replace the existing narrowspecsforce-delete-local-changess/forces deletion of local changes when narrowingbackupTs$back up local changes when narrowingsupdate-working-copys.update working copy when the store has changeds[OPTIONS]... [REMOTE]) inferrepo helpcategoryc&stt|}tj|jvrttd|drttd|d}|rqztj t |}t |}WntyO}zttd|t |jfd}~wwt||d\} } } | rcttd|d | |d | t|d } t|d } t|d }t|d }|d }|d}| p| p|p|p|p|p| }|j\}}| |8} | |M} ||8}||M}| p|}| p|}|r|d|d|}t|D]}||jddddd|jdd|ddqt|D]}||jddddd|jdd|ddq|dS|r}|\| >|!d(|j"#t$|t%|Wdn 1s=wYWdn 1sMwYWdn1s]wYWddSWddS1svwYdS|s|s|s|&tddS|| t'(|t)*d|||}|\}}|&tdt)+|t,-|||}z|rt.j/|0vrt1tdt23||}|rNt2j4|||d}|&tdt5}t67|j8|j9D] } |:|| ;qg}!t|D]}"t<|j=|"g|t>fd d!|Ds#|!?|"q|!rG|!D] }#|&d|#q*|@td"dkrF| :|!d#}n|&td$|rn|| }$||B}%tA|||||||$|%|d%|d& |$}|%}|r|| B}$||}%tB|||||||$|%W|Cn|CwWdn1swYWddSWddS1swYdS)'a show or change the current narrowspec With no argument, shows the current narrowspec entries, one per line. Each line will be prefixed with 'I' or 'X' for included or excluded patterns, respectively. The narrowspec is comprised of expressions to match remote files and/or directories that should be pulled into your client. The narrowspec has *include* and *exclude* expressions, with excludes always trumping includes: that is, if a file matches an exclude expression, it will be excluded even if it also matches an include expression. Excluding files that were never included has no effect. Each included or excluded entry is in the format described by 'hg help patterns'. The options allow you to add or remove included and excluded expressions. If --clear is specified, then all previous includes and excludes are DROPPED and replaced by the new ones specified to --addinclude and --addexclude. If --clear is specified without any further options, the narrowspec will be empty and will not match any files. If --auto-remove-includes is specified, then those includes that don't match any files modified by currently visible local commits (those not shared by the remote) will be added to the set of explicitly specified includes to remove. --import-rules accepts a path to a file containing rules, allowing you to add --addinclude, --addexclude rules in bulk. Like the other include and exclude switches, the changes are applied immediately. sJthe tracked command is only supported on repositories cloned with --narrowrs'the --clear option is not yet supporteds import_rulesr,NrsJincluding other spec files using '%include' is not supported in narrowspecrrrrsauto_remove_includessupdate_working_copyrsstatuss%s Isnarrow.included)labelspatrXsnarrow.excludedrs narrow-wcsnothing to widen or narrow scomparing with %s r^rps&looking for unused includes to remove c3s|]}|VqdSrur)rvrr)r*rz~sztrackedcmd..s0remove these unused includes (yn)?$$ &Yes $$ &NoTsfound no unused includes sforce_delete_local_changesr)Drr7rrUr InputErrorrr.r9r:r;r r<rr>r? StorageErrorrArBrrCrFr parsepatternsrXpager formatterr startitemwriteendwlocklockrrrrrr=r bailifchangedrget_unique_pull_path hidepasswordrpeerrrjrlr@r findcommonincomingrrYrrrrupdaterrrrr$ promptchoicerrclose)&rIrJ remotepathpatsr4newrulesrNrOrP includepats excludepatsrS addedincludesremovedincludes addedexcludesremovedexcludesautoremoveincludesupdate_working_copy only_showrrwidening narrowingfmir~rbranchesrkrqr localfilesrsuggestedremovalsrVsrrr)rr* trackedcmdsV M           *       *Z ZZrru), __future__rrr9mercurial.i18nrmercurial.noderr mercurialrrrr r r r r rrrrrrrrrrrmercurial.utilsrr"commandr+r#r&r'ro wrapfunctionrr remoteoptsCATEGORY_MAINTENANCErr)r)r)r*sv  T  +2zf%&,