not ui object passed to extsetup()
TK Soh
teekaysoh at gmail.com
Wed Aug 12 02:07:52 UTC 2009
On Tue, Aug 11, 2009 at 11:03 AM, Martin Geisler<mg at lazybytes.net> wrote:
> TK Soh <teekaysoh at gmail.com> writes:
>
>> I noticed that unlike the uisetup() callback, extsetup() doesn't have
>> a ui object passed into it, forcing extensions like color have to
>> 'capture' the ui via uisetup() and use it later in extsetup(). Can
>> anyone share some background on this, please? Thanks.
>
> The extsetup callback was introduced in 863e237b58fb, which came from
> this thread:
>
> http://markmail.org/message/pr6bwayg6pmy7q6x
>
> There are no comments in the thread -- I guess nobody thought of passing
> ui when calling extsetup.
Intriguing ;-)
> This part of Mercurial could benefit from a major overhaul to make it
> more regular. Dividing the initialization into well-defined phases would
> be a good start. Today, a hgrc file with
>
> [extensions]
> foo =
> bar =
>
> will be loaded with a call tree like this:
>
> dispatch._dispatch
>
> extensions.loadall
> extensions.load
> # add foo module to extensions._extensions
> foo.uisetup(ui)
> extensions.load
> # add bar module to extensions._extensions
> bar.uisetup(ui)
>
> foo.extsetup()
> commands.table.update(foo.cmdtable)
> bar.extsetup()
> commands.table.update(bar.cmdtable)
>
> foo.reposetup(ui, repo)
> bar.reposetup(ui, repo)
>
> A problem with the above call tree is that extensions are initialized
> while being loaded, instead of doing it in phases:
>
> dispatch._dispatch
>
> extensions.loadall
> # add foo module to extensions._extensions
> # add bar module to extensions._extensions
>
> extensions.uisetupall
> bar.uisetup(ui)
> foo.uisetup(ui)
>
> foo.extsetup()
> bar.extsetup()
should it be
foo.extsetup(ui)
bar.extsetup(ui)
?
> commands.table.update(foo.cmdtable)
> commands.table.update(bar.cmdtable)
>
> foo.reposetup(ui, repo)
> bar.reposetup(ui, repo)
Would it better to do commands.table.update() after all callbacks are
done? It might help to simplify the thought process. Not sure if
there's any special need for reposetup() to be called after though.
> If things were grouped like this, an extension like color could do
>
> mq = extensions.find('mq')
> record = extensions.find('record')
> if mq and record:
> # add color to qrecord
>
> in extsetup without having to think about the load order, and knowing
> that the updated qrecord cmdtable entry will be copied correctly into
> commands.table.
>
> I don't know if this covers all the corner cases -- probably not :-)
>
> But I think introducing a new set of callbacks and deprecating the old
> ones could help streamline this API.
Sounds good.
More information about the Mercurial-devel
mailing list