Patchwork [3,of,3,V2] ui: rerun color.setup() once the pager has spawned to honor 'color.pagermode'

login
register
mail settings
Submitter Matt Harbison
Date March 28, 2017, 2:50 a.m.
Message ID <3fa40378c88e3b914905.1490669428@Envy>
Download mbox | patch
Permalink /patch/19764/
State Accepted
Headers show

Comments

Matt Harbison - March 28, 2017, 2:50 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1490483831 14400
#      Sat Mar 25 19:17:11 2017 -0400
# Node ID 3fa40378c88e3b9149054de48b9b880d93653488
# Parent  1c73c5cde39463e03c3c7be10b6fe1256a6e5143
ui: rerun color.setup() once the pager has spawned to honor 'color.pagermode'

Otherwise, ui.pageractive is False when color is setup in dispatch.py (without
--pager=on), and this config option is ignored.

Patch

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -859,6 +859,12 @@ 
             # auto-detection of things being formatted.
             self.setconfig('ui', 'formatted', wasformatted, 'pager')
             self.setconfig('ui', 'interactive', False, 'pager')
+
+            # If pagermode differs from color.mode, reconfigure color now that
+            # pageractive is set.
+            cm = self._colormode
+            if cm != self.config('color', 'pagermode', cm):
+                color.setup(self)
         else:
             # If the pager can't be spawned in dispatch when --pager=on is
             # given, don't try again when the command runs, to avoid a duplicate