[PATCH 2 of 4] dispatch: add an additional extensibility point during dispatch

Gregory Szorc gregory.szorc at gmail.com
Wed Feb 4 16:17:11 CST 2015


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1423087102 28800
#      Wed Feb 04 13:58:22 2015 -0800
# Node ID f6866444b15b1bb1c5e24ea31660e1f8deb78a83
# Parent  c1b76e9330b1f39342899d8d53c3ddab388c3cb5
dispatch: add an additional extensibility point during dispatch

An upcoming patch will introduce an ordering dependency between the
color and pager extensions. Specifically, one's uisetup function must
come before the other's.

There is no easy way to accomplish guaranteed ordering of extension
functions. The Mercurial project has survived many years without an
explicit dependency system between extensions. Instead of inventing
one to solve this problem, we instead create a new, separate monkeypatch
point for the color extension to use to ensure its code runs after
pager's. It is ugly. But it is simple.

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -916,8 +916,10 @@ def statprofile(ui, func, fp):
         statprof.stop()
         statprof.display(fp)
 
 def _runcommand(ui, options, cmd, cmdfunc):
+    _latefixupui(ui, options, cmd, cmdfunc)
+
     def checkargs():
         try:
             return cmdfunc()
         except error.SignatureError:
@@ -948,4 +950,7 @@ def _runcommand(ui, options, cmd, cmdfun
             if output:
                 fp.close()
     else:
         return checkargs()
+
+def _latefixupui(ui, options, cmd, cmdfunc):
+    """Additionally extensibility point called during _runcommand."""


More information about the Mercurial-devel mailing list