Ë ßpPnj1)}ãó<—ddlmZmZmZmZddlmZGd„d«Zy)é)ÚcommandsÚerrorÚ extensionsÚ registraré)ÚtracingcóZ—eZdZdZd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z dd „Zd„Zy )Ú exthelperaM Helper for modular extension setup A single helper should be instantiated for each module of an extension, where a command or function needs to be wrapped, or a command, extension hook, fileset, revset or template needs to be registered. Helper methods are then used as decorators for these various purposes. If an extension spans multiple modules, all helper instances should be merged in the main module. All decorators return the original function and may be chained. Aside from the helper functions with examples below, several registrar method aliases are available for adding commands, configitems, filesets, revsets, and templates. Simply decorate the appropriate methods, and assign the corresponding exthelper variable to a module level variable of the extension. The extension loading mechanism will handle the rest. example:: # ext.py eh = exthelper.exthelper() # As needed (failure to do this will mean your registration will not # happen): cmdtable = eh.cmdtable configtable = eh.configtable filesetpredicate = eh.filesetpredicate revsetpredicate = eh.revsetpredicate templatekeyword = eh.templatekeyword # As needed (failure to do this will mean your eh.wrap*-decorated # functions will not wrap, and/or your eh.*setup-decorated functions # will not execute): uisetup = eh.finaluisetup extsetup = eh.finalextsetup reposetup = eh.finalreposetup uipopulate = eh.finaluipopulate @eh.command(b'mynewcommand', [(b'r', b'rev', [], _(b'operate on these revisions'))], _(b'-r REV...'), helpcategory=command.CATEGORY_XXX) def newcommand(ui, repo, *revs, **opts): # implementation goes here eh.configitem(b'experimental', b'foo', default=False, ) @eh.filesetpredicate(b'lfs()') def filesetbabar(mctx, x): return mctx.predicate(...) @eh.revsetpredicate(b'hidden') def revsetbabar(repo, subset, x): args = revset.getargs(x, 0, 0, b'babar accept no argument') return [r for r in subset if b'babar' in repo[r].description()] @eh.templatekeyword(b'babar') def kwbabar(ctx): return b'babar' có¨—g|_g|_g|_g|_g|_g|_g|_i|_tj|j«|_ i|_ tj|j«|_ tj«|_ tj«|_ tj«|_y©N)Ú_uipopulatecallablesÚ _uicallablesÚ _extcallablesÚ_repocallablesÚ_commandwrappersÚ_extcommandwrappersÚ_functionwrappersÚcmdtablerÚcommandÚ configtableÚ configitemÚfilesetpredicateÚrevsetpredicateÚtemplatekeyword)Úselfs ú7usr/lib/python3.12/site-packages/mercurial/exthelper.pyÚ__init__zexthelper.__init__Xsª€Ø$&ˆÔ!ØˆÔØˆÔØ ˆÔØ "ˆÔØ#%ˆÔ Ø!#ˆÔ؈Œ Ü ×(Ñ(¨¯©Ó7ˆŒ ؈ÔÜ#×.Ñ.¨t×/?Ñ/?Ó@ˆŒÜ )× :Ñ :Ó <ˆÔÜ(×8Ñ8Ó:ˆÔÜ(×8Ñ8Ó:ˆÕócóî—|jj|j«|jj|j«|jj|j«|jj|j«|j j |j «|jj |j«|jj |j«|jj|j«|jj|j«|jj|j«|jj|j«|jj«D]A\}}||jvr|j|j|«Œ3||j|<ŒCyr )rÚextendr rrrÚ_mergerrrrrrÚupdaterÚitems)rÚotherÚsectionr#s rÚmergezexthelper.mergehsp€Ø ×Ñ× Ñ  ×!3Ñ!3Ô4Ø ×!Ñ!×(Ñ(¨×)CÑ)CÔDØ ×Ñ×!Ñ! %×"5Ñ"5Ô6Ø ×Ñ×"Ñ" 5×#7Ñ#7Ô8Ø ×Ñ×$Ñ$ U×%;Ñ%;Ô<Ø ×Ñ×#Ñ# E×$9Ñ$9Ô:Ø ×Ñ×#Ñ# E×$9Ñ$9Ô:Ø ×Ñ×$Ñ$ U×%;Ñ%;Ô<Ø × Ñ ×'Ñ'¨×(AÑ(AÔBØ ×Ñ×%Ñ% e×&=Ñ&=Ô>Ø � ‰ ×јUŸ^™^Ô,Ø#×/Ñ/×5Ñ5Ö7‰NˆG�Uؘ$×*Ñ*Ñ*Ø× Ñ  Ñ)×0Ñ0°Õ7à,1�× Ñ  Ò)ñ 8rcó¦—|jD]I\}}}tjtj||«}|sŒ/|D]}|dj |«ŒŒK|j D]\}}}tj|||«Œ|jD]2} tjdt| ««5| |«ddd«Œ4y#1swYŒ?xYw)aDMethod to be used as the extension uisetup The following operations belong here: - Changes to ui.__class__ . The ui object that will be used to run the command has not yet been created. Changes made here will affect ui objects created after this, and in particular the ui that will be passed to runcommand - Command wraps (extensions.wrapcommand) - Changes that need to be visible to other extensions: because initialization occurs in phases (all extensions run uisetup, then all run extsetup), a change made here will be visible to other extensions during extsetup - Monkeypatch or wrap function (extensions.wrapfunction) of dispatch module members - Setup of pre-* and post-* hooks - pushkey setup rzfinaluisetup: %sN) rrÚ wrapcommandrÚtableÚappendrÚ wrapfunctionrrÚlogÚrepr) rÚuirÚwrapperÚoptsÚentryÚoptÚcontÚfuncnameÚcs rÚ finaluisetupzexthelper.finaluisetupzs´€ð&'+×&;Ô&;Ñ "ˆG�W˜dÜ×*Ñ*¬8¯>©>¸7ÀGÓLˆEÚÛ�Cؘ!‘H—O‘O CÕ(ñ ð'<ð (,×'=Ô'=Ñ #ˆD�(˜GÜ × #Ñ # D¨(°GÕ <ð(>à×"Ô"ˆAÜ—‘Ð/´°a³Õ9Ù�"”÷:Ð9ñ#ß9Ð9ús Â3 CÃC có6—|jD] }||«Œ y)zëMethod to be used as the extension uipopulate This is called once per ui instance to: - Set up additional ui members - Update configuration by ``ui.setconfig()`` - Extend the class dynamically N)r )rr.r5s rÚfinaluipopulatezexthelper.finaluipopulate˜s€ð×*Ô*ˆAÙ ˆb�Eñ+rcó®—i}|jD]h\}}}}||vr% tj|«}|j||<tj ||||«}|sŒN|D]} |dj | «ŒŒj|jD]2} tjdt| ««5| |«ddd«Œ4y#t$rYŒ¸wxYw#1swYŒNxYw)z÷Method to be used as the extension extsetup The following operations belong here: - Changes depending on the status of other extensions. (if extensions.find(b'mq')) - Add a global option to all commands rzfinalextsetup: %sN) rrÚfindÚKeyErrorrr(r*rrr,r-) rr.Ú knownextsÚextrr/r0Úer1r2r5s rÚ finalextsetupzexthelper.finalextsetup¤sÕ€ðˆ à+/×+CÔ+CÑ 'ˆC�˜' 4ؘ)Ñ#ðÜ"Ÿ™¨Ó,�Að "#§¡� ˜#‘Ü×*Ñ*¨9°S©>¸7ÀGÓLˆEÚÛ�Cؘ!‘H—O‘O CÕ(ñ ð,Dð×#Ô#ˆAÜ—‘Ð0´$°q³'Õ:Ù�"”÷;Ð:ñ$øô òñðú÷;Ð:úsœB<Â( C Â< CÃCà C có —|jD]3}tjdt|««5|||«ddd«Œ5y#1swYŒ@xYw)zôMethod to be used as the extension reposetup The following operations belong here: - All hooks but pre-* and post-* - Modify configuration variables - Changes to repo.__class__, repo.dirstate.__class__ zfinalreposetup: %sN)rrr,r-)rr.Úrepor5s rÚfinalreposetupzexthelper.finalreposetupÁs?€ð×$Ô$ˆAÜ—‘Ð1´4¸³7Õ;Ù�"�d” ÷<Ð;ñ%ß;Ð;ús ¯ AÁA có<—|jj|«|S)a%Decorated function will be executed during uisetup example:: # Required, otherwise your uisetup function(s) will not execute. uisetup = eh.finaluisetup @eh.uisetup def setupbabar(ui): print('this is uisetup!') )rr*©rÚcalls rÚuisetupzexthelper.uisetupÎs€ð ×Ñ× Ñ  Ô&؈ rcó<—|jj|«|S)a5Decorated function will be executed during uipopulate example:: # Required, otherwise your uipopulate function(s) will not execute. uipopulate = eh.finaluipopulate @eh.uipopulate def setupfoo(ui): print('this is uipopulate!') )r r*rDs rÚ uipopulatezexthelper.uipopulateÝs€ð ×!Ñ!×(Ñ(¨Ô.؈ rcó<—|jj|«|S)a/Decorated function will be executed during extsetup example:: # Required, otherwise your extsetup function(s) will not execute. extsetup = eh.finalextsetup @eh.extsetup def setupcelestine(ui): print('this is extsetup!') )rr*rDs rÚextsetupzexthelper.extsetupìs€ð ×Ñ×!Ñ! $Ô'؈ rcó<—|jj|«|S)a8Decorated function will be executed during reposetup example:: # Required, otherwise your reposetup function(s) will not execute. reposetup = eh.finalreposetup @eh.reposetup def setupzephir(ui, repo): print('this is reposetup!') )rr*rDs rÚ reposetupzexthelper.reposetupûs€ð ×Ñ×"Ñ" 4Ô(؈ rNcóȇ‡‡‡—‰€gŠnP‰D]K}t|t«stjd«‚t |«dvsŒ6d}tj|«‚ˆˆˆˆfd„}|S)aVDecorated function is a command wrapper The name of the command must be given as the decorator argument. The wrapping is installed during `uisetup`. If the second option `extension` argument is provided, the wrapping will be applied in the extension commandtable. This argument must be a string that will be searched using `extension.find` if not found and Abort error is raised. If the wrapping applies to an extension, it is installed during `extsetup`. example:: # Required if `extension` is not provided uisetup = eh.finaluisetup # Required if `extension` is provided extsetup = eh.finalextsetup @eh.wrapcommand(b'summary') def wrapsummary(orig, ui, repo, *args, **kwargs): ui.note(b'Barry!') return orig(ui, repo, *args, **kwargs) The `opts` argument allows specifying a list of tuples for additional arguments for the command. See ``mercurial.fancyopts.fancyopts()`` for the format of the tuple. sopts must be list of tuples)éés)each opt tuple must contain 4 or 5 valuescóŠ•—‰€ ‰jj‰|‰f«|S‰jj‰‰|‰f«|Sr )rr*r)r/rÚ extensionr0rs €€€€rÚdecz"exthelper.wrapcommand..dec1sTø€ØÐ Ø×%Ñ%×,Ñ,¨g°wÀÐ-EÔFð ˆNð×(Ñ(×/Ñ/Ø ¨°$Ð7ôðˆNr)Ú isinstanceÚtuplerÚProgrammingErrorÚlen)rrrQr0r2ÚmsgrRs```` rr(zexthelper.wrapcommand scû€ð: ˆ<؉Dã�Ü! #¤uÔ-Ü×0Ñ0Ð1OÓPÐPÜ�s“8 6Ò)ØF�CÜ×0Ñ0°Ó5Ð5ð ÷ ðˆ rc󇇇—ˆˆˆfd„}|S)aLDecorated function is a function wrapper This function takes two arguments, the container and the name of the function to wrap. The wrapping is performed during `uisetup`. (there is no extension support) example:: # Required, otherwise the function will not be wrapped uisetup = eh.finaluisetup @eh.wrapfunction(discovery, b'checkheads') def wrapcheckheads(orig, *args, **kwargs): ui.note(b'His head smashed in and his heart cut out') return orig(*args, **kwargs) cóD•—‰jj‰‰|f«|Sr )rr*)r/Ú containerr4rs €€€rrRz#exthelper.wrapfunction..decNs#ø€Ø × "Ñ "× )Ñ )¨9°hÀÐ*HÔ I؈Nr©)rrZr4rRs``` rr+zexthelper.wrapfunction<sú€ö$ ðˆ r)NN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rr&r6r8r?rBrFrHrJrLr(r+r[rrr r sE„ñ>ò@;ò 2ò$ò< òò: ò ò ò ò ó0ódrr N)ÚrrrrÚhgdemandimportrr r[rrÚrbs ð÷óõ#÷{ò{r