pager: wrap ui._runpager
authorJun Wu <quark@fb.com>
Mon, 26 Dec 2016 00:25:44 +0000
changeset 30722 117e15c30e6c
parent 30721 4ab19763d71c
child 30723 6ef9f32d76c6
pager: wrap ui._runpager As discussed at [1], ui._runpager will be the new low-level API accepting a pager command to actually run the pager. And ui.pager is the high-level API which reads config directly from self. This change is necessary for chgserver to override _runpager cleanly. [1]: www.mercurial-scm.org/pipermail/mercurial-devel/2016-December/091656.html
hgext/pager.py
--- a/hgext/pager.py	Sat Jan 07 12:24:15 2017 +0100
+++ b/hgext/pager.py	Mon Dec 26 00:25:44 2016 +0000
@@ -118,6 +118,12 @@
     if '--debugger' in sys.argv or not ui.formatted():
         return
 
+    class pagerui(ui.__class__):
+        def _runpager(self, pagercmd):
+            _runpager(self, pagercmd)
+
+    ui.__class__ = pagerui
+
     # chg has its own pager implementation
     argv = sys.argv[:]
     if 'chgunix' in dispatch._earlygetopt(['--cmdserver'], argv):
@@ -157,7 +163,7 @@
             ui.setconfig('ui', 'interactive', False, 'pager')
             if util.safehasattr(signal, "SIGPIPE"):
                 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
-            _runpager(ui, p)
+            ui._runpager(p)
         return orig(ui, options, cmd, cmdfunc)
 
     # Wrap dispatch._runcommand after color is loaded so color can see