alias: honor the [defaults] section, fix issue1642
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Sun, 17 May 2009 16:15:37 +0200
changeset 8477 a0104303f400
parent 8476 d5dda64f5552
child 8478 d728f126c1b7
alias: honor the [defaults] section, fix issue1642
hgext/alias.py
tests/test-alias
tests/test-alias.out
--- a/hgext/alias.py	Sun May 17 16:08:47 2009 +0200
+++ b/hgext/alias.py	Sun May 17 16:15:37 2009 +0200
@@ -11,6 +11,7 @@
 
 from mercurial.i18n import _
 from mercurial import commands, cmdutil, error
+import shlex
 
 cmdtable = {}
 
@@ -69,8 +70,11 @@
         if not target:
             ui.warn(_('*** [alias] %s: no definition\n') % cmd)
             continue
-        args = target.split(' ')
+        args = shlex.split(target)
         tcmd = args.pop(0)
         if args:
+            defaults = ui.config('defaults', cmd)
+            if defaults:
+                args = shlex.split(defaults) + args
             ui.setconfig('defaults', cmd, ' '.join(args))
         cmdtable[cmd] = lazycommand(ui, cmd, tcmd)
--- a/tests/test-alias	Sun May 17 16:08:47 2009 +0200
+++ b/tests/test-alias	Sun May 17 16:15:37 2009 +0200
@@ -10,6 +10,13 @@
 unknown = bargle
 ambiguous = s
 recursive = recursive
+mylog = log
+lognull = log -r null
+
+[defaults]
+mylog = -q
+lognull = -q
+log = -v
 EOF
 
 echo '% basic'
@@ -30,3 +37,7 @@
 
 echo '% with opts'
 hg cleanst
+
+echo '% interaction with defaults'
+hg mylog
+hg lognull
--- a/tests/test-alias.out	Sun May 17 16:08:47 2009 +0200
+++ b/tests/test-alias.out	Sun May 17 16:15:37 2009 +0200
@@ -8,3 +8,6 @@
 adding foo
 % with opts
 C foo
+% interaction with defaults
+0:e63c23eaa88a
+-1:000000000000