changeset 3064:7a1a4d1f0958 stable

pager: add a function in compats to start pager This will help us enabling pager when ui.pager API exists. Also we can try plugging in the old pager API in this function and we won't have to change anything.
author Pulkit Goyal <7895pulkit@gmail.com>
date Sat, 14 Oct 2017 20:17:25 +0530
parents 6f87042766cb
children fdd0b6c26597
files hgext3rd/evolve/compat.py hgext3rd/topic/compat.py
diffstat 2 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/compat.py	Fri Oct 13 20:28:21 2017 +0200
+++ b/hgext3rd/evolve/compat.py	Sat Oct 14 20:17:25 2017 +0530
@@ -172,3 +172,8 @@
 
 if not util.safehasattr(obsolete, '_computephasedivergentset'):
     obsolete._computephasedivergentset = obsolete.cachefor('phasedivergent')(obsolete._computebumpedset)
+
+def startpager(ui, cmd):
+    """function to start a pager in case ui.pager() exists"""
+    if util.safehasattr(ui, 'pager'):
+        ui.pager(cmd)
--- a/hgext3rd/topic/compat.py	Fri Oct 13 20:28:21 2017 +0200
+++ b/hgext3rd/topic/compat.py	Sat Oct 14 20:17:25 2017 +0530
@@ -22,3 +22,10 @@
     getmarkers = obsolete.getmarkers
 if successorssets is None:
     successorssets = obsolete.successorssets
+
+def startpager(ui, cmd):
+    """function to start a pager in case ui.pager() exists"""
+    try:
+        ui.pager(cmd)
+    except AttributeError:
+        pass