changeset 40597:04d08f17ce7a

help: document weird behavior of uisetup() While refactoring ui.log() API, it was really annoying that uisetup() is actually an extsetup() the phase 1. Let's document that. I'm planning to add another uisetup() which is called per ui instance, though I can't think of a good name for it.
author Yuya Nishihara <yuya@tcha.org>
date Mon, 12 Nov 2018 22:51:36 +0900
parents 252396a6a3f2
children fa33196088c4
files mercurial/help/internals/extensions.txt
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/help/internals/extensions.txt	Mon Nov 12 22:26:24 2018 +0900
+++ b/mercurial/help/internals/extensions.txt	Mon Nov 12 22:51:36 2018 +0900
@@ -159,7 +159,8 @@
 then ``extsetup`` is called. This means ``extsetup`` can be useful in case
 one extension optionally depends on another extension.
 
-Both ``uisetup`` and ``extsetup`` receive a ui object::
+Both ``uisetup`` and ``extsetup`` receive a ui object with the local
+repository configuration::
 
     def uisetup(ui):
         # ...
@@ -167,6 +168,13 @@
     def extsetup(ui):
         # ...
 
+Be aware that ``uisetup`` in NOT the function to configure a ``ui`` instance.
+It's called only once per process, not per ``ui`` instance. Also, any changes
+to the ``ui`` may be discarded because the ``ui`` here temporarily loaded
+local configuration. So, it's generally wrong to do `ui.setconfig()` in
+these callbacks. Notable exception is setting ``pre/post-<command>`` hooks
+and extending ``ui.__class__``.
+
 In Mercurial 1.3.1 or earlier, ``extsetup`` takes no argument.
 
 Command table setup