pager: add a function in compats to start pager stable
authorPulkit Goyal <7895pulkit@gmail.com>
Sat, 14 Oct 2017 20:17:25 +0530
branchstable
changeset 3064 7a1a4d1f0958
parent 3061 6f87042766cb
child 3065 fdd0b6c26597
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.
hgext3rd/evolve/compat.py
hgext3rd/topic/compat.py
--- 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