^c|ddlZddlZddlZddlZddlZddlZddlmZmZddl m Z m Z m Z ddl mZmZmZm Z mZddlmZiZiZiZgZhdZd1dZd Zd Zd Zd2d Zd ZdZdZ dZ!dZ"d1dZ#dZ$dZ%d1dZ&dZ'dZ(dZ)dZ*dZ+d2dZ,dZ-GddZ.dZ/d1d Z0d!Z1d"Z2d#Z3d$Z4d%Z5d&Z6d'Z7d(Z8d)Z9d3d+Z:d4d-Z;d.ZdS)5N)_gettext)getattropensetattr)cmdutil configitemserrorpycompatutil) stringutil> colorhgciashelvehbisectinotifyinterhgprogress bookmarks parentrevspecc#vKrfd}nd}tD]"}t|}|r||r||fV#dS)NcxdD]5}d||z}||dsdS6dS)N)s%shgext.%s extensions!T)config startswith)nameformatconfuis 6/usr/lib/python3/dist-packages/mercurial/extensions.pyenabledzextensions..enabled8sR.  yy >>#DOOD,A,A#44  cdS)NT)rs r#zextensions..?str%)_order _extensions)r"r$rmodules` r# extensionsr,5s $      $#T"  ggdmm ,   r%cd} t|}nc#t$rVtD]9\}}|d|zs|d|zr|}n:YnwxYw|st||S)z'return module with given extension nameN./)r*KeyErroritemsendswith)rmodkvs r#findr6Fs C$ %%''  DAqzz$+&& !**TD[*A*A   tnn Js AA21A2c|dd}tjtj|}t j|}t j|}t j|rSt j |\}}tj ||g\}}}tj ||||S tj ||S#t$r}|js||_d}~wwxYw)Nr._)replacer normpath expandpathr fsdecodeospathisdirsplitimp find_module load_module load_sourceIOErrorfilename)r> module_namedffdfpathdescexcs r#loadpathrNUs%%dD11K =.. / /D#K00K  T " "D w}}Tw}}T""1/!aS11E4 UD    ?;55 5   < $#  sC-- D 7DD cttj|}|d}|ddD]}t ||}|S)z#import and return the moduler.rN) __import__r sysstrr@r)rr3 componentscomps r#_importhrTlsW X_T** + +CD!!J122!!c4   Jr%cJ|rt|d|z}n td|z}nx#t$rk}|r||d|zd|z td|z}n8#t$r+}|r||d|z|t|}Yd}~nd}~wwxYwYd}~nd}~wwxYw|S)Nrs hgext3rd.%s)rNrT ImportError)rr> reportfuncr3errs r# _importextrYus %t[4/00 %;-..CC % % % K 3 d 2NT4IJJJ %~455 % % %AJsNT$94@@@tnn %  % Js>+ B B AB B(!B BBBB c|dd|tj|||jr,|ddr|dSdSdS)N extensions* - could not import %s (%s): trying %s sdevelsdebug.extensions)logr forcebytestr debugflag configbool traceback)r"rXfailednexts r#_reportimporterrorrcs{FF6$$  | h0CDD r%ct|tttfr|D]}t ||dSt|t rS|D]<\}}t ||t d|tj|fz|=dSt|tdrtj d||fzddS)Ns%s.%ssunicode %r found in %ssuse b'' to make it byte stringhint) isinstancelistsettuple_rejectunicodedictr1rr]typer ProgrammingError)rxsxr4r5s r#rlrls"tS%())   $ $A 4 # # # # $ $ B   HHJJ M MDAq 4 # # # 8tZ-DQ-G-G&HH! L L L L M M BS " " $ %T 22      r%)snorepos optionalrepos inferrepoc|D]Q\}}|dfdtD}|s#tjdd|zd|zdS)z4Check if extension commands have required attributesrc>g|]}tj||Sr')r safehasattr).0arIs r# z%_validatecmdtable..s+JJJ43CAq3I3IJ1JJJr%smissing attributes: %ss, s'use @command decorator to register '%s'rfN)r1 _cmdfuncattrsr rojoin)r"cmdtablecemissingrIs @r#_validatecmdtabler~s    1 aDJJJJmJJJ  $ % 7(;(; ;;a?      r%c dD]!}t|t||i"dD]*}t||d}|rt||j+t|t|didS)z=Sanity check for loadable tables provided by extension module)cmdtable colortable configtable)filesetpredicate internalmergerevsetpredicatetemplatefilter templatefunctemplatekeywordNrz)rlr_tabler~)r"r3tos r#_validatetablesrs 9//q'#q"--.... ( ( CD ! !  ( 1ah ' ' 'b'#z26677777r%c |ds|dr |dd}n|}|tvrdS|tvr t|S|dd|dt|<t jd|5}t ||tt|}dddn #1swxYwY|dd|||||xx|j z cc<t|dd}|rt j d }t j tj |d } d| vr| d pd | d pd f} d|vs| |kr=td } || ||t jfzdS|dd|t#|||t|<t$||dd|t jd|5}t(|gD]} | d dddn #1swxYwY|dd||S)Nshgext.shgext/r[s - loading extension: %s zload extension %ss > %s extension loaded in %s minimumhgversion)nrrs^(third party extension %s requires version %s or newer of Mercurial (current: %s); disabling) s& - validating extension tables: %s s( - invoking registered callbacks: %s zcallbacks extension %sTloadeds > callbacks completed in %s )r_builtinr*r\r timedcmrYbindrcelapsedr versiontuplerr]rwarnversionrr)append_aftercallbacksget) r"rr> loadingtime shortnamestatsr3minvercurverextminmsgfns r#loadrs, y!!T__Y%?%?H  HtK9%%FF<7CCC!K  )9 5 5CtT*>Qin1fQin15F 6>>Vf__<C GGC9fdlnn== > > > FFF<CYOOOB K  MM)FFBI . : :e!%%i44  B BdOOOOO FF<=uEEE Js$%CCC+IIIc.tt|dd}|rv ||ni#t$r\}|dt j|}|td||fzYd}~dSd}~wwxYwdS)NuisetupTforce&*** failed to set up extension %s: %s Frr* Exceptionr`rr]rr)rr"rinstrs r# _runuisetuprsk$'D99G  GBKKKK    LLtL $ $ $)$//C GGA@AAT3KO P P P55555   4 , BAB  Bc.tt|dd}|rv ||ni#t$r\}|dt j|}|td||fzYd}~dSd}~wwxYwdS)NextsetupTrrFr)rr"rrrs r# _runextsetupr s{4(*d;;H  HRLLLL    LLtL $ $ $)$//C GGA@AAT3KO P P P55555   4rc tjt}|d}fd|D}d|D}t t }|dd|rdnd|ddt |tjd 5}| dd d }|D]\}}|rA|d d d kr3|tvr|dd||d dt|<I t||||]#t$r} tj| } |rtd} | ||| fz} ntd} | || fz} |} | d|d } | | tj| ddrQd}t)| t*jr| jr| j}|td}t+j| ||d| zt)| t*jr1| jr*|td| jz|Yd} ~ d} ~ wwxYw dddn #1swxYwY|ddt t |z |dtdfg}|ddt7|||t9}|ddtjd5}t |dD]}|dd|tjd|5}t;||s,|dd|||dddn #1swxYwY|dd ||||xx|jz cc< dddn #1swxYwY|dd!||dd"tjd#5}t |dD]}||vr|dd$|tjd%|5}tA||s,|dd&|||dddn #1swxYwY|dd'||||xx|jz cc< dddn #1swxYwY|dd(||D]#}|dd)|dtB|<$|dd*tjd+5}tDD]?}|tBvr tD|D]%}|dd,||d-.&@ dddn #1swxYwY|dd/|tD#d d0l$m%}m&}m'}m(}m)}m*}m+}m,}|dd1d2|d3fd4|d5fd6|d7fd8|d9fd:|d7fd;|dfd?|d@fg}tjdA5}t7|||dddn #1swxYwY|ddB|t[|D]2}|ddC|tj.||3|ddDdS)ENrc&g|] \}}|v ||fSr'r')rur4r5 whitelists r#rwzloadall..s&@@@Vai1a&r%c$g|] \}}d|v ||fS):r')rur4r5s r#rwzloadall..s% ; ; ;!QT]]q!f]]]r%r[sloading %sextensions s additional r%s- processing %d entries zload all extensions*rrrs$ - skipping disabled extension: %s s+failed to import extension "%s" from %s: %ss#failed to import extension "%s": %ssrequiredsnosSloading of this extension was required, see `hg help config.extensions` for detailsrfs*** %s s *** (%s) s&> loaded %d extensions, total time %s rsloadconfigtables!- loading configtable attributes s- executing uisetup hooks z all uisetups - running uisetup for %s z uisetup %ss& - the %s extension uisetup failed s > uisetup for %s took %s s> all uisetup took %s s- executing extsetup hooks z all extsetups - running extsetup for %s z extsetup %ss' - the %s extension extsetup failed s > extsetup for %s took %s s> all extsetup took %s s$ - disabling broken %s extension s%- executing remaining aftercallbacks aftercallbackss. - extension %s not loaded, notify callbacks Frs+> remaining aftercallbacks completed in %s )colorcommands filemergefilesetrevsettemplatefilters templatefuncs templatekws)- loading extension registration objects rs loadcmdtablersloadcolortablers loadpredicatersloadinternalmergerrs loadfilterrs loadfunctionrs loadkeywordzload registration objectss0> extension registration object loading took %s s*> extension %s take a total of %s to load sextension loading complete )/ collections defaultdictintr lenr)r\r rconfigsuboptions_disabledextensionsrrrr]rcopyupdate parseboolrrhr HintrgAbortrr` _loadextrarjraddrrr*rclearrerrrrrrrrsorted timecount)r"rrresultnewindexrdefault_sub_optionsrr>rr error_msgoptions ext_optionsrgearlyextraloadersbrokenalluisetupstatsallextetupstatsrrrrrrrrrr extraloaderss ` r#loadallrsP )#..K ^^M * *F@@@@v@@@ ; ;6 ; ; ;F6{{HFF!"+ FF<5s6{{CCC + , ,,# 11-FFqI") #) #LT4 !9$$#666(D  15QRR'- #Rt[1111 # # # -d33- !F!!I$c!22II !"H I II$,I-2244 11-FFqI {+++' K(G(GHH#D!$ 33) )#y| K   +id;;;;GG[I5666!$ 33> >- 0 049 <===LLNNNNNNNN9 #) #,#,#,#,#,#,#,#,#,#,#,#,#,#,#,#\FF2 F h  &89FF<>???r8./// UUFFF<7888 m $ $ /899% / /D FF:E9J93K9J>>KKK0>P=.=O7+ P=7O; ;P=>O; ?1P==QQ AU =T UT UT 1UU"U AX""X&)X&=[["[ct|dD]I}t|}|s|D]4\}}}t||d}|t|||||5JdSN)r)r*r) r"rrrr+objname loadermod loadernameextraobjs r#rrsxyy!CCT"  .: C C *GY vw55H#. :..r4BBB C CCr%c|tvrt|du}||dSt|g|dS)aRun the specified function after a named extension is loaded. If the named extension is already loaded, the callback will be called immediately. If the named extension never loads, the callback will be called after all extensions have been loaded. The callback receives the named argument ``loaded``, which is a boolean indicating whether the dependent extension actually loaded. Nr)r*r setdefaultr) extensioncallbackrs r# afterloadedrsaKY't3""9b1188BBBBBr%c <t|D]\}}t|dd}|s ||&#t$rY}|d|t d|t j|fzYd}~d}~wwxYwdS)aMRun extension hooks on the given ui to populate additional members, extend the class dynamically, etc. This will be called after the configuration is loaded, and/or extensions are loaded. In general, it's once per ui instance, but in command-server and hgweb, this may be called more than once with the same ui. uipopulateNTrs.*** failed to populate ui by extension %s: %s )r,rrr`rrrr])r"rr3hookrs r# populateuirs ^^   csL$//    DHHHH    LLtL $ $ $ GGDEE06678           s 6 BABBc8tsJfd}|S)zPartial function application Returns a new function that is the partial application of args and kwargs to func. For example, f(1, 2, bar=3) === bind(f, 1)(2, bar=3)c|zi|Srr')rvkwargsfuncs r#closurezbind..closurestdQh&2&&&r%)callable)rrrs`` r#rr s= D>>'''''' Nr%c |j|_n#t$rYnwxYwt|d|_t|d|_|jt|di||_||_dS)z.Copy and add some useful attributes to wrapper __module____doc____dict__N) __name__AttributeErrorrrrrr _origfunc_unboundwrapper)wraporigfnunboundwrappers r#_updatewrapperrs       fl33DO69--DLMR88999DN)Ds  ct|sJtj||\}}|D] \}}||ur|} n|d} t jt j|t j| } t| | ||| xj |z c_ t|} | | d<|| dxx|z cc<t| || <|S)a.Wrap the command named `command' in table Replace command in the command table with wrapper. The wrapped command will be inserted into the command table specified by the table argument. The wrapper will be called like wrapper(orig, *args, **kwargs) where orig is the original (wrapped) function, and *args, **kwargs are the arguments passed to it. Optionally append to the command synopsis and docstring, used for help. For example, if your extension wraps the ``bookmarks`` command to add the flags ``--remote`` and ``--all`` you might call this function like so: synopsis = ' [-a] [--remote]' docstring = """ The ``remotenames`` extension adds the ``--remote`` and ``--all`` (``-a``) flags to the bookmarks command. Either flag will show the remote bookmarks known to the repository; ``--remote`` will also suppress the output of the local bookmarks. """ extensions.wrapcommand(commands.table, 'bookmarks', exbookmarks, synopsis, docstring) rNr) rr findcmdr1 functoolspartialr checksignaturerrrirk) tablecommandwrappersynopsis docstringaliasesentryaliasr|keyrrnewentrys r# wrapcommandr&s: G  _We44NGUKKMMq ::C E 1XF   G$$d&9&&A&A  D4))) ! E{{HHQK x xE#J Lr%c2tj|}tsJ|jD]H}||jvr=|j|jtsJfd}||j|_nI|t urtd|d|ddS)z[Wraps a filecache property. These can't be wrapped using the normal wrapfunction. cg|Ri|Srr')rkwargsrrs r#rzwrapfilecache..wrapfs#wv7777777r%ztype 'z' has no property ''N)r rQr__mro__rrobjectr)clspropnamercurrclsrrs ` @r# wrapfilecacherZs x((H G  ;   w' ' '%h/4FF## # # # 8 8 8 8 8 8/3G X & + E (&nhhhOPPPr%c$eZdZdZdZdZdZdS)wrappedfunctionz3context manager for temporarily wrapping a functioncRt|sJ||_||_||_dSr)r _container _funcname_wrapper)self containerfuncnamers r#__init__zwrappedfunction.__init__ss/     #! r%cFt|j|j|jdSr) wrapfunctionrrr )r!s r# __enter__zwrappedfunction.__enter__ys T_dndmDDDDDr%cFt|j|j|jdSr)unwrapfunctionrrr )r!exctypeexcvaluer`s r#__exit__zwrappedfunction.__exit__|s t FFFFFr%N)rr __qualname__rr$r'r,r'r%r#rrpsO==   EEEGGGGGr%rc"t|sJt||}t|sJtj|rt j||}nt ||}t|||t||||S)aWrap the function named funcname in container Replace the funcname member in the given container with the specified wrapper. The container is typically a module, class, or instance. The wrapper will be called like wrapper(orig, *args, **kwargs) where orig is the original (wrapped) function, and *args, **kwargs are the arguments passed to it. Wrapping methods of the repository object is not recommended since it conflicts with extensions that extend the repository by subclassing. All extensions that need to extend methods of localrepository should use this subclassing trick: namely, reposetup() should look like def reposetup(ui, repo): class myrepo(repo.__class__): def whatever(self, *args, **kwargs): [...extension stuff...] super(myrepo, self).whatever(*args, **kwargs) [...extension stuff...] repo.__class__ = myrepo In general, combining wrapfunction() with subclassing does not work. Since you cannot control what other extensions are loaded by your end users, you should play nicely with others by using the subclass trick. ) rrinspectismodulerrrrr)r"r#rrrs r#r&r&sB G   Y ) )F F   ""% &11GV$$4))) Ix&&& Mr%ct||}|}||d}||t|||t |D]}t ||||S)a/undo wrapfunction If wrappers is None, undo the last wrap. Otherwise removes the wrapper from the chain of wrappers. Return the removed wrapper. Raise IndexError if wrapper is None and nothing to unwrap; ValueError if wrapper is not None but is not found in the wrapper chain. Nr)getwrapperchainpopremoverreversedr&)r"r#rchainrws r#r)r)s Ix 0 0E YY[[F( LL Ix((( e__--Y!,,,, Nr%cg}t||}|rHt|sJ|t|d|t|dd}|H|S)zget a chain of wrappers of a function Return a list of functions: [newest wrapper, ..., oldest wrapper, origfunc] The wrapper functions are the ones passed to wrapfunction, whose first argument is origfunc. rrN)rrr)r"r#rrs r#r2r2ssF H % %B ,|| gb"3R88999 Rd + + , Mr%cddl}i}tj|dr!tjtjtj|j } tj |}|D]}| dr=| ddd}tj ||}nC|}tj ||d}tj|s||vs|tvs|dkr|||<n#t $rYnwxYwt"D] \}}|r|||< |S) zAfind paths of disabled extensions. returns a dict of {name: path}rN__file__s.pyr.rs __init__.pys__init__)hgextr rtr=r>dirnameabspathr fsencoder:listdirr2rsplitryexistsr)OSErrorrr1)r;extsextpathfilesr|rr>s r#_disabledpathsrFs}LLL D z**"'// L*5>:: ; ;   "Jw''E " "::f%%!88D!,,Q/D7<<33DDD7<<NCCD7>>$//! 4<<46>>T[5H5H!T  "    D  *//11 d  DJ Ks&D.. D;:D;cjg}|}|dddks|s9|}|sn"|dddk%|9|dd}|dks|dkr|dd}|r||r3||d}|r||n/|sdS|||}|ndSd|S) zreturn the top-level python documentation for the given file Loosely inspired by pydoc.source_synopsis(), but rewritten to handle triple quotes and to return the whole text instead of just the synopsisNr#s"""s'''rr%)readlinestriprstripr2r@rry)filerlinestarts r# _moduledocrPsF F ==??D rr(d  $**,, }}   rr(d  $**,,  !HE %6//ABBx #{{}}%%e,, zz%((+(MM$''' t MM$   ==??D #t 88F  r%c t|d5}t|}dddn #1swxYwYn#t$rYdSwxYw|rt|St dS)zBretrieve help synopsis of a disabled extension (without importing)rbN(no help text available))rrPrErr)r>srcdocs r# _disabledhelprVs $   "#S//C " " " " " " " " " " " " " " "  .s||,---s':. :2:2: AAc@ ddlm}d|jDS#tt f$rYnwxYwt }|siSi}|D]3\}}t|}|r|dkrtj |||<4|S)zCfind disabled extensions from hgext. returns a dict of {name: desc}r __index__cFi|]\}}|tv|t|Sr')r)r)rurrLs r# zdisabled..2s9   d6!! '$--!!!r%s __index__) r;rYdocsr1rVrrFrVr firstline)rYpathsrCrr>rUs r#disabledr_-s  ######  'n2244     (        E  Dkkmm33 dD!!  34<''#-c22DJ Ks (+??c(t}||vrt||S ddl}ddlm}t j|drdS|t vrdSt|j |S#ttf$rYdSwxYw)zrTrootrzrmrvrs r#_disabledcmdtablerxps dE  +cyT**+++++++++++++++HT"" ) )y   IaL a ! ! $QS))DD 39 % % 3DD C Os(AA  A cB t|}n#ttf$rYdSwxYw tj|||\}}n"#t jt jf$rYdSwxYw|D]}||r|}n |d}t|} ||| fS)Nr) rxrE SyntaxErrorr rr AmbiguousCommandUnknownCommandrrV) r"cmdrr>strictrzr r r{rUs r#_finddisabledcmdrs$T** [ ! h??  "E$8 9  <<   C E aj   C s s''AA$#A$Fc>t}|stj|d}||d}|rt |||||}|s2|D]\}}t |||||}|rn|r|Stj|)zXfind cmd from disabled extensions without importing. returns (cmdname, extname, doc)N)r~)rFr r|r3rr1)r"r}r~r^extr>rs r# disabledcmdrs   E ("3''' C 99S$  D Br3T&AAA ++--  JD$"2sD$vFFFC     s # ##r%Tc i}tD]r\}}t|jptd}|J|r|dd}t j|||<s|S)z+return a dict of {name: desc} of extensionsrSNr.)r,rrrr@rr]rK)rrCenamerrUs r#r$r$s D ll88 sck""Da(C&D&D  *KK%%b)E *3//5577U Kr%cHdtDS)z4return short names of extensions that failed to loadcg|] \}}|| Srr')rurr3s r#rwznotloaded..s E E EYT3Dr%)r*r1r'r%r# notloadedrs" E E+"3"3"5"5 E E EEr%ctj|drK|]}tj|VdSr)r bytestr)rurs r# z moduleversion..s-AAAH,Q//AAAAAAr%) r rtr getversionr __version__rhrirkryrr])r+rs r# moduleversionrs  .. 8Frs         "   .*       ;     888$0000f      y:y:y:y:x C C CCCC*,    * * *1111hQQQ, G G G G G G G G ///d*"###LB . . .4.$,&$$$$2    FFF *22222r%