^c6dZddlZddlmZddlmZddlmZm Z m Z m Z m Z m Z mZmZmZmZddlmZdZiZe jeZe jZe jZedd d edd d edd d GddejjZGddZdZdZdZedddhdZ edddhdZ!edddhdZ"dZ#edd Z$ed!d"Z%ed#d$Z&dS)%a@ 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') N)_)bin) bookmarkserror extensions logexchange namespaces registrar revsetlangsmartset templateutilutil) stringutilsships-with-hg-core remotenames bookmarksT)defaultbranches hoistedpeersdefaultcXeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d ZeZd S)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). cLi|_i|_||_||_d|_dS)NF)cachepotentialentries_kind_repoloaded)selfkindrepos 3/usr/lib/python3/dist-packages/hgext/remotenames.py__init__zlazyremotenamedict.__init__Xs* "   cd|_|j}tj||jD]\}}}|dz|z}|||f|j|<dS)z?Read the remotenames file, store entries matching selected kindT/N)rrrreadremotenamefilerr)rrnoderpathrnamenames r _loadzlazyremotenamedict._load_sk z"-"@ $*# #  > > D%4<%'D+/*=D !$ ' '  > >r"c||jvrdS|j|\}}}|j}t|} |j|n#t $rYdSwxYw|jdkr||rdS|gS)z;Check that the node for potentialentry exists and return itNr)rrr changelogrev LookupErrorr closesbranch)rpotentialentryr&remoter)rbinnodes r _resolvedatazlazyremotenamedict._resolvedatais!6664!2>Bfdzd))  N  w ' ' ' '   44  : $ $g)C)C)E)E $4ysA AAc|js|||}||StN)rr*_fetchandcacheKeyErrorrkeyvals r __getitem__zlazyremotenamedict.__getitem__zs@{  JJLLL!!#&& ?J** r"c*t|jSr5)iterrrs r __iter__zlazyremotenamedict.__iter__sD)***r"c*t|jSr5)lenrr>s r __len__zlazyremotenamedict.__len__s4()))r"ctr5NotImplementedErrorr>s r __setitem__zlazyremotenamedict.__setitem__!!r"ctr5rDr>s r __delitem__zlazyremotenamedict.__delitem__rGr"cx||jvr |j|S||}| ||j|<|SdSr5)rr3r8s r r6z!lazyremotenamedict._fetchandcachesH $*  :c? "$$ ?!DJsOJ4r"cj|js||jS)z&Get a list of bookmark or branch names)rr*rkeysr>s r rLzlazyremotenamedict.keyss.{  JJLLL$))+++r"c#K|js||jD]\}}|t |dgfV dS)z Iterate over (name, node) tuplesrN)rr*ritemsr)rkvtups r iteritemszlazyremotenamedict.iteritemssk{  JJLLL,2244 & &GAts47||n% % % % % & &r"N)__name__ __module__ __qualname____doc__r!r*r3r;r?rBrFrIr6rLrQrNr"r rrLs  >>>"+++***"""""",,, &&& EEEr"rcHeZdZdZdZdZdZdZdZdZ dZ d Z d Z d S) 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. c<||_|dSr5)r clearnames)rrargss r r!zremotenames.__init__s  r"ctd|j|_td|j|_|dS)zClear all remote names staterrN)rrrbranches_invalidatecacher>s r rZzremotenames.clearnamess@+L$*EE*; CC  r"c>d|_d|_d|_d|_dSr5) _nodetobmarks _nodetobranch _hoisttonodes _nodetohoistsr>s r r^zremotenames._invalidatecaches(!!!!r"c|jSr5)rr>s r bmarktonodeszremotenames.bmarktonodess ~r"c|jsi|}i|_|D]9\}}|j|dg|:|jS)Nr)r`rerN setdefaultappend)rrer)r&s r nodetobmarkszremotenames.nodetobmarkss! H,,..L!#D *0022 H H d"--d1gr::AA$GGGG!!r"c|jSr5)r]r>s r branchtonodeszremotenames.branchtonodess }r"c|jsh|}i|_|D]8\}}|D]0}|j|g|19|jSr5)rarkrNrgrh)rrkr)nodesr&s r nodetobranchzremotenames.nodetobranchs! I ..00M!#D ,2244 I I e!IID&11$;;BB4HHHHI!!r"c|jsp|}i|_|dz }|D];\}}||r!|t |d}||j|<<|jS)Nr$)rbrerN startswithrArhoist marktonodesr)r&s r hoisttonodeszremotenames.hoisttonodess! 4++--K!#D  TME)//11 4 4 d??5))4E -D/3D&t,!!r"cR|js|}i|_|dz }|D]e\}}||rK|t |d}|j|dg|f|jS)Nr$r)rcrerNrprArgrhrqs r nodetohoistszremotenames.nodetohoistss! L++--K!#D  TME)//11 L L d??5))LE -D&11$q'2>>EEdKKK!!r"N) rRrSrTrUr!rZr^rerirkrnrtrvrVr"r rXrXs   """ """""" " " " " " " " "r"rXcd|jvrdS|jd}||D]+}|||}|s|d}|ddf||<,|||||S)Nremotebookmarksr r")names listnamesrm) origuirfmbmarksnsr)rmr&s r wrapprintbookmarksrs++ & 'B T""))t$$  QxdC(t 4D"f % %%r"cFtjtdtdS)Ns_printbookmarks)r wrapfunctionrr)r}s r extsetuprsI'9;MNNNNNr"c `|jdddd|sdSt||_t j}|ddr||ddddd d d }|j || dd r5|ddddfdfdfd }|j ||ddr1|ddddddd }|j |dSdS)Ns experimentalrTsremotenames-extrrxremotebookmarksremote bookmark: %s cX|jSr5) _remotenamesrerLrs r zreposetup..s!4#4#A#A#C#C#H#H#J#Jr"c\|j|gSr5)rregetrr)s r rzreposetup..*t'8'E'E'G'G'K'Kb((r"c\|j|gSr5)rrirrr&s r rzreposetup..rr") templatename colornamelogfmtr{namemapnodemaprs hoistednamess hoistednameshoisted name: %s c\|jSr5)rrtrL)rrrs r rzreposetup..(s)t'8'E'E(($&&r"c`|j|gSr5)rrtr)rr)rrs r rzreposetup..+-4+<+I+I,,#dB--r"c`|j|gSr5)rrvr)rr&rrs r rzreposetup...rr"rremotebranches remotebranchsremote branch: %s cX|jSr5)rrkrLrs r rzreposetup..:s!4#4#B#B#D#D#I#I#K#Kr"c\|j|gSr5)rrkrrs r rzreposetup..;s*t'8'F'F'H'H'L'Lb((r"c\|j|gSr5)rrnrrs r rzreposetup..>rr") r} setconfiglocalrXrr namespace configboolrz addnamespaceconfig)r}rrremotebookmarkns hoistednamensremotebranchnsrrs @r reposetuprs Go~t=OPPP ::<<#D))D  B }}^\22"32 +',JJ      0111 ..99  3B,(-        M J # #M 2 2 2 }}^[110 *%*KK     /////00r"repoctx)requiresc||d}||d}g}d|jvr3|jd||}d|jvr6||jd||z }tj||d|dS)zz_revsetutil..s< 6 6! 1 6BFF1II 6 6 6 6 6 6r")r getargsrr stringmatcher getstringralwayssetr,rzr{updatermrRepoLookupErrorr baseset)rsubsetxrtypesr[rpatternmatcherrmrtyperr)revsrs @r _revsetutilr}sf  aAq)F'G'G H HD !+!9  a!,H*I*I J J" " gwww+ EEE B33 DJ  E"B T** 3 3wt}} RXXdD112222 z%# 0 1 1G ;    7 6 6 6u 6 6 6D H$T** **r"sremotenames([name])c&t|||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`. )rxrrrrrs r remotenamesrevsetrs tVQ(O P PPr"sremotebranches([name])c&t|||dS)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`. )rrrs r remotebranchesrevsetrs tVQ(< = ==r"sremotebookmarks([name])c&t|||dS)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`. )rxrrs r remotebmarksrevsetrs tVQ(= > >>r")'rUcollections.abc collectionsmercurial.i18nrmercurial.noder mercurialrrrrr r r r r rmercurial.utilsr testedwith configtable configitemtemplatekeywordrevsetpredicateabcMutableMappingrrXrrrrrrrrrrrVr"r rs4&                        '&&&&& #  !Y !+ . . +)+--+)+--        \\\\\7\\\~C"C"C"C"C"C"C"C"L & & & OOO=0=0=0@7F*;<<<=<"#w.?@@@A@$"gv->???@?$+++:'((QQ)(Q*++>>,+>+,,??-,???r"