not ui object passed to extsetup()
Martin Geisler
mg at lazybytes.net
Tue Aug 11 06:03:07 CDT 2009
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.
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()
commands.table.update(foo.cmdtable)
commands.table.update(bar.cmdtable)
foo.reposetup(ui, repo)
bar.reposetup(ui, repo)
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.
--
Martin Geisler
VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multiparty Computation) to Python. See: http://viff.dk/.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://selenic.com/pipermail/mercurial-devel/attachments/20090811/4f3719a7/attachment.pgp
More information about the Mercurial-devel
mailing list