[PATCH 3 of 4 V2] pager: ensure wrapped dispatch._runcommand runs before color's

Gregory Szorc gregory.szorc at gmail.com
Fri Feb 6 14:11:03 CST 2015


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1423253349 28800
#      Fri Feb 06 12:09:09 2015 -0800
# Node ID e7fd7d7aabbebd77be388a2c80b2f1daf8534c84
# Parent  b46b4078fbecbfacaecc3ca4bf71c90b74908467
pager: ensure wrapped dispatch._runcommand runs before color's

An upcoming patch will teach color to potentially act differently if the
pager is active. Since both extensions wrap the same function
(dispatch._runcommand) to change behavior, we must guarantee that
pager's wrapped function runs before color's so color may read the
breadcrumb left by pager.

diff --git a/hgext/pager.py b/hgext/pager.py
--- a/hgext/pager.py
+++ b/hgext/pager.py
@@ -158,9 +158,14 @@ def uisetup(ui):
                 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
             _runpager(ui, p)
         return orig(ui, options, cmd, cmdfunc)
 
-    extensions.wrapfunction(dispatch, '_runcommand', pagecmd)
+    # Wrap dispatch._runcommand after color is loaded so color can see
+    # ui.pageractive. Otherwise, if we loaded first, color's wrapped
+    # dispatch._runcommand would run without having access to ui.pageractive.
+    def afterloaded(loaded):
+        extensions.wrapfunction(dispatch, '_runcommand', pagecmd)
+    extensions.afterloaded('color', afterloaded)
 
 def extsetup(ui):
     commands.globalopts.append(
         ('', 'pager', 'auto',


More information about the Mercurial-devel mailing list