changeset 1453:6fbb13b7a59f

get command defaults from hgrc
author TK Soh <teekaysoh@yahoo.com>
date Wed, 26 Oct 2005 16:10:36 -0700
parents f1755621cb7d
children f4250806dbeb
files mercurial/commands.py
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Tue Oct 25 22:17:31 2005 -0700
+++ b/mercurial/commands.py	Wed Oct 26 16:10:36 2005 -0700
@@ -2417,7 +2417,7 @@
 class ParseError(Exception):
     """Exception raised on errors in parsing the command line."""
 
-def parse(args):
+def parse(ui, args):
     options = {}
     cmdoptions = {}
 
@@ -2428,6 +2428,17 @@
 
     if args:
         cmd, args = args[0], args[1:]
+        defaults = ui.config("defaults", cmd)
+        if defaults:
+            # reparse with command defaults added
+            args = [cmd] + defaults.split() + args
+            try:
+                args = fancyopts.fancyopts(args, globalopts, options)
+            except fancyopts.getopt.GetoptError, inst:
+                raise ParseError(None, inst)
+
+            cmd, args = args[0], args[1:]
+
         i = find(cmd)[1]
         c = list(i[1])
     else:
@@ -2494,7 +2505,7 @@
         table.update(cmdtable)
 
     try:
-        cmd, func, args, options, cmdoptions = parse(args)
+        cmd, func, args, options, cmdoptions = parse(u, args)
     except ParseError, inst:
         if inst.args[0]:
             u.warn(_("hg %s: %s\n") % (inst.args[0], inst.args[1]))