a —+«b 7ã@s–dZddlmZddlmZddlmZddlmZm Z m Z m Z m Z m Z mZmZmZmZmZddlmZe jr€ddlZejjZnddlZejZdZiZe e¡Ze ¡Ze ¡Zed d d d ed d d d ed ddd Gdd„deƒZ Gdd„de!ƒZ"dd„Z#dd„Z$dd„Z%ed ddhddd„ƒZ&edddhdd d!„ƒZ'ed"ddhdd#d$„ƒZ(d%d&„Z)ed'ƒd(d)„ƒZ*ed*ƒd+d,„ƒZ+ed-ƒd.d/„ƒZ,dS)0a@ showing remotebookmarks and remotebranches in UI (EXPERIMENTAL) By default both remotebookmarks and remotebranches are turned on. Config knob to control the individually are as follows. Config options to tweak the default behaviour: remotenames.bookmarks Boolean value to enable or disable showing of remotebookmarks (default: True) remotenames.branches Boolean value to enable or disable showing of remotebranches (default: True) remotenames.hoistedpeer Name of the peer whose remotebookmarks should be hoisted into the top-level namespace (default: 'default') é)Úabsolute_import)Ú_)Úbin) Ú bookmarksÚerrorÚ extensionsÚ logexchangeÚ namespacesÚpycompatÚ registrarÚ revsetlangÚsmartsetÚ templateutilÚutil)Ú stringutilNsships-with-hg-coreó remotenamesó bookmarksT)Údefaultóbranchesó hoistedpeersdefaultc@sleZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dd„Z dd„Z dd„ZeZdS)Úlazyremotenamedictaü Read-only dict-like Class to lazily resolve remotename entries We are doing that because remotenames startup was slow. We lazily read the remotenames file once to figure out the potential entries and store them in self.potentialentries. Then when asked to resolve an entry, if it is not in self.potentialentries, then it isn't there, if it is in self.potentialentries we resolve it and store the result in self.cache. We cannot be lazy is when asked all the entries (keys). cCs"i|_i|_||_||_d|_dS)NF)ÚcacheÚpotentialentriesÚ_kindÚ_repoÚloaded)ÚselfÚkindÚrepo©rú7/usr/lib64/python3.9/site-packages/hgext/remotenames.pyÚ__init__as zlazyremotenamedict.__init__cCsFd|_|j}t ||j¡D]&\}}}|d|}|||f|j|<qdS)z?Read the remotenames file, store entries matching selected kindTó/N)rrrZreadremotenamefilerr)rrÚnodeZrpathZrnameÚnamerrr Ú_loadhsÿ zlazyremotenamedict._loadcCsr||jvrdS|j|\}}}|j}t|ƒ}z|j |¡WntyPYdS0|jdkrl|| ¡rldS|gS)z;Check that the node for potentialentry exists and return itNr)rrrÚ changelogÚrevÚ LookupErrorrZ closesbranch)rZpotentialentryr#Zremoter$rZbinnoderrr Ú _resolvedatars  zlazyremotenamedict._resolvedatacCs.|js| ¡| |¡}|dur$|Stƒ‚dS©N)rr%Ú_fetchandcacheÚKeyError©rÚkeyÚvalrrr Ú __getitem__ƒs  zlazyremotenamedict.__getitem__cCs t|jƒSr*)Úiterr©rrrr Ú__iter__Œszlazyremotenamedict.__iter__cCs t|jƒSr*)Úlenrr2rrr Ú__len__szlazyremotenamedict.__len__cCst‚dSr*©ÚNotImplementedErrorr2rrr Ú __setitem__’szlazyremotenamedict.__setitem__cCst‚dSr*r6r2rrr Ú __delitem__•szlazyremotenamedict.__delitem__cCs<||jvr|j|S| |¡}|dur4||j|<|SdSdSr*)rr)r-rrr r+˜s    z!lazyremotenamedict._fetchandcachecCs|js| ¡|j ¡S)z&Get a list of bookmark or branch names)rr%rÚkeysr2rrr r:¢szlazyremotenamedict.keysccs<|js| ¡t |j¡D]\}}|t|dƒgfVqdS)z Iterate over (name, node) tuplesrN)rr%r Ú iteritemsrr)rÚkZvtuprrr r;¨szlazyremotenamedict.iteritemsN)Ú__name__Ú __module__Ú __qualname__Ú__doc__r!r%r)r0r3r5r8r9r+r:r;Úitemsrrrr rUs     rc@sXeZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dd„Z dS)Ú remotenamesa% This class encapsulates all the remotenames state. It also contains methods to access that state in convenient ways. Remotenames are lazy loaded. Whenever client code needs to ensure the freshest copy of remotenames, use the `clearnames` method to force an eventual load. cGs||_| ¡dSr*)rÚ clearnames)rrÚargsrrr r!¼szremotenames.__init__cCs(td|jƒ|_td|jƒ|_| ¡dS)zClear all remote names staterrN)rrrÚbranchesÚ_invalidatecacher2rrr rCÀszremotenames.clearnamescCsd|_d|_d|_d|_dSr*)Ú _nodetobmarksÚ _nodetobranchÚ _hoisttonodesÚ _nodetohoistsr2rrr rFÆszremotenames._invalidatecachecCs|jSr*)rr2rrr Ú bmarktonodesÌszremotenames.bmarktonodescCsF|js@| ¡}i|_t |¡D] \}}|j |dg¡ |¡q|jS)Nr)rGrKr r;Ú setdefaultÚappend)rrKr$r#rrr Ú nodetobmarksÏs zremotenames.nodetobmarkscCs|jSr*)rEr2rrr Ú branchtonodes×szremotenames.branchtonodescCsL|jsF| ¡}i|_t |¡D]&\}}|D]}|j |g¡ |¡q*q|jSr*)rHrOr r;rLrM)rrOr$Únodesr#rrr Ú nodetobranchÚszremotenames.nodetobranchcCsZ|jsT| ¡}i|_|d7}t |¡D],\}}| |¡r&|t|ƒd…}||j|<q&|jS)Nr")rIrKr r;Ú startswithr4©rÚhoistZ marktonodesr$r#rrr Ú hoisttonodesãs  zremotenames.hoisttonodescCsh|jsb| ¡}i|_|d7}t |¡D]:\}}| |¡r&|t|ƒd…}|j |dg¡ |¡q&|jS)Nr"r)rJrKr r;rRr4rLrMrSrrr Ú nodetohoistsîs zremotenames.nodetohoistsN) r=r>r?r@r!rCrFrKrNrOrQrUrVrrrr rB´s  rBc Cs^d|jvrdS|jd}| |¡D],}| ||¡}|s8q"|d}|ddf||<q"|||||ƒS)Nóremotebookmarksró ó)ÚnamesÚ listnamesrP) ZorigÚuirZfmZbmarksÚnsr$rPr#rrr Úwrapprintbookmarksús   r^cCst tdt¡dS)Ns_printbookmarks)rZ wrapfunctionrr^)r\rrr Úextsetup sr_c sð|j dddd¡| ¡sdSt|ƒ|_tj}| dd¡r²|ddddd d „d d „d d „d }|j  |¡|  dd¡‰ˆr²|dddd‡fdd „‡fdd „‡fdd „d }|j  |¡| dd¡rì|dddddd „dd „dd „d }|j  |¡dS)Ns experimentalrTsremotenames-extrrWóremotebookmarksremote bookmark: %s cSs|j ¡ ¡Sr*)Ú _remotenamesrKr:©rrrr ÚrYzreposetup..cSs|j ¡ |g¡Sr*)rarKÚget©rr$rrr rc s ÿcSs|j ¡ |g¡Sr*)rarNrd©rr#rrr rc#s ÿ)Z templatenameZ colornameZlogfmtr[ZnamemapZnodemaprs hoistednamess hoistednameshoisted name: %s cs|j ˆ¡ ¡Sr*)rarUr:rb©rTrr rc1sÿcs|j ˆ¡ |g¡Sr*)rarUrdrergrr rc4sÿþcs|j ˆ¡ |g¡Sr*)rarVrdrfrgrr rc7sÿþróremotebranchesó remotebranchsremote branch: %s cSs|j ¡ ¡Sr*)rarOr:rbrrr rcCrYcSs|j ¡ |g¡Sr*)rarOrdrerrr rcDs ÿcSs|j ¡ |g¡Sr*)rarQrdrfrrr rcGs ÿ) r\Z setconfigÚlocalrBrar Ú namespaceZ configboolrZZ addnamespaceZconfig)r\rr]ZremotebookmarknsZ hoistednamensZremotebranchnsrrgr Ú reposetupsN  ÷     õ  ÷ rlórepoóctx)ZrequirescCst| |d¡}| |d¡}g}d|jvr<|jd || ¡¡}d|jvr`||jd || ¡¡7}tj||d|ddS)zŸrYz_revsetutil..)r ZgetargsrrZ stringmatcherZ getstringrÚalwaysÚsetr&rZr[ÚupdaterPrZRepoLookupErrorr Zbaseset) rÚsubsetÚxZrtypesrDrÚpatternZmatcherrPZrtyper]r$Zrevsrr|r Ú _revsetutil†s,ÿ     ÿr„sremotenames([name])cCst|||dƒS)zÜAll changesets which have a remotename on them. If `name` is specified, only remotenames of matching remote paths are considered. Pattern matching is supported for `name`. See :hg:`help revisions.patterns`. )rWrh©r„©rrr‚rrr Úremotenamesrevset£sr‡sremotebranches([name])cCst|||dƒS)zÞAll changesets which are branch heads on remotes. If `name` is specified, only remotenames of matching remote paths are considered. Pattern matching is supported for `name`. See :hg:`help revisions.patterns`. )rhr…r†rrr Úremotebranchesrevset­srˆsremotebookmarks([name])cCst|||dƒS)zÜAll changesets which have bookmarks on remotes. If `name` is specified, only remotenames of matching remote paths are considered. Pattern matching is supported for `name`. See :hg:`help revisions.patterns`. )rWr…r†rrr Úremotebmarksrevset·sr‰)-r@Z __future__rZmercurial.i18nrZmercurial.noderZ mercurialrrrrr r r r r rrZmercurial.utilsrZispy3Úcollections.abcÚ collectionsÚabcÚMutableMappingZmutablemappingZ testedwithZ configtableZ configitemZtemplatekeywordZrevsetpredicaterÚobjectrBr^r_rlrvrwrxr„r‡rˆr‰rrrr Ú s`   4   ýýý_F@