[PATCH 1 of 3] keyword: monkeypatch dispatch._runcommand instead of _parse

Christian Ebert blacktrash at gmx.net
Mon Jun 2 04:13:12 CDT 2008


# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1212356852 -7200
# Node ID 72b9cb02e546876e490b00a6374137dac0876537
# Parent  1603bba96411ce4608d7653bc1f3d6058ddf2db2
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.

diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -408,7 +408,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':
@@ -417,14 +417,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.


More information about the Mercurial-devel mailing list