keyword: monkeypatch dispatch._runcommand instead of _parse
authorChristian Ebert <blacktrash@gmx.net>
Sun, 01 Jun 2008 23:47:32 +0200
changeset 455 10ebb9f44b99
parent 452 f83dd10a4d24
child 456 47bbe7c2fa7d
child 459 df56cd11458d
keyword: monkeypatch dispatch._runcommand instead of _parse We want the current command, and hooking into this method makes it more transparent what we are doing.
hgkw/keyword.py
--- a/hgkw/keyword.py	Wed May 14 02:24:40 2008 +0200
+++ b/hgkw/keyword.py	Sun Jun 01 23:47:32 2008 +0200
@@ -410,7 +410,7 @@
 
 def uisetup(ui):
     '''Collects [keyword] config in kwtools.
-    Monkeypatches dispatch._parse if needed.'''
+    Monkeypatch dispatch._runcommand if needed to grab command for kwtools.'''
 
     for pat, opt in ui.configitems('keyword'):
         if opt != 'ignore':
@@ -419,14 +419,12 @@
             kwtools['exc'].append(pat)
 
     if kwtools['inc']:
-        def kwdispatch_parse(ui, args):
-            '''Monkeypatch dispatch._parse to obtain running hg command.'''
-            cmd, func, args, options, cmdoptions = dispatch_parse(ui, args)
+        def kwdispatch_runcommand(ui, options, cmd, cmdfunc):
             kwtools['hgcmd'] = cmd
-            return cmd, func, args, options, cmdoptions
+            return dispatch_runcommand(ui, options, cmd, cmdfunc)
 
-        dispatch_parse = dispatch._parse
-        dispatch._parse = kwdispatch_parse
+        dispatch_runcommand = dispatch._runcommand
+        dispatch._runcommand = kwdispatch_runcommand
 
 def reposetup(ui, repo):
     '''Sets up repo as kwrepo for keyword substitution.