changeset 4619:7c8f8b736365

extensions: kill ui readhooks Move .hgrc extension loading into localrepo
author Matt Mackall <mpm@selenic.com>
date Mon, 18 Jun 2007 13:24:34 -0500
parents 669e76b7df24
children 5fd7cc897542
files mercurial/cmdutil.py mercurial/localrepo.py mercurial/ui.py
diffstat 3 files changed, 4 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -262,7 +262,6 @@ def dispatch(ui, args):
         os.chdir(cwd)
 
     extensions.loadall(ui)
-    ui.addreadhook(extensions.loadall)
 
     # read the local repository .hgrc into a local ui object
     # this will trigger its extensions to load
@@ -273,8 +272,9 @@ def dispatch(ui, args):
         try:
             lui = commands.ui.ui(parentui=ui)
             lui.readconfig(os.path.join(path, ".hg", "hgrc"))
+            extensions.loadall(lui)
         except IOError:
-            pass
+            extensions.loadall(ui)
 
     cmd, func, args, options, cmdoptions = parse(ui, args)
 
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -10,7 +10,7 @@ from i18n import _
 import repo, changegroup
 import changelog, dirstate, filelog, manifest, context
 import re, lock, transaction, tempfile, stat, mdiff, errno, ui
-import os, revlog, time, util
+import os, revlog, time, util, extensions
 
 class localrepository(repo.repository):
     capabilities = ('lookup', 'changegroupsubset')
@@ -76,6 +76,7 @@ class localrepository(repo.repository):
         self.ui = ui.ui(parentui=parentui)
         try:
             self.ui.readconfig(self.join("hgrc"), self.root)
+            extensions.loadall(self.ui)
         except IOError:
             pass
 
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -32,7 +32,6 @@ class ui(object):
         if parentui is None:
             # this is the parent of all ui children
             self.parentui = None
-            self.readhooks = []
             self.quiet = quiet
             self.verbose = verbose
             self.debugflag = debug
@@ -52,7 +51,6 @@ class ui(object):
         else:
             # parentui may point to an ui object which is already a child
             self.parentui = parentui.parentui or parentui
-            self.readhooks = self.parentui.readhooks[:]
             self.trusted_users = parentui.trusted_users.copy()
             self.trusted_groups = parentui.trusted_groups.copy()
             self.cdata = dupconfig(self.parentui.cdata)
@@ -154,11 +152,6 @@ class ui(object):
         if root is None:
             root = os.path.expanduser('~')
         self.fixconfig(root=root)
-        for hook in self.readhooks:
-            hook(self)
-
-    def addreadhook(self, hook):
-        self.readhooks.append(hook)
 
     def readsections(self, filename, *sections):
         """Read filename and add only the specified sections to the config data