[PATCH 4 of 4] keyword: store functions before their monkey redefinitions
Christian Ebert
blacktrash at gmx.net
Tue Jun 3 07:38:15 UTC 2008
# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1212478524 -7200
# Node ID 8b29e22f01571b730c5bef31d12a04b1f3c60784
# Parent 4a1deb1ee9521183d8b66912fdf737903138a32a
keyword: store functions before their monkey redefinitions
monkey creation step by step:
1. store original function in variable
2. redefine function using stored original
3. assign original name to redefined function
diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -419,11 +419,12 @@
kwtools['exc'].append(pat)
if kwtools['inc']:
+ dispatch_runcommand = dispatch._runcommand
+
def kwdispatch_runcommand(ui, options, cmd, cmdfunc):
kwtools['hgcmd'] = cmd
return dispatch_runcommand(ui, options, cmd, cmdfunc)
- dispatch_runcommand = dispatch._runcommand
dispatch._runcommand = kwdispatch_runcommand
def reposetup(ui, repo):
@@ -495,7 +496,14 @@
finally:
del wlock, lock
+ repo.__class__ = kwrepo
+
# monkeypatches
+ patchfile_init = patch.patchfile.__init__
+ patch_diff = patch.diff
+ webcommands_changeset = webcommands.changeset
+ webcommands_filediff = webcommands.filediff
+
def kwpatchfile_init(self, ui, fname, missing=False):
'''Monkeypatch/wrap patch.patchfile.__init__ to avoid
rejects or conflicts due to expanded keywords in working dir.'''
@@ -523,13 +531,6 @@
kwt.matcher = util.never
return webcommands_filediff(web, req, tmpl)
- repo.__class__ = kwrepo
-
- patchfile_init = patch.patchfile.__init__
- patch_diff = patch.diff
- webcommands_changeset = webcommands.changeset
- webcommands_filediff = webcommands.filediff
-
patch.patchfile.__init__ = kwpatchfile_init
patch.diff = kw_diff
webcommands.changeset = webcommands.rev = kwweb_changeset
More information about the Mercurial-devel
mailing list