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

login
register
mail settings
Submitter Gregory Szorc
Date Feb. 6, 2015, 8:11 p.m.
Message ID <e7fd7d7aabbebd77be38.1423253463@gps-mbp.local>
Download mbox | patch
Permalink /patch/7723/
State Accepted
Commit 0baf41e02a4d89eebf0b33b7aaee0606601706c6
Headers show

Comments

Gregory Szorc - Feb. 6, 2015, 8:11 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@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.

Patch

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',