changeset 4553:741f64dfc04d

dispatch: parse and apply -R early This allows us to use extensions specified in .hg/hgrc. Unfortunately, this requires us to parse that file twice, but performance impact on the version command appears to be less than 1%.
author Matt Mackall <mpm@selenic.com>
date Mon, 11 Jun 2007 21:09:24 -0500
parents 38cdee6b6675
children 9dbabb9d466c
files mercurial/cmdutil.py
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -9,7 +9,7 @@ from node import *
 from i18n import _
 import os, sys, mdiff, bdiff, util, templater, patch, commands
 import atexit, signal, pdb, hg, lock, fancyopts, traceback
-import socket, revlog, version, extensions, errno
+import socket, revlog, version, extensions, errno, localrepo
 
 revrangesep = ':'
 
@@ -255,6 +255,15 @@ def dispatch(ui, args):
     extensions.loadall(ui)
     ui.addreadhook(extensions.loadall)
 
+    # read the local extension info into a local ui object
+    rcpath = earlygetopt(["-R", "--repository"], args) or localrepo.findrepo()
+    if rcpath:
+        try:
+            lui = commands.ui.ui(parentui=ui)
+            lui.readconfig(os.path.join(rcpath, ".hg", "hgrc"))
+        except IOError:
+            pass
+
     cmd, func, args, options, cmdoptions = parse(ui, args)
 
     if options["encoding"]: