hgext3rd/topic/compat.py
author Pulkit Goyal <7895pulkit@gmail.com>
Sat, 14 Oct 2017 20:17:25 +0530
branchstable
changeset 3064 7a1a4d1f0958
parent 2922 66357d4d03b2
child 3094 e11e018e8338
permissions -rw-r--r--
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.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2922
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     1
# Copyright 2017 FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     2
#
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     3
# This software may be used and distributed according to the terms of the
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     4
# GNU General Public License version 2 or any later version.
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     5
"""
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     6
Compatibility module
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     7
"""
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     8
from __future__ import absolute_import
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
     9
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    10
from mercurial import obsolete
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    11
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    12
getmarkers = None
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    13
successorssets = None
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    14
try:
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    15
    from mercurial import obsutil
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    16
    getmarkers = getattr(obsutil, 'getmarkers', None)
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    17
    successorssets = getattr(obsutil, 'successorssets', None)
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    18
except ImportError:
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    19
    pass
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    20
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    21
if getmarkers is None:
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    22
    getmarkers = obsolete.getmarkers
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    23
if successorssets is None:
66357d4d03b2 topic: centralize compatibility logic between hg versions into compat module
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
diff changeset
    24
    successorssets = obsolete.successorssets
3064
7a1a4d1f0958 pager: add a function in compats to start pager
Pulkit Goyal <7895pulkit@gmail.com>
parents: 2922
diff changeset
    25
7a1a4d1f0958 pager: add a function in compats to start pager
Pulkit Goyal <7895pulkit@gmail.com>
parents: 2922
diff changeset
    26
def startpager(ui, cmd):
7a1a4d1f0958 pager: add a function in compats to start pager
Pulkit Goyal <7895pulkit@gmail.com>
parents: 2922
diff changeset
    27
    """function to start a pager in case ui.pager() exists"""
7a1a4d1f0958 pager: add a function in compats to start pager
Pulkit Goyal <7895pulkit@gmail.com>
parents: 2922
diff changeset
    28
    try:
7a1a4d1f0958 pager: add a function in compats to start pager
Pulkit Goyal <7895pulkit@gmail.com>
parents: 2922
diff changeset
    29
        ui.pager(cmd)
7a1a4d1f0958 pager: add a function in compats to start pager
Pulkit Goyal <7895pulkit@gmail.com>
parents: 2922
diff changeset
    30
    except AttributeError:
7a1a4d1f0958 pager: add a function in compats to start pager
Pulkit Goyal <7895pulkit@gmail.com>
parents: 2922
diff changeset
    31
        pass