dispatch: move shell alias handling after early arg handling
authorMatt Mackall <mpm@selenic.com>
Fri, 15 Jul 2011 16:06:53 -0500
changeset 14886 9a3831d64ae2
parent 14885 50b67d5c4073
child 14887 d6ba373c9a8f
dispatch: move shell alias handling after early arg handling --cwd, --repo, and --config obviously should be handled first
mercurial/dispatch.py
tests/test-alias.t
--- a/mercurial/dispatch.py	Fri Jul 15 14:27:16 2011 -0500
+++ b/mercurial/dispatch.py	Fri Jul 15 16:06:53 2011 -0500
@@ -526,10 +526,6 @@
     args = req.args
     ui = req.ui
 
-    shellaliasfn = _checkshellalias(ui, args)
-    if shellaliasfn:
-        return shellaliasfn()
-
     # read --config before doing anything else
     # (e.g. to change trust settings for reading .hg/hgrc)
     cfgs = _parseconfig(ui, _earlygetopt(['--config'], args))
@@ -542,6 +538,12 @@
     rpath = _earlygetopt(["-R", "--repository", "--repo"], args)
     path, lui = _getlocal(ui, rpath)
 
+    # Now that we're operating in the right directory/repository with
+    # the right config settings, check for shell aliases
+    shellaliasfn = _checkshellalias(ui, args)
+    if shellaliasfn:
+        return shellaliasfn()
+
     # Configure extensions in phases: uisetup, extsetup, cmdtable, and
     # reposetup. Programs like TortoiseHg will call _dispatch several
     # times so we keep track of configured extensions in _loaded.
--- a/tests/test-alias.t	Fri Jul 15 14:27:16 2011 -0500
+++ b/tests/test-alias.t	Fri Jul 15 16:06:53 2011 -0500
@@ -251,7 +251,7 @@
   $ hg --cwd .. count 'branch(default)'
   2
   $ hg echo --cwd ..
-  --cwd ..
+  
 
 
 repo specific shell aliases
@@ -274,8 +274,6 @@
   hg: unknown command 'subalias'
   [255]
   $ hg -R .. subalias > /dev/null
-  hg: unknown command 'subalias'
-  [255]
 
 
 shell alias defined in other repo
@@ -284,6 +282,7 @@
   hg: unknown command 'mainalias'
   [255]
   $ hg -R .. mainalias
+  warning: --repository ignored
   main
   $ hg --cwd .. mainalias
   main