mercurial/cmdutil.py
changeset 4670 850950e59b52
parent 4667 c7a81e3ae80f
child 4671 150afe6becf6
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -262,11 +262,9 @@ def dispatch(ui, args):
         os.chdir(cwd)
 
     # read the local repository .hgrc into a local ui object
-    # this will trigger its extensions to load
-    path = earlygetopt(["-R", "--repository", "--repo"], args)
+    path = findrepo() or ""
     if not path:
-        path = findrepo() or ""
-    lui = ui
+        lui = ui
     if path:
         try:
             lui = commands.ui.ui(parentui=ui)
@@ -274,6 +272,13 @@ def dispatch(ui, args):
         except IOError:
             pass
 
+    # now we can expand paths, even ones in .hg/hgrc
+    rpath = earlygetopt(["-R", "--repository", "--repo"], args)
+    if rpath:
+        path = lui.expandpath(rpath)
+        lui = commands.ui.ui(parentui=ui)
+        lui.readconfig(os.path.join(path, ".hg", "hgrc"))
+
     extensions.loadall(lui)
     # check for fallback encoding
     fallback = lui.config('ui', 'fallbackencoding')