o ]Lb3@sddlmZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z m Z mZmZmZddlmZmZddlmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z'm(Z)m*Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2mZm3Z3m4Z4m5Z6m7Z7m8Z8m9Z9m:Z:m;Z;mZ>m?Z@mAZAmBZBmCZCmDZEmFZFddlGmHZHmCZIdd lJmKZKmLZLmMZMmNZNdd lOmPZQmRZSmTZUe'jVZVeCjWZWeCjXZXeYZZGd d d e:j[Z\Gd dde\Z]Gddde\Z^Gddde^Z_Gddde^Z`Gddde\ZaddZbGdddeCjcZdGdddeCjcZeddZfdd Zghd!Zhehid"hZjeIkeHjlGd#d$d$emZneIkeHjoGd%d&d&eHjpZqeIkeHjrGd'd(d(eqZseYZtd)d*Zud+d,Zvdbd-d.Zwdbd/d0Zxd1d2Zyd3d4Zzd5d6Z{d7d8Z|d9d:Z}d;d<Z~d=d>Zd?d@ZeIkeHjGdAdBdBemZeIkeHjGdCdDdDemZdEdFZeHjdGdHfeHjdIdHfgZeIkeHjGdJdKdKemZdLdMZdNdOZdcdPdQZdRdSZdbdTdUZdVdWZdXdYZdZd[Zd\d]Zdcd^d_Zd`daZdS)d)absolute_importN)_)binhexnullrevsha1nodeconstantsshort)delattrgetattr), bookmarks branchmapbundle2 bundlecaches changegroupcolorcommitcontextdirstate dirstateguard discoveryencodingerrorexchange extensionsfileloghooklockmatch mergestate mergeutil namespaces narrowspecobsoletepathutilphasespushkeypycompatrcutilrepoview requirementsrevlogrevset revsetlangscmutilsparsestore subrepoutiltags transactiontxnutilutilvfswireprototypes) repositoryr5)hashutilprocutil stringutilurlutil)concurrency_checker constantssidedatacs.eZdZdZdfdd ZfddZZS)_basefilecachezHAll filecache usage on repo are done for logic that should be unfilteredNcsH|dur|S|}z|j|jWStyYnwtt|||SN) unfiltered__dict__snameKeyErrorsuperr@__get__selfrepotypeunfi __class__5/usr/lib/python3/dist-packages/mercurial/localrepo.pyrGms z_basefilecache.__get__cstt|||SrA)rFr@setrB)rIrJvaluerMrOrPrQxsz_basefilecache.setrA)__name__ __module__ __qualname____doc__rGrQ __classcell__rOrOrMrPr@js r@c(eZdZdZfddZddZZS) repofilecachez3filecache for files in .hg but outside of .hg/storec,tt|j||D] }t|dfq dS)Nplain)rFrY__init__ _cachedfilesaddrIpathspathrMrOrPr\zrepofilecache.__init__cCs |j|SrA)r6joinrIobjfnamerOrOrPrc zrepofilecache.joinrSrTrUrVr\rcrWrOrOrMrPrY| rYcrX) storecachez filecache for files in the storecrZ)N)rFrjr\r]r^r_rMrOrPr\rbzstorecache.__init__cCs ||SrA)sjoinrdrOrOrPrc zstorecache.joinrhrOrOrMrPrjrirjcrX)changelogcachezfilecache for the changelogc&tt|tdtddS)N 00changelog.irk) 00changelog.nrk)rFrnr\r]r^rIrMrOrPr\ zchangelogcache.__init__cC6||dg}|jjjddr|||d|S)Nrqpersistent-nodemapFrrrcr0openeroptionsgetappendrIrer`rOrOrP tracked_pathszchangelogcache.tracked_pathsrSrTrUrVr\r}rWrOrOrMrPrnrirncrX)manifestlogcachezfilecache for the manifestlogcro)N) 00manifest.irk) 00manifest.nrk)rFrr\r]r^rsrMrOrPr\rtzmanifestlogcache.__init__cCru)NrrvFrrwr|rOrOrPr}r~zmanifestlogcache.tracked_pathsrrOrOrMrPrrircrX)mixedrepostorecachez2filecache for a mix files in .hg/store and outsidecstt|j|t|dSrA)rFrr\r]update)rIpathsandlocationsrMrOrPr\szmixedrepostorecache.__init__cCs<|\}}|dkr|j|S|dkrtd|||S)Nr[rksunexpected location: %s)r6rcrProgrammingErrorrl)rIrefnameandlocationrflocationrOrOrPrcs  zmixedrepostorecache.joinrhrOrOrMrPrs rcCs$|j|d}|s dS|jdfS)z{check if a repo has already cached "name" filecache-ed property This returns (cachedobj-or-None, iscached) tuple. NNFT)rB _filecacherzre)rJname cacheentryrOrOrP isfilecacheds rcs"eZdZdZdfdd ZZS)unfilteredpropertycachez0propertycache that apply to unfiltered repo onlyNcs,|}||urtt||St||jSrA)rBrFrrGr rrHrMrOrPrGs zunfilteredpropertycache.__get__rA)rSrTrUrVrGrWrOrOrMrPrsrc@eZdZdZddZdS)filteredpropertycachez1propertycache that must take filtering in accountcCst||j|dSrA)object __setattr__r)rIrerRrOrOrP cachevaluez filteredpropertycache.cachevalueN)rSrTrUrVrrOrOrOrPrs rcCs|t|vS)z?check if a repo has an unfilteredpropertycache value for )varsrB)rJrrOrOrPhasunfilteredcachercstfdd}|S)z@decorate method that always need to be run on unfiltered versioncs|g|Ri|SrA)rB)rJargskwargsorigrOrPwrappersz!unfilteredmethod..wrapper) functoolswraps)rrrOrrPunfilteredmethodsr>knownlookupunbundle branchmap getbundlepushkeyschangegroupsubsetc@s<eZdZddZddZddZddZd d Zd d Zd S)localcommandexecutorcCs||_d|_d|_dSr)_peer_sent_closed)rIpeerrOrOrPr\s zlocalcommandexecutor.__init__cC|SrArOrsrOrOrP __enter__zlocalcommandexecutor.__enter__cC |dSrA)close)rIexctypeexcvalueexctbrOrOrP__exit__rgzlocalcommandexecutor.__exit__c Cs|jrtd|jrtdt|jt|}tj }z |dit |}Wnt y@t |t ddY|Sw|||S)Ns1callcommand() cannot be used after sendcommands()s*callcommand() cannot be used after close()rrO)rrrrr rr'sysstrfuturesFuture strkwargs Exceptionfuture_set_exception_infosysexc_info set_result)rIcommandrfnfresultrOrOrP callcommand s$   z localcommandexecutor.callcommandcC d|_dSNT)rrsrOrOrP sendcommands$rmz!localcommandexecutor.sendcommandscCrr)rrsrOrOrPr'rmzlocalcommandexecutor.closeN) rSrTrUr\rrrrrrOrOrOrPrs rcseZdZdZd)fdd ZddZddZd d Zd d Zd dZ ddZ ddZ ddZ d*ddZ    d+ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(ZZS), localpeerz8peer for a local repo; reflects only the most recent APINcs`tt||durt}|d|_|j|_|jr(t |}| d|| ||_ dS)Nservedsexp-wanted-sidedata=)rFrr\ moderncapscopyfiltered_repoui_wanted_sidedatarformat_remote_wanted_sidedatar^_restrictcapabilities_caps)rIrJcaps formattedrMrOrPr\/s  zlocalpeer.__init__cC |jSrA)rurlrsrOrOrPr?rmz localpeer.urlcC|jSrA)rrsrOrOrPlocalBzlocalpeer.localcCrrArOrsrOrOrPrErzlocalpeer.peercCdSrrOrsrOrOrPcanpushHrzlocalpeer.canpushcCs|jdSrA)rrrsrOrOrPrKzlocalpeer.closecCrrA)rr rsrOrOrPr Rrmzlocalpeer.branchmapcCrrA)rrsrOrOrP capabilitiesUrzlocalpeer.capabilitiescCs|jtjSrA)rtryreadrCB_MANIFEST_FILErsrOrOrP clonebundlesXrzlocalpeer.clonebundlescC$d||t|t|t|fS)z+Used to test argument passing over the wire%s %s %s %s %sr'bytestrrIonetwothreefourfiverOrOrP debugwireargs[zlocalpeer.debugwireargsc KsTtj|j|f||||d|d}t|}t|r#t|j|St d|dS)N)headscommon bundlecapsremote_sidedatar01) rgetbundlechunksrr5 chunkbufferbundle2requestedr getunbundlerrr) rIsourcerrrrrchunkscbrOrOrP getbundlees"  zlocalpeer.getbundlecCrrA)rrrsrOrOrPrrmzlocalpeer.headscC |j|SrA)rknownrInodesrOrOrPrrgzlocalpeer.knowncCrrA)rlistkeys)rI namespacerOrOrPrrgzlocalpeer.listkeyscCrrA)rlookuprIkeyrOrOrPrrgzlocalpeer.lookupcCs|j||||SrA)rr&)rIrroldnewrOrOrPr&zlocalpeer.pushkeycCsttd)Ns.cannot perform stream clone against local peer)rAbortrrsrOrOrP stream_outrzlocalpeer.stream_outc Cszfz*t|j|d}t|j||d|}t|dr(t|}t |j|}|WWSt yf}z/t |dd}|rat |jj}|D]} || qDt|}t |j|} t |j| d}~wwtjy~}z ttdt|d}~ww)zPapply a bundle on a repo This function handles the repo locking itself.Nspushs getchunks_bundle2salvagedoutputrOs push failed:)r readbundlerunbundlerr5 safehasattrr getchunksrrrr bundle20addpart processbundler PushRaced ResponseErrorrr; forcebytestr) rIbundlerrretstreamexcoutputbundleroutbrOrOrPrs4   zlocalpeer.unbundlecCt|SrA)rrsrOrOrPcommandexecutorzlocalpeer.commandexecutorrANNN)NNNN)rSrTrUrVr\rrrrrr rrrrrrrrr&rrrrWrOrOrMrPr+s2   )rcs@eZdZdZfddZddZddZdd Zd d ZZ S) locallegacypeerzcpeer extension which implements legacy methods too; used for tests with restricted capabilitiescstt|j|tddS)N)r)rFrr\ legacycaps)rIrJrMrOrPr\zlocallegacypeer.__init__cCrrA)rbetween)rIpairsrOrOrPrrgzlocallegacypeer.betweencCrrA)rbranchesrrOrOrPr!rgzlocallegacypeer.branchescCs*tj|j||jd}t|j|d|SN) missingroots ancestorsofr)routgoingrrrmakechangegroup)rIrrr%rOrOrPrszlocallegacypeer.changegroupcCs$tj|j||d}t|j|d|Sr")rr%rrr&)rIbasesrrr%rOrOrPchangegroupsubsetsz!locallegacypeer.changegroupsubset) rSrTrUrVr\rr!rr(rWrOrOrMrPrs rcCsX|dd}tj|vrt||}tj|dd}| s*t t d|j |S)zreturns the vfs object pointing to root of shared source repo for a shared repository hgvfs is vfs pointing at .hg/ of current repo (shared one) requirements is a set of requirements of current repo (shared one) sharedpath T)realpaths1.hg/sharedpath points to nonexistent directory %s)readrstriprequirementsmodRELATIVE_SHARED_REQUIREMENTr5normpathrcvfsmodr6existsr RepoErrorrbase)hgvfsr* sharedpath sharedvfsrOrOrP _getsharedvfss r8c CsXz t|d}W|Sty+}z|r|jtjkst}WYd}~|Sd}~ww)zreads the require file present at root of this vfs and return a set of requirements If allowmissing is True, we suppress ENOENT if raisedrequiresN)rQr, splitlinesIOErrorerrnoENOENT)r6 allowmissingr*erOrOrP _readrequiress r@c!Cs<|}|j|_tj|ddd}|d}tj|dd}d}d}|sfz|Wn2tyC} z | jtjkr9WYd} ~ nd} ~ wt y\} zt t d|t | fd} ~ wwt t d|t|d} tj| vpttj| v}d} |rt|| }t|d } nt|d } t d } tj| vr|rtjt|dvr|d d } |d d }|dvrddlm}||||| || ni|dkrt j t d| dt j t d|| d| t| dO} nI|r,t|d}tj|vr,|d d}|d d} |dvrddlm}|||| | || n|dkr!t j t d| dt j t d|| dt|||| |rFt|||| t|t |ddt|D}t!|}t"| |t#|| t$}|rs|j%}|d}|&t'j(n|j%}|d}|d}t)| |dd}|j*|_*|j} t+|| || _,tj-| vstj.| vr|&t'j/|0t'j1tj|dd}|j*|_*tj|dd}|j*|_*g}i}t2D]+\}}|||| ||||| | j,|||||d }t3|t4st 5d!||6|qt78d"|j%d#t9| f}t4|t:|i} | |||||| |||||||d$ S)%aeCreate a local repository object. Given arguments needed to construct a local repository, this function performs various early repository loading functionality (such as reading the ``.hg/requires`` and ``.hg/hgrc`` files), validates that the repository can be opened, derives a type suitable for representing that repository, and returns an instance of it. The returned object conforms to the ``repository.completelocalrepository`` interface. The repository type is derived by calling a series of factory functions for each aspect/interface of the final repository. These are defined by ``REPO_INTERFACES``. Each factory function is called to produce a type implementing a specific interface. The cumulative list of returned types will be combined into a new type and that type will be instantiated to represent the local repository. The factory functions each receive various state that may be consulted as part of deriving a type. Extensions should wrap these factory functions to customize repository type creation. Note that an extension's wrapped function may be called even if that extension is not loaded for the repo being constructed. Extensions should check if their ``__name__`` appears in the ``extensionmodulenames`` set passed to the factory function and no-op if not. T expandpathr+.hg cacheauditedFNsinvalid path %s: %ssrepository %s not foundstores?see `hg help config.format.use-share-safe` for more informationsshares"safe-mismatch.source-not-safe.warnssafe-mismatch.source-not-safe)sdowngrade-allowallowsdowngrade-abortr)upgradeaborts4share source does not support share-safe requirementhintsfshare-safe mismatch with source. Unrecognized value '%s' of `share.safe-mismatch.source-not-safe` set.ssafe-mismatch.source-safessafe-mismatch.source-safe.warn)s upgrade-allowrGs upgrade-abortsWversion mismatch: source uses share-safe functionality while the current share does notsbshare-safe mismatch with source. Unrecognized value '%s' of `share.safe-mismatch.source-safe` set.cSh|]\}}|jqSrOrS.0nmrOrOrP z&makelocalrepository..cachewcachecSstj|ddS)NTrD)r1r6)r4rOrOrPsz%makelocalrepository..)rintentsr*featureswdirvfsr5r0storevfs storeoptionscachevfs wcachevfsextensionmodulenames extrastate baseclassessunable to construct type for %ssderivedrepo:%s<%s>,) baseuirorigrootrYr5r*supportedrequirementsr6r0r\r]rXrW);rr1r6rcisdirstatOSErrorr<r= ValueErrorrrrr;rr3r@r.SHARED_REQUIREMENTr/r8SHARESAFE_REQUIREMENT configboolconfigrHdowngrade_share_to_non_safeupgrade_share_to_safeloadhgrc afterhgrcloadrloadall populateuigathersupportedrequirementsensurerequirementsrecognizedensurerequirementscompatiblerQr4r^r8REPO_FEATURE_SHARED_STORAGE makestore createmoderesolvestorevfsoptionsryREVLOGV2_REQUIREMENTCHANGELOGV2_REQUIREMENTREPO_FEATURE_SIDE_DATAdiscardREPO_FEATURE_STREAM_CLONEREPO_INTERFACES isinstancerKrr{r'rsortedtuple)!rbrarWrrYhgpathr5sharedr7r?r*rZrK mismatch_warnmismatch_configrHsourcerequiresr^rdrX storebasepath cachepath wcachepathr0r\r]r'r_ifacertyprclsrOrOrPmakelocalrepositorys^                              rcCstsdSd}tj|vr(|r(z|j|d|jdd}Wn ty'Ynwz|j|d|jdd}Wn ty@Ynwz|j|d|jdd}W|Sty[Y|Sw)aLoad hgrc files/content into a ui instance. This is called during repository opening to load any additional config files or settings relevant to the current repository. Returns a bool indicating whether any additional configs were loaded. Extensions should monkeypatch this function to modify how per-repo configs are loaded. For example, an extension may wish to pull in configs from alternate files or sources. sharedvfs is vfs object pointing to source repo if the current one is a shared one FhgrcrootTshgrc-not-shared)r( use_repo_hgrcr.rj readconfigrcr4r;)rrYr5r*r7rrOrOrPrpOs0   rpcCs^dgdgdgd}t|D]\}}||vrq|D]}|d|s+|jd|dddqqd S) aQPerform additional actions after .hg/hgrc is loaded. This function is called during repository loading immediately after the .hg/hgrc file is loaded and before per-repo extensions are loaded. The function can be used to validate configs, automatically add options (including extensions) based on requirements, etc. git largefileslfs)rrrs extensionsrksautoload)rN)ritems hasconfig setconfig)rrYr5r*autoextensions requirementnamesrrOrOrPrqys  rqcCsttj}ddt|D}tD] }|j|vr|||qtjD]"}tj|}|rC| rC| d|| dkrC| t j q!|S)z6Determine the complete set of recognized requirements.cSrLrOrMrNrOrOrPrRrSz.gathersupportedrequirements..exp-compression-%szstd)rQlocalrepository_basesupportedrfeaturesetupfuncsrTr5 compengines available revlogheaderr^rr.REVLOG_COMPRESSION_ZSTD)r supportedmodulesrrenginerOrOrPrts       rtcCsrt}|D]}||vr q|r|ddsttd||q|r7tjtddt|tdddS) aValidate that a set of local requirements is recognized. Receives a set of requirements. Raises an ``error.RepoError`` if there exists any requirement in that set that currently loaded code doesn't recognize. Returns a set of supported requirements. rrs.hg/requires file is corrupts:repository requires features unknown to this Mercurial: %s sJsee https://mercurial-scm.org/wiki/MissingRequirement for more informationrJN)rQisalnumrRequirementErrorrr^rcr)r*rmissingrrOrOrPrus"   rucCs&tj|vrtjsttddSdS)aValidates that a set of recognized requirements is mutually compatible. Some requirements may not be compatible with others or require config options that aren't enabled. This function is called during repository opening to ensure that the set of requirements needed to open a repository is sane and compatible with config options. Extensions can monkeypatch this function to perform additional checking. ``error.RepoError`` should be raised on failure. sfrepository is using sparse feature but sparse is not enabled; enable the "sparse" extensions to accessN)r.SPARSE_REQUIREMENTr/enabledrr3r)rr*rOrOrPrvs rvcCsDtj|vrtj|vrtj|v}t|||St||St||S)z,Construct a storage object for a repository.)r.STORE_REQUIREMENTFNCACHE_REQUIREMENTDOTENCODE_REQUIREMENTstoremod fncachestore encodedstore basicstore)r*ravfstype dotencoderOrOrPrxs     rxcCsi}tj|vr d|d<|dd}|dur||d<tj|vs#tj|vr-|t|||nd|d<tj|vr}||||js|td2||}td?}td@}tjs(|d5krd6|d7}|||jsd8|d9}|||d:kr(tj||d;|d dAr3d|dB<|dCd<r>d|dD<|S)Ez+Resolve opener options specific to revlogs.sflagprocessorsTrevlogv1revlogv2s changelogv2s generaldeltarschunkcachesizeNstorages#revlog.optimize-delta-parent-choicesdeltabothparentssrevlog.issue6528.fix-incomingsissue6528.fix-incomingsrevlog.reuse-external-deltaFs"revlog.reuse-external-delta-parents lazydeltas lazydeltabasersmaxdeltachainspanrsmmapindexthresholds sparse-readssparse-read.density-thresholdssparse-read.min-gap-sizeswith-sparse-readssparse-read-density-thresholdssparse-read-min-gap-size sparse-revlogs maxchainlensrevlog-compression-sexp-compression--s compenginesrevlog.zlib.levels zlib.level s8invalid value for `storage.revlog.zlib.level` config: %dsrevlog.zstd.levels zstd.levels8invalid value for `storage.revlog.zstd.level` config: %dsenableellipsiss rust.indexs#revlog.persistent-nodemap.slow-path)rGwarnrIsMunknown value for config "storage.revlog.persistent-nodemap.slow-path": "%s" s"falling back to default value: %s sQaccessing `persistent-nodemap` repository without associated fast implementation.s@check `hg help config.format.use-persistent-nodemap` for detailsrs warning: r*(s) rIrJrvsdirstate-v2.slow-paths7unknown value for config "dirstate-v2.slow-path": "%s" sJaccessing `dirstate-v2` repository without associated fast implementation.s9check `hg help config.format.use-dirstate-v2` for detailssrevlog.persistent-nodemap.mmapspersistent-nodemap.mmapdevelsdevel-force-nodemap)r.rr{r|GENERALDELTA_REQUIREMENTrrkr. gddeltaconfig configbytesfloatrlSPARSEREVLOG_REQUIREMENT revlogconstSPARSE_REVLOG_MAX_CHAIN_LENGTH startswithsplitrrrNARROW_REQUIREMENTNODEMAP_REQUIREMENTconfig_defaultwarnquietr+HAS_FAST_PERSISTENT_NODEMAPDIRSTATE_V2_REQUIREMENTrHAS_FAST_DIRSTATE_V2)rr*rXrychunkcachesizedeltabothparents issue6528 lazydelta lazydeltabase chainspanmmapindexthresholdwithsparsereadsrdensitythres srmingapsize sparserevlog maxchainlenrprefixmsg slow_pathdefaultrKrOrOrPrs                                 rcKtS)z6Produce a type conforming to ``ilocalrepositorymain``.)r)rrOrOrPmakemainsrc@r)revlogfilestoragez File storage when using revlogs.cCs$|dr |dd}t|j|SN/r)rrsvfsrIrarOrOrPfiles  zrevlogfilestorage.fileNrSrTrUrVrrOrOrOrPr rc@r)revlognarrowfilestoragez1File storage when using revlogs and narrow files.cCs(|dr |dd}t|j||jSr)rr narrowfilelogr_storenarrowmatchrrOrOrPrs  zrevlognarrowfilestorage.fileNrrOrOrOrPrrrcKs*|tj|tjtj|vrtStS)z=Produce a type conforming to ``ilocalrepositoryfilestorage``.)r^r8 REPO_FEATURE_REVLOG_FILE_STORAGErr.rrr)r*rXrrOrOrPmakefilestorages   rcCrrA)rrOrOrOrPrVrVcCrrA)rrOrOrOrPrVrc@seZdZdZejejejejej ej ej ej ej ejejejejejejejejejejhZhdZ dddZddZdd Zd d Zd d ZddZe ddZ!e ddZ"ddZ#ddZ$ddZ%dddZ&e'ddddd d!Z(d"d#Z)e d$d%Z*e+d&d'd(d)Z,e+d*d+d,Z-e.d-d.Z/e0d/d0Z1e2d1d2d3Z3d4d5Z4d6d7Z5e+e6j7d8d9Z8e+e6j7d:d;Z9e+e6j7de=dEdFZ?e@dGdHZAe dIdJZBdKdLZCdMdNZDdOdPZEeEZFdQdRZGdSdTZHdUdVZIdWdXZJddYdZZKd[d\ZLdd]d^ZMeNd_d`ZOdadbZPdcddZQdedfZRdgdhZSdidjZTdkdlZUdmdnZVe@dodpZWdqdrZXddsdtZYdudvZZdwdxZ[dydzZ\d{d|Z]d}d~Z^ddZ_ddZ`ddZadddZbdddZcddZddddZeddZfddZge=ddZhe=ddZiddZjddZkdddZlddZmddZndddZoddZpddZqe@ddZrddZsdddZte@ddZuddZve@dddZwddZxddZyddZzdddZ{ddZ|e@ddZ}ddZ~ddZdddÄZdddńZddDŽZddɄZdd˄Ze@    >  ddd΄Ze@dddЄZe@dd҄Ze@ddԄZ   > > > >dddׄZddلZddۄZdd݄Zddd߄ZdddZddZddZddZe=ddZddZddZdddZddZddZ >dddZdS(raQMain class for representing local repositories. All local repositories are instances of this class. Constructed on its own, instances of this class are not usable as repository objects. To obtain a usable repository object, call ``hg.repository()``, ``localrepo.instance()``, or ``localrepo.makelocalrepository()``. The latter is the lowest-level. ``instance()`` adds support for creating new repositories. ``hg.repository()`` adds more extension integration, including calling ``reposetup()``. Generally speaking, ``hg.repository()`` should be used. > bisect.statercache/dirstater9NcCs||_||_||_||_|j|_||_|j|_||_t |_ |j j |_ ||_ ||_ | |_| |_| |_| |_d|_|jddsE|jddrN||jj|j_g|_t|j|jj|_|jj|_|jj|_|jddst|jddrt|jdr||jjj|jj_n ||jj|j_d|_ t!"|_#d|_$i|_%i|_&d|_'|_(|_)i|_*i|_+g|_,t--|_.i|_/i|_0t12||_3d|_4t5j6|jvrd|_4t7|_8i|_9t:;|dS)aCreate a new local repository instance. Most callers should use ``hg.repository()``, ``localrepo.instance()``, or ``localrepo.makelocalrepository()`` for obtaining a new repository object. Arguments: baseui ``ui.ui`` instance that ``ui`` argument was based off of. ui ``ui.ui`` instance for use by the repository. origroot ``bytes`` path to working directory root of this repository. wdirvfs ``vfs.vfs`` rooted at the working directory. hgvfs ``vfs.vfs`` rooted at .hg/ requirements ``set`` of bytestrings representing repository opening requirements. supportedrequirements ``set`` of bytestrings representing repository requirements that we know how to open. May be a supetset of ``requirements``. sharedpath ``bytes`` Defining path to storage base directory. Points to a ``.hg/`` directory somewhere. store ``store.basicstore`` (or derived) instance providing access to versioned storage. cachevfs ``vfs.vfs`` used for cache files. wcachevfs ``vfs.vfs`` used for cache files related to the working copy. features ``set`` of bytestrings defining features/capabilities of this instance. intents ``set`` of system strings indicating what this repo will be used for. Nr all-warnings check-lockssvfsFr)z@localrepository._getvfsward..checkvfs..write with no lock: "%s"rswrite with no wlock: "%s") r5rrralenr develwarnany _currentlockrr_wlockfreeprefix)rar%rrJrvfs_path_prefixesrorigfuncrrefrIr+rPcheckvfssF       z-localrepository._getvfsward..checkvfsrAweakrefref)rIr6r8rOr5rPr s -zlocalrepository._getvfswardcst|dfdd }|S)zbuild a ward for self.svfsNcs||d}}|dust|dsdS|dvrdS||jr,|t|jdd}||jdur>|jjd|dd|S)Nr$r&r'rr.)r*) r5rrr6r/r2rrr0)rar%rrJr6r7rOrP checksvfss  z/localrepository._getsvfsward..checksvfsrAr9)rIr6r>rOr=rPrs zlocalrepository._getsvfswardcCrrA) _writecachesrsrOrOrPr rgzlocalrepository.closecCs|jr |jdSdSrA)rwritersrOrOrPr?szlocalrepository._writecachescCs\|jddrt|}ttj|dd}|dt||jddr,|t j |S)Nrsbundle2-advertisesclient)rolesbundle2=snarrow) rrkrQr encodecaps getrepocapsr^urlreqquoter7 NARROWCAP)rIrcapsblobrOrOrPrs  z%localrepository._restrictcapabilitiescCstj|j|jdS)N)callbackr$ pathauditorr _checknestedrsrOrOrPauditor szlocalrepository.auditorcCstj|j|jdddS)NFT)rHrealfscachedrIrsrOrOrP nofsauditor&s zlocalrepository.nofsauditorcCs||jsdS|t|jdd}t|}|d}t|}|rKd|}||jvrE||kr3dS||}| |t|ddS| |s#dS)z/Determine if path is a legal nested repository.FrNrT) rrr/r5pconvert splitpathrcsubstatesub checknestedpop)rIrasubpath normsubpathctxpartsrrSrOrOrPrK.s       zlocalrepository._checknestedcCrrA)rrsrOrOrPrTrzlocalrepository.peercCr)zaReturn unfiltered version of the repository Intended to be overwritten by filtered repo.rOrsrOrOrPrBWszlocalrepository.unfilteredcCs<|jdurd|vr|d|j}t|j}||||S)aReturn a filtered version of a repository The `name` parameter is the identifier of the requested view. This will return a repoview object set "exactly" to the specified view. This function does not apply recursive filtering to a repository. For example calling `repo.filtered("served")` will return a repoview using the "served" view, regardless of the initial view used by `repo`. In other word, there is always only one level of `repoview` "filtering". N%)rr)newtyperBrN)rIrvisibilityexceptionsrrOrOrPr]s  zlocalrepository.filtered) bookmarksr[)sbookmarks.currentr[)r]rkrpcCs|t|SrA)_refreshchangelogr bmstorersrOrOrP _bookmarksos7 zlocalrepository._bookmarkscCs(dt|vr|dur|`dSdSdS)z7make sure the in memory changelog match the on-disk one changelogN)rcurrenttransactionrarsrOrOrPr^sz!localrepository._refreshchangelogcCs|jjSrA)r`activersrOrOrP_activebookmarkzlocalrepository._activebookmark phaserootsrqcCst||jSrA)r% phasecacher rsrOrOrP _phasecachezlocalrepository._phasecachesobsstorecCst|j|SrA)r#rxrrsrOrOrPobsstorerizlocalrepository.obsstorecCs,|j|jjt|jt|j ddS)N changelog)concurrencychecker) rprefetch_parentsr0rar4mayhavependingr revlogchecker get_checkerr)rJrOrOrPras   zlocalrepository.changelogcCs|j||jSrA)r0 manifestlogrrsrOrOrPrqrzlocalrepository.manifestlogrcCs|SrA) _makedirstatersrOrOrPrrezlocalrepository.dirstatec sPfdd}tj}tj}|jv}|jv}tjjjjj|j ||dS)z3Extension point for wrapping the dirstate per-repo.cs tSrA)r/matcherrOrsrOrPrV z/localrepository._makedirstate..)use_tracked_hint) r.rDIRSTATE_TRACKED_HINT_V1r*rr6rr_dirstatevalidater)rI sparsematchfnv2_reqthuse_dirstate_v2rurOrsrPrrs   zlocalrepository._makedirstatecCsRz |j||WStjy(|js#d|_|jtdt||j YSw)NTs-warning: ignoring unknown working parent %s! ) rarevr LookupErrorrrrrr r rInoderOrOrPrws  z!localrepository._dirstatevalidatecCs t|S)zdmatcher patterns for this repository's narrowspec A tuple of (includes, excludes). )r"loadrsrOrOrP narrowpatss zlocalrepository.narrowpatscCs0tj|jvr tS|j\}}tj|j||dSN)includeexclude) r.rr*matchmodalwaysrr"rrrIrrrOrOrPrs  z!localrepository._storenarrowmatchcCs:tj|jvr tSt||j\}}tj|j ||dSr) r.rr*rrr"checkworkingcopynarrowspecrrrrrOrOrP _narrowmatchs   zlocalrepository._narrowmatchFcCsP|r%|r|jst|}t|j|g}t||St||jS|jS)amatcher corresponding the the repo's narrowspec If `match` is given, then that will be intersected with the narrow matcher. If `includeexact` is True, then any exact matches from `match` will be included even if they're outside the narrowspec. )rrrexactfiles unionmatcherintersectmatchers)rIr includeexactemnmrOrOrP narrowmatchs  zlocalrepository.narrowmatchcCst||||jdddS)NTclearfilecache)r"save invalidate)rI newincludes newexcludesrOrOrP setnarrowpatsszlocalrepository.setnarrowpatscCs(dt|jjftt|jjf|jt|jfiS)Nnull)rrr rsrOrOrP_quick_access_changeid_nulls   z+localrepository._quick_access_changeid_nullc Cs|j}|j}|jD]=}||jkrq|j|}|dur"q||f}|||<|||<| |D]}|t kr:q3| |}||f}|||<|||<q3q|j }||jkr]|||d<|S)N.) rrrBrarparentsr indexget_rev parentrevsrrp1) rIquickclrr|pairrrPp1noderOrOrP_quick_access_changeid_wc$s.         z)localrepository._quick_access_changeid_wccCsdt|vr |jd=dSdS)Nr)rrCrsrOrOrP!_quick_access_changeid_invalidateCs  z1localrepository._quick_access_changeid_invalidatecCs|jtjvr |jS|jS)zan helper dictionnary for __getitem__ calls This contains a list of symbol we can recognise right away without further processing. )r r) filter_has_wcrrrsrOrOrP_quick_access_changeidHs z&localrepository._quick_access_changeidc s@|dur tSt|tjr|St|tr'fddtj|tDSj |}|dur>|\}}tj ||ddS|dkrTj }j |}t ||Szt|trcj |}|}nz|dkruj}j |}nht|jjkrz |}j |}WnUtjyt|}tyr|jvrtd}t|t|t|}wt|djjkrt|}j |}nt d |t!t"|ft ||WStj#tjfyt$td t!|t%tfyt&td t!|tj'ytYSw) Ncs g|] }|jjvr|qSrO)ra filteredrevs)rOirsrOrP ]s  z/localrepository.__getitem__..F)maybe_filteredtiprs*working directory has unknown parent '%s'!rs$unsupported changeid '%s' of type %ssfiltered revision '%s'unknown revision '%s')(r workingctxrbasectxslicer'xrangeindicesr/rrz changectxratipr|intrrrrBrnodelenrFilteredLookupErrorrr}rrrrr rrrrKFilteredIndexErrorFilteredRepoLookupError IndexErrorRepoLookupErrorWdirUnsupported)rIchangeid quick_accessr|rrrOrsrP __getitem__Ssv           zlocalrepository.__getitem__cCs&z||WdStjyYdSw)z!True if the given changeid existsTF)rr)rIrrOrOrP __contains__s zlocalrepository.__contains__cCrrrOrsrOrOrP __nonzero__rzlocalrepository.__nonzero__cCs|}t|jSrA)rBr/ra)rIrLrOrOrP__len__s zlocalrepository.__len__cCs t|jSrA)iterrarsrOrOrP__iter__rmzlocalrepository.__iter__cGs tj|g|R}t||S)aFind revisions matching a revset. The revset is specified as a string ``expr`` that may contain %-formatting to escape certain types. See ``revsetlang.formatspec``. Revset aliases from the configuration are not expanded. To expand user aliases, consider calling ``scmutil.revrange()`` or ``repo.anyrevs([expr], user=True)``. Returns a smartset.abstractsmartset, which is a list-like interface that contains integer revisions. )r-spectreer, makematcher)rIexprrtreerOrOrPrevss zlocalrepository.revscgs(|j|g|RD]}||Vq dS)aVFind revisions matching a revset and emit changectx instances. This is a convenience wrapper around ``revs()`` that iterates the result and is a generator of changectx instances. Revset aliases from the configuration are not expanded. To expand user aliases, consider calling ``scmutil.revrange()``. N)r)rIrrrrOrOrPrQs zlocalrepository.setcCs|dgkr ttgS|dgkr"|jd}|dur"t|dgS|r5tj|j|t||d}||Stjd||d}||S)a<Find revisions matching one of the given revsets. Revset aliases from the configuration are not expanded by default. To expand user aliases, specify ``user=True``. To provide some local definitions overriding user aliases, set ``localalias`` to ``{name: definitionstring}``. rrNr)r localalias)r)r,basesetrrrzmatchanyrlookupfn)rIspecsuserr quick_datarQrOrOrPanyrevss    zlocalrepository.anyrevscCs d|jS)Nsfile:rrsrOrOrPrrmzlocalrepository.urlcKstj|j|||fi|S)zCall a hook, passing this repo instance. This a convenience method to aid invoking hooks. Extensions likely won't call this unless they have registered a custom hook or are replacing code that is expected to call a hook. )rr)rIrthrowrrOrOrPrszlocalrepository.hookcCs*Gdddt}|}|\|_|_|S)zMReturns a tagscache object that contains various tags related caches.c@seZdZddZdS)z-localrepository._tagscache..tagscachecSsd|_|_d|_|_dSrA)r2tagtypes nodetagscachetagslistrsrOrOrPr\s z6localrepository._tagscache..tagscache.__init__N)rSrTrUr\rOrOrOrP tagscaches r)r _findtagsr2r)rIrcacherOrOrP _tagscaches zlocalrepository._tagscachec Csni}|jjr |\}}n|jj}|jj}t|D]\}}z |||||<Wqtj t fy4Yqw|S)zreturn a mapping of tag to node) rarrrr2r|r' iteritemsrr}rh)rItr2ttr|kvrOrOrPr2s zlocalrepository.tagscCst|j|}dd|D}t|j|||i}t|D]\}\}}||jkr0||t|<q|j |d<ddt|D}||fS)auDo the hard work of finding tags. Return a pair of dicts (tags, tagtypes) where tags maps tag name to node, and tagtypes maps tag name to a string like 'global' or 'local'. Subclasses or extensions are free to add their own tags, but should be aware that the returned dicts will be retained for the duration of the localrepo object.cSsi|]}|dqS)sglobalrO)rOtagrOrOrP 1sz-localrepository._findtags..rcSsi|] \}}t||qSrO)rtolocal)rOrrRrOrOrPr>s ) tagsmodfindglobaltagsr readlocaltagsr'rr rrrar)rIalltagsrr2rrhistrOrOrPr s zlocalrepository._findtagscCs|jj|S)z return the type of the given tag. result can be: 'local' : a local tag 'global' : a global tag None : tag does not exist )rrrz)rItagnamerOrOrPtagtypeDs zlocalrepository.tagtypecCsZ|jjs)g}t|D]\}}||j|||fq ddt|D|j_|jjS)z)return a list of tags ordered by revisioncSsg|] \}}}||fqSrOrO)rOrrrPrOrOrPrUsz,localrepository.tagslist..) rrr'rr2r{rar|r)rIlrrPrOrOrPrOs zlocalrepository.tagslistcCsf|jjs+i}t|jjD] \}}||g|q t|D]}|q ||j_|jj |gS)z&return the tags associated with a node) rrr'rr2 setdefaultr{ itervaluessortrz)rIrrrrPr2rOrOrPnodetagsYs zlocalrepository.nodetagscCr)z;return the list of bookmarks pointing to the specified node)r`rr~rOrOrP nodebookmarksd zlocalrepository.nodebookmarkscCs |j|S)zkreturns a dictionary {branch: [branchheads]} with branchheads ordered by increasing revision number)rrsrOrOrPr hs zlocalrepository.branchmapcCs|js t||_|jSrA)rr revbranchcacherBrsrOrOrPrmszlocalrepository.revbranchcachecCs|||dSrA)rsetdata)rIr|changelogrevisionrOrOrPregister_changesetsrz"localrepository.register_changesetcCs>z||WSty|sttd| YdSw)zreturn the tip node for a given branch If ignoremissing is True, then this method will not raise an error. This is helpful for callers that only expect None for a missing branch (e.g. namespace). sunknown branch '%s'N)r branchtiprErrr)rIbranch ignoremissingrOrOrPrvs zlocalrepository.branchtipcCs.t||}|durttd||S)Nr)r. revsymbolrrrr)rIrrrOrOrPrszlocalrepository.lookupcCs"||r |St||SrA)r hasbranchr.rrrrOrOrP lookupbranchszlocalrepository.lookupbranchc CsJ|j}|jj}|j}g}|D]}||}|dup||v }||q|SrA)rarrrr{) rIrrrrrrPrresprOrOrPrs zlocalrepository.knowncCrrArOrsrOrOrPrrzlocalrepository.localcCs|jjddddS)NphasesspublishT) untrusted)rrkrsrOrOrP publishingszlocalrepository.publishingcCs(|sdS|s dS|djj S)NFTvisible)rrrrarrsrOrOrPcancopys zlocalrepository.cancopycCs|j|jkrdSdS)z2the type of shared repository (None if not shared)rFN)r6rarsrOrOrPrs zlocalrepository.sharedcGs|jj|j|g|RSrA)r6reljoinr)rIrinsidefrOrOrPwjoinrzlocalrepository.wjoincCs*|dur|j}|d|||dSrA)r  setparentsr)rIrp2rOrOrPrs zlocalrepository.setparentscCstj|||||dS)zcchangeid must be a changeset revision, if specified. fileid can be a file revision or node.)r)rfilectx)rIrarfileidrrOrOrPrs zlocalrepository.filectxcCrrA)rgetcwdrsrOrOrPrrmzlocalrepository.getcwdcCs|j||SrA)rpathto)rIrcwdrOrOrPr rzlocalrepository.pathtoc Cs||jvrmg}|j|D]Z\}}|dkrq t|jd|g}d}|}t|jD]\}} | |r@| }|t |d }nq)|sJdd}d|_ t |ds_|} | fdd}d| j |_ ||||fq ||j|<|j|S) N!rkc[s t||SrA)r:filter)scrrOrOrPrV z-localrepository._loadfilter.. commandfilterrc[s |||SrArO)r roldfnrrOrOrPrVrtzcompat-)rr configitemsrrrr'rrrr/lstriprS getargspecr{) rIr rpatcmdmfrparamsrfilterfnrrOrOrP _loadfilters0      zlocalrepository._loadfiltercCsV|D]&\}}}||r(|jd||pt|jf||||j||d}|Sq|S)Nsfiltering %s through %s )rrJfilename)rdebugr'sysbytesrS)rI filterpatsrdatarrrrOrOrP_filterszlocalrepository._filtercC |dS)NsencoderrsrOrOrP_encodefilterpats z!localrepository._encodefilterpatscCr!)Nsdecoder"rsrOrOrP_decodefilterpatsr$z!localrepository._decodefilterpatscCs||j|<dSrA)r)rIrr rOrOrP adddatafilterrzlocalrepository.adddatafiltercCs6|j|r |j|}n|j|}||j||SrA)rislinkreadlinkr,r r#rIrrrOrOrPwreads  zlocalrepository.wreadcKs||j||}d|vr|j||t|S|jj||fd|i|d|vr4|j|ddt|S|j|ddt|S)zwrite ``data`` into ``filename`` in the working directory This returns length of written (maybe decoded) data. lbackgroundclosexFT)r r%rsymlinkr@setflagsr/)rIrrflagsr,rrOrOrPwwrite s  zlocalrepository.wwritecCs||j||SrA)r r%r)rOrOrP wwritedata szlocalrepository.wwritedatacCs(|jr|}nd}|r|r|SdS)z4return the current transaction or None if non existsN)rrunning)rItrrOrOrPrb s   z"localrepository.currenttransactionc sLjddsjddrjdurtddur)jdSj dr:tj t dt dd d t t f}tt|}d |}jd d |dddD}|rm|}njj}jjd}tddjdd} dkr| rjfddfdd} fdd} tj|j|ddt|jj| | td t j!d<t"j!d <gj!d!<ij!d"<|j#d#<j#d$<j!j#d%<$d&jj%fd'd(} $d)| &d*'fd+d,} (d-| &d.j)t_*t+,S)/Nrrrstransaction requires locking)rjournalsabandoned transaction founds(run 'hg recover' to clean up transactionrJs%.40f#%fsTXN:s pretxnopenT)rtxnnametxnidcSsg|] \}}||t|fqSrOundonamerOr6xrOrOrPr9 z/localrepository.transaction..)r[rFcSdSrArO)r;rOrOrPrVb rz-localrepository.transaction..rshook-track-tagsstripcs}|dus Jt|j|}|j}t|j||}t|j|||}|rOd|jd<|jdddd}t||WddS1sHwYdSdS)N1s tag_movedschanges/tags.changeswT) atomictemp) r fnoderevsrraheadrevsdifftagshookargsr6 writediff)tr2rJ oldfnodesnewheads newfnodeschanges changesfile)oldheadsreporefrOrP tracktagsj s   "z.localrepository.transaction..tracktagsc s~|}|dus Jd}|jj|}|r9|jj|d}|dd}|ddr.d}nd}t||||t|jd rmtj d  D]#\}\}} j } | t||| |j dd d it| qIt|jd r|j} j dD]/\} \}} | D]&} j } t| | }| t||| |j dd d it| qq~|j dd d itj dS)zwill run pre-closing hooksN)rssingle-head-per-branchrsaccount-closed-headsFspublic-changes-onlys immutablerpretxnclose-bookmarkr]rTpretxnclose-phaser pretxnclose)rP)rQ)rR)rrkconfigsuboptionsrzr.enforcesingleheadrhashookrrKrrErrr preparehookargsr'rrBrarrr%)rGrJ singleheadopt singlehead singleheadsub accountclosedr rrrrrrr|r)descrNr4rOrOrPvalidate} sf           z-localrepository.transaction..validatecs\}|dur dS|r|jddStdtd|jdd|jdddS)Njournal.narrowspecjournal.narrowspec.dirstatejournal.dirstateTr)rr@r" restorebackuprestorewcbackupr)r4successrJ)rNrIrOrP releasefn s  z.localrepository.transaction..releasefnundo) validatorrccheckambigfilesr origrepolens obsmarkersrr]stxnidstxnnameschangess flush-fncachecs6|jfdd}}|dusJ||dS)z@To be run if transaction is successful, will schedule a hook runc s0}|dus Jt|jdr?tjd}|D]#\}\}}j}|t ||||j d ddit |qt|jdr| j}tjdddd }|D]/\} \}}| D]&} j}t|| } |t | |||j d ddit |q`qX|j d ddit dS)Ntxnclose-bookmarkr]rFtxnclose-phasercSs |ddS)NrrO)rrOrOrPrV rzUlocalrepository.transaction..txnclosehook..hookfunc..)rtxnclose)rh)ri)rj)rrUrrrKrrErrr rVr'rrBrarrr%) unused_successrJ bmchangesrrrrrphasemvrr|r)rErNr4rOrPhookfunc sN      zClocalrepository.transaction..txnclosehook..hookfuncN)rE _afterlock)rGrnrJ)rNr4)rErP txnclosehook s # z1localrepository.transaction..txnclosehooks txnclose-hooks -warm-cachecs4}|dus J|j dddit|jdS)z#To be run if transaction is abortedNtxnabortrF)rq)rr'rrE)rGrJrNrOrP txnaborthook% s   z1localrepository.transaction..txnaborthooks txnabort-hooksrefresh-filecachestats)-rrkr2rrrrbnestrr2r3rrandomtimerr9sha1digestr _writejournal _journalfilesrr6r:r;rarCr3 aftertransr0ryr]r/rKrQrE addfinalizer@ addpostclose_buildcacheupdateraddabort_refreshfilecachestatsrr.registersummarycallback)rIr[reportidbasehar7renamesrpvfsmapshouldtracktagsr\rcrprsrO)r[rMrNrIr4rOrPr3" s~     "  @       /   zlocalrepository.transactionc CsH|jdf|jdf|jdf|jdf|jdf|jdft|df|jdffS) Nr5r]r^r_journal.branch journal.descjournal.bookmarksjournal.phaseroots)rr6r bookmarksvfsrsrOrOrPrz5 s zlocalrepository._journalfilescCsdd|DS)NcSsg|] \}}|t|fqSrOr8r:rOrOrPrB sz-localrepository.undofiles..)rzrsrOrOrP undofilesA rzlocalrepository.undofilescCs|jddt|dt|d|jdt|j|jddt ||ft |}|d| d|j d |j d dS) Nr_r^r]rrs%d %s rr]rrf)r savebackupr" savewcbackupr6r@r fromlocalrr/r rrr)rIr[rrOrOrPryD s    zlocalrepository._writejournalcCs|A|jdr4|jtd|j|jd}tj|j|d|jj t d|  WddS|j td WddS1sHwYdS)Nr5s%rolling back interrupted transaction )rkr[rfTs%no interrupted transaction available F) rrr2rstatusrr6r3rollbackrr]r)rIrrOrOrPrecoverS s&  $zlocalrepository.recoverc Csd}}}z3|}|}|jdr)t|d}||||Wt|||S|jt dWt|||dSt|||w)Nrdsrollbacks"no rollback information available r) wlockrrr2r _rollbackreleaserrr)rIdryrunforcerrdsguardrOrOrPrh s   zlocalrepository.rollbackcsp|j}z=|jd}t|d|dd}}}t|dkr$|d}|d} |r7|jr7td| ||f} ntd| |f} WntyOtd} d}Ynw|si|d |d kri|d krit j td td d| | |rrdS|j } ||j|jd} tj|j| d|jtdt|} | dr| jdddd|jdr|jjdddd||jjjtfdd| D}|r2|t|dt |d|j ddz|jd}|j !t"#|Wnty|td|j $Ynwt%dd |d D} t| dkr#| td!| n | td"| t&j'(||)dS)#Ns undo.descrrr)rs8repository tip rolled back to revision %d (undo %s: %s) s4repository tip rolled back to revision %d (undo %s) s!rolling back unknown transaction rrcommits;rollback of last commit while not checked out may lose datasuse -f to forcerJ)r[rkrdrsundo.bookmarksr]T) checkambigsundo.phaserootsrfc3s|]}| VqdSrArOrOphas_noderOrPr, r-z,localrepository._rollback..sundo.narrowspecsundo.narrowspec.dirstates undo.dirstates undo.branchs>named branch could not be reset: current branch is still '%s' cSsg|]}|qSrO)r|rrOrOrPr z-localrepository._rollback..s3working directory now based on revisions %d and %d s+working directory now based on revision %d )*rr6r,r:rr/verboserr;rrrrr destroyingrr3rrr]r rr2renamerrarrr1rr"r`ra setbranchrrrr mergestatemodrclean destroyed)rIrrrrroldlenr[detailoldtiprrrr parentgonerrOrrPrw s               zlocalrepository._rollbackcst|fdd}|S)zcalled during transaction to build the callback updating cache Lives on the repository to help extension who might want to augment this logic. For this purpose, the created transaction is passed to the method. cs }|dus J||dSrA) updatecaches)r4rJrrrOrPupdater s z3localrepository._buildcacheupdater..updaterr9)rInewtransactionrrOrrrPr~ s  z"localrepository._buildcacheupdaterc Cs|dur|jddkrdS|}|r+d}|j|dtj}|dkr'tj}tj}n|dur2tj}tj |vr^|dusD|j dt |kr^|j d| d | d |j|tj|vrj|jj|d tj|vrv|jj|d tj|vr|}|jD]}||q|tj|vr|d D]}|qtj|vrt|j||j tj!|vr|"tj#|vr| d "tj$|vrt%j&'D]} | | } | | qdSdS) awarm appropriate caches If this function is called after a transaction closed. The transaction will be available in the 'tr' argument. This can be used to selectively update caches relevant to the changes in that transaction. If 'full' is set, make sure all caches the function knows about have up-to-date data. Even the ones usually loaded more lazily. The `full` argument can take a special "post-clone" value. In this case the cache warming is made after a clone and of the slower cache might be skipped, namely the `.fnodetags` one. This argument is 5.8 specific as we plan for a cleaner way to deal with this for 5.9. Nssourcer>za`full` argument for `repo.updatecaches` is deprecated (use `caches=repository.CACHE_ALL` instead)s5.9s post-clonergsupdating the branch cache rs served.hidden)r3r)(rErzrBr deprecwarnr8 CACHES_ALLCACHES_POST_CLONECACHES_DEFAULTCACHE_BRANCHMAP_SERVEDrKr/rrr r write_delayedCACHE_CHANGELOG_CACHEra update_cachesCACHE_MANIFESTLOG_CACHErqCACHE_REV_BRANCHr branchinfor@CACHE_FULL_MANIFESTrmanifestCACHE_FILE_NODE_TAGSrrBrCACHE_TAGS_DEFAULTr2CACHE_TAGS_SERVEDCACHE_BRANCHMAP_ALLr) filtertablekeys) rIr4fullcachesrLrrbcrrXfiltrrOrOrPr sV               zlocalrepository.updatecachescCs4dt|vr |jd=|j||jdS)Nr)rrCrclearinvalidatevolatilesetsrrsrOrOrPinvalidatecaches7 s  z localrepository.invalidatecachescCs |jt||dSrA)rrr#clearobscachesrrsrOrOrPrA s   z&localrepository.invalidatevolatilesetsc CsPt|dr&|jjD]}zt|j|Wq tyYq wt|ddSdS)aInvalidates the dirstate, causing the next call to dirstate to check if it was modified since the last time it was read, rereading it if it has. This is different to dirstate.invalidate() that it doesn't always rereads the dirstate. Use dirstate.invalidate() if you want to explicitly read the dirstate again (i.e. restoring it to a previous known good state).rN)rrrr AttributeErrorrB)rIrrOrOrPinvalidatedirstateF s  z"localrepository.invalidatedirstatec Cs|}t|jD]*}|dkrq |dkr|r|jjrq |r%|j|=zt||Wq ty5Yq w| |sE|j dSdS)a9Invalidates both store and non-store parts other than dirstate If a transaction is running, invalidation of store is omitted, because discarding in-memory changes might cause inconsistency (e.g. incomplete fncache causes unintentional failure, but redundant one doesn't). rrkN) rBlistrrrbra_delayedr rrr0)rIrrBrrOrOrPrW s* zlocalrepository.invalidatecCs||dS)zyFully invalidates both store and non-store parts, causing the subsequent operation to reread any outside changes.N)rrrsrOrOrP invalidateall{ s zlocalrepository.invalidateallcCs>|jD]\}}t|}|dks||jvrq|qdS)z>Reload stats of cached files so that they are flagged as validrN)rrr'rrCrefresh)rIr4rcerOrOrPr s   z&localrepository._refreshfilecachestatsc CsXd}d}|r|jdd}|jdd}|jdd} tj|j|||||||| d } | S)Nruistimeouts timeout.warnssignal-safe-lock)rc acquirefnr[ signalsafe)rrrklockmodtrylock) rIr6locknamewaitrcrr[timeout warntimeoutrrrOrOrP_lock s$  zlocalrepository._lockcCsD|j|jfD]}|o |}|r|jr|j|dSq|ddS)zadd a callback to be run when the repository is fully unlocked The callback will be executed when the outermost lock is released (with wlock being higher level than 'lock').TN)rrheld postreleaser{)rIrHr;rrOrOrPro s    zlocalrepository._afterlockTcCsT||j}|dur||S|j|jd|d|jtd|jd}t ||_|S)a]Lock the repository store (.hg/store) and return a weak reference to the lock. Use this before modifying the store (e.g. committing or stripping). If you are opening a transaction, get a lock as well.) If both 'lock' and 'wlock' must be acquired, ensure you always acquires 'wlock' first to avoid a dead-lock hazard.Nslocks repository %s)r6rrrcrr[) r2rrrrrrrcr:r;)rIrrrOrOrPr s   zlocalrepository.lockc sjrnd}|dur|jr||S|r4jdds&jddr4jdur4jdfdd}j d||j t d j }t |_|S) a8Lock the non-store parts of the repository (everything under .hg except .hg/store) and return a weak reference to the lock. Use this before modifying files in .hg. If both 'lock' and 'wlock' must be acquired, ensure you always acquires 'wlock' first to avoid a dead-lock hazard.Nrrrs"wlock" acquired after "lock"cs4jr jnjdjddS)Nr)rpendingparentchangerr@rrrOrsrOrPunlock s   z%localrepository.wlock..unlockswlocksworking directory of %s)rrrrrkr2rr0rr6rrrcr:r;)rIrrrrOrsrPr s,      zlocalrepository.wlockcCs(|durdS|}|dus|jsdS|S)z3Returns the lock if it's held, or None if it's not.N)r)rIlockrefrrOrOrPr2 s zlocalrepository._currentlockcCs ||jS)z4Returns the wlock if it's held, or None if it's not.)r2rrsrOrOrP currentwlock rzlocalrepository.currentwlockc Cs|s|rkt|j|j|j}|D]U}|j|}|dks,||vs,||j vr-q||j vr9||t d|j |sF||r^|d}|D] }||rUnqL||t dq||jvrj||t dqdSdS)z2check for commit arguments that aren't committablersfile not found!rsno match under directory!sfile not tracked!N)isexactrrQmodifiedaddedremovedrr normalizerRdeletedrrrerhasdirr) rIwctxrrfailmatchedrdrrOrOrPcheckcommitpatterns s*     z#localrepository.checkcommitpatternsrkc s(|duri}dd}|st}|s||_aKd} t| dk} |s<| r<|s.failrsBcannot partially commit a merge (do not specify files or patterns))rr)rrsallowemptycommits(nothing to commit, clearing merge state s&cannot commit merge with missing filesscommitting subrepository %s rrks precommitT)rparent1parent2rs!note: commit message saved in %s sHnote: use 'hg commit --logfile .hg/last-message.txt --edit' to reuse it cs*jrjdtddSdS)Nr)rrr)rahasnoderrrkhookp1hookp2rrIrOrP commithook s   z*localrepository.commit..commithook)2rrbadrrr/rrrrrrextendrr1 precommitrrrworkingcommitctxrrr,r checkunresolvedisemptyrkrresetr_textsavecommitmessager. getuipathfnrrS subrelpathr writestaterrr rr3 commitctxr r markcommittedr@ro)rItextrdaterreditorextrarrmergersubs commitsubsnewstatecctxmseditedmsgfnuipathfnr rSsrrrrrOrrPr s       *       $     \ zlocalrepository.commitcCstj||||dS)N)rorigctx)rr)rIrXrrrOrOrPr szlocalrepository.commitctxcCsdt|vr |jdSdS)aInform the repository that nodes are about to be destroyed. Intended for use by strip and rollback, so there's a common place for anything that has to be done before destroying history. This is mostly useful for saving state that is in memory and waiting to be flushed when the current lock is released. Because a call to destroyed is imminent, the repo will be invalidated causing those changes to stay in memory (waiting for the next unlock), or vanish completely. rhN)rrhr@rsrOrOrPr s zlocalrepository.destroyingcCs*|j||j||dS)zInform the repository that nodes have been destroyed. Intended for use by strip and rollback, so there's a common place for anything that has to be done after destroying history. N)rh filterunknownr@rrrsrOrOrPr s   zlocalrepository.destroyedrcCs||||||||S)z3a convenience method that calls node1.status(node2))r)rInode1node2rignoredrunknown listsubreposrOrOrPr s zlocalrepository.statuscCs|j|dS)aAdd a callback to run within the wlock, at the point at which status fixups happen. On status completion, callback(wctx, status) will be called with the wlock held, unless the dirstate has changed from underneath or the wlock couldn't be grabbed. Callbacks should not capture and use a cached copy of the dirstate -- it might change in the meanwhile. Instead, they should access the dirstate via wctx.repo().dirstate. This list is emptied out after each status run -- extensions should make sure it adds to this list each time dirstate.status is called. Extensions should also make sure they don't call this for statuses that don't involve the dirstate. N)rr{)rIpsrOrOrPaddpostdsstatus szlocalrepository.addpostdsstatuscCr)zAUsed by workingctx to get the list of post-dirstate-status hooks.rrsrOrOrP postdsstatus szlocalrepository.postdsstatuscCs|jdd=dS)z7Used by workingctx to clear post-dirstate-status hooks.NrrsrOrOrPclearpostdsstatus rz!localrepository.clearpostdsstatuscsJ|dur|jt}fdd|DS|j|}t||jjddS)Ncsg|]}|qSrO)r)rOr|rrOrPr rSz)localrepository.heads..T)rreverse)rareversedrCrrr|)rIstartrCrrOr rPr s   zlocalrepository.headscsv|dur |d}|}||sgStt|j||d}|dur9t|j|g|dfdd|D}|S)aVreturn a (possibly filtered) list of heads for the given branch Heads are returned in topological order, from newest to oldest. If branch is None, use the dirstate branch. If start is not None, return only heads reachable from start. If closed is True, return heads that are marked as closed as well. N)closedrcsg|]}|vr|qSrOrO)rOhfbheadsrOrPr sz/localrepository.branchheads..) rr rrr" branchheadsrQra nodesbetween)rIrr#r$r!bheadsrOr&rPr( s  zlocalrepository.branchheadscCsv|s|jg}g}|D],}|} |j|}|d|jks%|d|jkr3||||d|dfn|d}qq |S)NTrr)rarrr r{)rIrrrPrrrOrOrPr! s  zlocalrepository.branchesc Csg}|D]@\}}|gd}}}d}||kr?||jkr?|j|d} ||kr0|||d}| }|d7}||kr?||jks||q|S)Nrrr)r rarr{) rIr rtopbottomrPrrrrrOrOrPr. s   zlocalrepository.betweencCr)zExtensions can override this function if additional checks have to be performed before pushing, or call it if they override push command. NrO)rIpushoprOrOrP checkpushA rzlocalrepository.checkpushcCstS)zReturn util.hooks consists of a pushop with repo, remote, outgoing methods, which are called before pushing changesets. )r5hooksrsrOrOrPprepushoutgoinghooksG sz$localrepository.prepushoutgoinghooksc sz1}i}|dur||jt|}|d<|d<|d<|d<jdddi|Wn,tjy]}zj t d||j rRj t d |j WYd}~d Sd}~wwj d ft fd d }|S)Nrrrr prepushkeyrTspushkey-abort: %s s(%s) Fspushing key for "%s:%s" csjdddS)Nr)rrrrr)rrrrrrrrIrOrPrunhookb s z(localrepository.pushkey..runhook)r1)rbrrEr'rrr HookAbortr write_errrrKrr&pushro) rIrrrrr4rErr3rOr2rPr&N s.   zlocalrepository.pushkeycCs@|jdd|d|jd|t||}|jd||d|S)Ns prelistkeysT)rrslisting keys for "%s" slistkeys)rvalues)rrrr&r)rIrr7rOrOrPro s  zlocalrepository.listkeyscCr)z+used to test argument passing over the wirerrrrOrOrPrv rzlocalrepository.debugwireargscCsL|dd}z ||W|n|w||jt|jddS)Nslast-message.txtswbr)r6r@rr rr/r)rIrfprOrOrPr s  z!localrepository.savecommitmessagecCs&tj|jvrdS|jt|dSrA)r8r}rXrr^r'r)rIcategoryrOrOrPregister_wanted_sidedata s z(localrepository.register_wanted_sidedatac Cs|tjvrtd}t||t|}||j|gv}|r-|s-td}t|||r<|s.c s`D]+\}}}||z|||Wqty-}z |jtjkr#WYd}~qd}~wwdSrA) tryunlinkrrgr<r=)r6srcdestr renamefilesrOrPa s   zaftertrans..arO)rrKrOrIrPr{ s  r{cCs6tj|\}}|dsJtj||dddS)Nr5rdr)osrarrrcr>)rr4rrOrOrPr9 sr9cCs*t|}|rt|||dt|||dS)N createopts)rW)r< urllocalpathcreaterepositoryr)rracreaterWrN localpathrOrOrPinstance s rScCrrrOr+rOrOrPislocal rrTcCs(t|pi}d|vr|dd|d<|S)zPopulate the default creation options for a repository. A dictionary of explicitly requested creation options can be passed in. Missing keys will be populated. backendrsnew-repo-backend)dictrlrrNrOrOrPdefaultcreateopts s rXcCsdt}|js|St||d}t||D] }|tjvr||q|jD] }|tjvr/||q#|S)zclone the requirements of a local repo for a local clone The store requirements are unchanged while the working copy requirements depends on the configuration rM)rQr*rXnewreporequirementsr.WORKING_DIR_REQUIREMENTSr^)rrNsrcrepotarget_requirementsrrOrOrPclone_requirements s      r]cCsld|vr td|ddkrttd|dtjh}|ddrB|tj|ddrB|tj |ddrB|tj | dd }|D]}|t j vr`t j |}|r`|r`nqJtjtd d d d |Dtdd|dkr|dn |dkr|d|t|r|tj|ddr|tj|ddr|tj|ddr|tj|tj|ddr|tj|dd}|dkr|tj|dd}|dkr|tj|tj|ddr|tj|dr |tj|dr|d|ddr"|tj|dd r/|tj |dd!r<|tj!d"|vrt"|d"j#}tj!|vrQ|}n%t"} |D]} | tj$vr`qV| |vrgqV| | qV|| 8}||O}|d#r|tj%n|tj&|dd$r|'dd%} td&} td'} | d(kr|j(| | | d|S|tj)|S))zDetermine the set of requirements for a new local repository. Extensions can wrap this function to specify custom requirements for new repositories. rUsFbackend key not present in createopts; was defaultcreateopts() called?rsCunable to determine repository requirements for storage backend: %srsusestores usefncaches dotencodesrevlog-compressionsIcompression engines %s defined by format.revlog-compression not available, css|]}d|VqdS)s"%s"NrO)rOr?rOrOrPr,sz&newreporequirements..s;run "hg debuginstall" to list available compression enginesrJrsrevlog-compression-zstdszlibrrsuse-dirstate-v2s"exp-use-copies-side-data-changesetrrsexp-use-changelog-v2s*enable-unstable-format-and-corrupt-my-datarsinternal-phase narrowfilesrsbookmarks-in-storesuse-persistent-nodemapuse-share-safe sharedreposharedrelativesuse-dirstate-tracked-hints!use-dirstate-tracked-hint.versionz)ignoring unknown tracked key version: %d zshallowfilestorerrUrar_ shareditemsrbcsi|] \}}|vr||qSrOrO)rOrrrrOrPrr<z)filterknowncreateopts..)rrWrOrprPfilterknowncreateoptss rqc Cs.|dur|durd}t|i}n6t||d}t||}t|ts'td|r;tjtddt |tddt ||d}|t ||8}t j |d d d }t |d }|rettd |d |vr|d j}|drztj||j}t|}Wnttfy} z tjtdt| dd} ~ ww|s||jd dd |vr|d|dtj |v} | rd |vr|d|!ddt"#|\} } t"$|| | rd |vrt j |dd d} t"$| | d |vr|%d||drdt |dd}|%d|dSdS)a7Create a new repository in a vfs. ``path`` path to the new repo's working directory. ``createopts`` options for the new repository. ``requirement`` predefined set of requirements. (incompatible with ``createopts``) The following keys for ``createopts`` are recognized: backend The storage backend to use. lfs Repository will be created with ``lfs`` requirement. The lfs extension will automatically be loaded when the repository is accessed. narrowfiles Set up repository to support narrow file storage. sharedrepo Repository object from which storage should be shared. sharedrelative Boolean indicating if the path to the shared repo should be stored as relative. By default, the pointer to the "parent" repo is stored as an absolute path. shareditems Set of items to share to the new repository (in addition to storage). shallowfilestore Indicates that storage for files should be shallow (not all ancestor revisions are known). Ns/cannot specify both createopts and requirementsrMs-filterknowncreateopts() did not return a dictsBunable to create repository because of unknown creation option: %sr^s#is a required extension not loaded?rJTrArCsrepository %s already existsrarbscannot calculate relative path) notindexedrTrUrFrqs9 dummy changelog to prevent using the old repo layoutrDr)ror*sshared)&rrrXrqrrVrrrcrrYrmr1r6r2r3r6rzrLrarelpathr4r5rPr;rhr;rmakedirsmakedirmkdirr.rr{r.filterrequirements writerequiresr@)rrarNr*r unknownoptsrYr5r6r? has_storewcreqstorereqrZrrOrOrPrPs~                    rPcCs*|Gdddt}t|d|dS)z9Poison a repository instance so it can no longer be used.c@seZdZddZddZdS)z,poisonrepository..poisonedrepositorycSs|dkr t||Std)Nrs/repo instances should not be used after unshare)r__getattribute__rr)rIitemrOrOrPr}Ms  z=poisonrepository..poisonedrepository.__getattribute__cSr=rArOrsrOrOrPrUrz2poisonrepository..poisonedrepository.closeN)rSrTrUr}rrOrOrOrPpoisonedrepositoryLs rrNN)rrr)rJrrOrOrPpoisonrepositoryBsrrA)NN) __future__rr<rrLrurrvr:i18nrrrrrrr r'r r rmr r rrrrrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r(r)r*r.r+r,r-r.r/r0rr1r2rr3r4r5r6r1r7 interfacesr8 interfaceutilutilsr9r:r;r< revlogutilsr=ror>rr?r"rurlerrrDrQr] filecacher@rYrjrnrrr propertycacherrrrrunionr implementeripeercommandexecutorrr ipeercommandsrripeerlegacycommandsrrr8r@rrprqrtrurvrxrzrrilocalrepositoryfilestoragerrrilocalrepositorymainrrr{r9rSrTrXr]rYrmrqrPrrOrOrOrPs  /       - %  :* '%     I  +  ~