changeset 41057:f7863606d4ff

exthelper: add a cautionary note about adding attributes to containers
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 23 Dec 2018 14:52:43 -0500
parents 41cd64a81dd9
children c61b8dfb07c8
files mercurial/exthelper.py
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/exthelper.py	Thu Dec 27 00:10:40 2018 -0500
+++ b/mercurial/exthelper.py	Sun Dec 23 14:52:43 2018 -0500
@@ -246,6 +246,15 @@
         This function takes two arguments, the container and the name of the
         function to wrap. The wrapping is performed during `uisetup`.
 
+        Adding attributes to a container like this is discouraged, because the
+        container modification is visible even in repositories that do not
+        have the extension loaded.  Therefore, care must be taken that the
+        function doesn't make assumptions that the extension was loaded for the
+        current repository.  For `ui` and `repo` instances, a better option is
+        to subclass the instance in `uipopulate` and `reposetup` respectively.
+
+        https://www.mercurial-scm.org/wiki/WritingExtensions
+
         example::
 
             @eh.addattr(context.changectx, 'babar')