comparison mercurial/ui.py @ 31079:873ebdd6e84d

pager: do not try to run an empty pager command If pagercmd is explicitly set to '', the pager process would exit silently and the output would be lost. We'd better disable the pager in such case.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 23 Feb 2017 21:27:25 +0900
parents 88203f26ea57
children c42feb5f3143
comparison
equal deleted inserted replaced
31078:a113284f54a0 31079:873ebdd6e84d
867 or '--debugger' in sys.argv): 867 or '--debugger' in sys.argv):
868 # We only want to paginate if the ui appears to be 868 # We only want to paginate if the ui appears to be
869 # interactive, the user didn't say HGPLAIN or 869 # interactive, the user didn't say HGPLAIN or
870 # HGPLAINEXCEPT=pager, and the user didn't specify --debug. 870 # HGPLAINEXCEPT=pager, and the user didn't specify --debug.
871 return 871 return
872 self.debug('starting pager for command %r\n' % command)
873 872
874 # TODO: add a "system defaults" config section so this default 873 # TODO: add a "system defaults" config section so this default
875 # of more(1) can be easily replaced with a global 874 # of more(1) can be easily replaced with a global
876 # configuration file. For example, on OS X the sane default is 875 # configuration file. For example, on OS X the sane default is
877 # less(1), not more(1), and on debian it's 876 # less(1), not more(1), and on debian it's
878 # sensible-pager(1). We should probably also give the system 877 # sensible-pager(1). We should probably also give the system
879 # default editor command similar treatment. 878 # default editor command similar treatment.
880 envpager = encoding.environ.get('PAGER', 'more') 879 envpager = encoding.environ.get('PAGER', 'more')
881 pagercmd = self.config('pager', 'pager', envpager) 880 pagercmd = self.config('pager', 'pager', envpager)
881 if not pagercmd:
882 return
883
884 self.debug('starting pager for command %r\n' % command)
882 self.pageractive = True 885 self.pageractive = True
883 # Preserve the formatted-ness of the UI. This is important 886 # Preserve the formatted-ness of the UI. This is important
884 # because we mess with stdout, which might confuse 887 # because we mess with stdout, which might confuse
885 # auto-detection of things being formatted. 888 # auto-detection of things being formatted.
886 self.setconfig('ui', 'formatted', self.formatted(), 'pager') 889 self.setconfig('ui', 'formatted', self.formatted(), 'pager')