changeset 8477:a0104303f400

alias: honor the [defaults] section, fix issue1642
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Sun, 17 May 2009 16:15:37 +0200
parents d5dda64f5552
children d728f126c1b7
files hgext/alias.py tests/test-alias tests/test-alias.out
diffstat 3 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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