o ]Lb 7@sdZddlmZddlmZddlmZddlmZm Z m Z m Z m Z m Z mZmZmZmZmZddlmZe jr@ddlZejjZnddlZejZdZiZeeZeZeZed d d d ed d d d ed ddd GdddeZ Gddde!Z"ddZ#ddZ$ddZ%ed ddhdddZ&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) bookmarkserror extensions logexchange namespacespycompat registrar revsetlangsmartset templateutilutil) stringutilNsships-with-hg-core remotenames bookmarksT)defaultbranches hoistedpeersdefaultc@sleZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZeZdS)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)cachepotentialentries_kind_repoloaded)selfkindrepor3/usr/lib/python3/dist-packages/hgext/remotenames.py__init__as  zlazyremotenamedict.__init__cCsFd|_|j}t||jD]\}}}|d|}|||f|j|<q dS)z?Read the remotenames file, store entries matching selected kindT/N)rrrreadremotenamefilerr)rrnoderpathrnamenamerrr _loadhs zlazyremotenamedict._loadcCsr||jvrdS|j|\}}}|j}t|}z|j|Wn ty(YdSw|jdkr6||r6dS|gS)z;Check that the node for potentialentry exists and return itNr)rrr changelogrev LookupErrorr closesbranch)rpotentialentryr$remoter'rbinnoderrr _resolvedatars  zlazyremotenamedict._resolvedatacCs*|js|||}|dur|StN)rr(_fetchandcacheKeyErrorrkeyvalrrr __getitem__s  zlazyremotenamedict.__getitem__cC t|jSr1)iterrrrrr __iter__ zlazyremotenamedict.__iter__cCr8r1)lenrr:rrr __len__r<zlazyremotenamedict.__len__cCtr1NotImplementedErrorr:rrr __setitem__zlazyremotenamedict.__setitem__cCr?r1r@r:rrr __delitem__rCzlazyremotenamedict.__delitem__cCs8||jvr |j|S||}|dur||j|<|SdSr1)rr0r4rrr r2s    z!lazyremotenamedict._fetchandcachecCs|js||jS)z&Get a list of bookmark or branch names)rr(rkeysr:rrr rEs zlazyremotenamedict.keysccs>|js|t|jD]\}}|t|dgfVqdS)z Iterate over (name, node) tuplesrN)rr(r iteritemsrr)rkvtuprrr rFs zlazyremotenamedict.iteritemsN)__name__ __module__ __qualname____doc__r!r(r0r7r;r>rBrDr2rErFitemsrrrr rUs     rc@sXeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ 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||_|dSr1)r clearnames)rrargsrrr r!s zremotenames.__init__cCs(td|j|_td|j|_|dS)zClear all remote names staterrN)rrrbranches_invalidatecacher:rrr rOs zremotenames.clearnamescCsd|_d|_d|_d|_dSr1) _nodetobmarks _nodetobranch _hoisttonodes _nodetohoistsr:rrr rRs zremotenames._invalidatecachecC|jSr1)rr:rrr bmarktonodeszremotenames.bmarktonodescCsF|js |}i|_t|D]\}}|j|dg|q|jS)Nr)rSrXr rF setdefaultappend)rrXr'r$rrr nodetobmarkss zremotenames.nodetobmarkscCrWr1)rQr:rrr branchtonodesrYzremotenames.branchtonodescCsL|js#|}i|_t|D]\}}|D] }|j|g|qq|jSr1)rTr]r rFrZr[)rr]r'nodesr$rrr nodetobranchszremotenames.nodetobranchcCsZ|js*|}i|_|d7}t|D]\}}||r)|t|d}||j|<q|jS)Nr")rUrXr rF startswithr=rhoist marktonodesr'r$rrr hoisttonodess  zremotenames.hoisttonodescCsh|js1|}i|_|d7}t|D]\}}||r0|t|d}|j|dg|q|jS)Nr"r)rVrXr rFr`r=rZr[rarrr nodetohoistss zremotenames.nodetohoistsN) rIrJrKrLr!rOrRrXr\r]r_rdrerrrr rNs rNc Cs^d|jvrdS|jd}||D]}|||}|sq|d}|ddf||<q|||||S)Nremotebookmarksr )names listnamesr^) origuirfmbmarksnsr'r^r$rrr wrapprintbookmarkss   rpcCsttdtdS)Ns_printbookmarks)r wrapfunctionrrp)rlrrr extsetup srrc s|jdddd|sdSt||_tj}|ddrY|ddddd d d d d d d }|j || ddrY|ddddfdd fdd fdd d }|j ||ddrx|dddddd dd dd d }|j |dSdS)Ns experimentalrTsremotenames-extrrfremotebookmarksremote bookmark: %s cS|jSr1) _remotenamesrXrErrrr zreposetup..cS|j|gSr1)rurXgetrr'rrr rw  cSryr1)rur\rzrr$rrr rw#r|) templatename colornamelogfmtrjnamemapnodemaprs hoistednamess hoistednameshoisted name: %s cs|jSr1)rurdrErvrbrr rw1sc|j|gSr1)rurdrzr{rrr rw4 crr1)rurerzr}rrr rw7rrremotebranches remotebranchsremote branch: %s cSrtr1)rur]rErvrrr rwCrxcSryr1)rur]rzr{rrr rwDr|cSryr1)rur_rzr}rrr rwGr|) rl setconfiglocalrNrur namespace configboolri addnamespaceconfig)rlrroremotebookmarkns hoistednamensremotebranchnsrrr reposetupsP         rrepoctx)requirescCst||d}||d}g}d|jvr|jd||}d|jvr0||jd||7}tj||d|ddS)zs"z_revsetutil..)r getargsrr stringmatcher getstringralwayssetr)rirjupdater^rRepoLookupErrorr baseset) rsubsetxrtypesrPrpatternmatcherr^rtyperor'revsrrr _revsetutils.     rsremotenames([name])cCt|||dS)zAll 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`. )rfrrrrrrrr remotenamesrevsetrsremotebranches([name])cCr)zAll 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`. )rrrrrr remotebranchesrevsetrrsremotebookmarks([name])cCr)zAll 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`. )rfrrrrr remotebmarksrevsetrr)-rL __future__rmercurial.i18nrmercurial.noder mercurialrrrrr r r r r rrmercurial.utilsrispy3collections.abc collectionsabcMutableMappingmutablemapping testedwith configtable configitemtemplatekeywordrevsetpredicaterobjectrNrprrrrrrrrrrrrrr sb   4   _F@