comparison mercurial/ui.py @ 30994:3ed6e43998df

ui: introduce neverpager() call I'm about to add direct paging support to some commands, and as a result we need a way to communicate from the higher layers of dispatch that paging is explicitly disabled.
author Augie Fackler <augie@google.com>
date Wed, 15 Feb 2017 17:48:03 -0500
parents 61b4122019d3
children 5e85bab867a7
comparison
equal deleted inserted replaced
30993:9c2977ceaa46 30994:3ed6e43998df
153 if src: 153 if src:
154 self.fout = src.fout 154 self.fout = src.fout
155 self.ferr = src.ferr 155 self.ferr = src.ferr
156 self.fin = src.fin 156 self.fin = src.fin
157 self.pageractive = src.pageractive 157 self.pageractive = src.pageractive
158 self._neverpager = src._neverpager
158 159
159 self._tcfg = src._tcfg.copy() 160 self._tcfg = src._tcfg.copy()
160 self._ucfg = src._ucfg.copy() 161 self._ucfg = src._ucfg.copy()
161 self._ocfg = src._ocfg.copy() 162 self._ocfg = src._ocfg.copy()
162 self._trustusers = src._trustusers.copy() 163 self._trustusers = src._trustusers.copy()
171 else: 172 else:
172 self.fout = util.stdout 173 self.fout = util.stdout
173 self.ferr = util.stderr 174 self.ferr = util.stderr
174 self.fin = util.stdin 175 self.fin = util.stdin
175 self.pageractive = False 176 self.pageractive = False
177 self._neverpager = False
176 178
177 # shared read-only environment 179 # shared read-only environment
178 self.environ = encoding.environ 180 self.environ = encoding.environ
179 181
180 self.httppasswordmgrdb = httppasswordmgrdbproxy() 182 self.httppasswordmgrdb = httppasswordmgrdbproxy()
829 def _isatty(self, fh): 831 def _isatty(self, fh):
830 if self.configbool('ui', 'nontty', False): 832 if self.configbool('ui', 'nontty', False):
831 return False 833 return False
832 return util.isatty(fh) 834 return util.isatty(fh)
833 835
836 def neverpager(self):
837 self._neverpager = True
838
834 def pager(self, command): 839 def pager(self, command):
835 """Start a pager for subsequent command output. 840 """Start a pager for subsequent command output.
836 841
837 Commands which produce a long stream of output should call 842 Commands which produce a long stream of output should call
838 this function to activate the user's preferred pagination 843 this function to activate the user's preferred pagination
842 847
843 Args: 848 Args:
844 command: The full, non-aliased name of the command. That is, "log" 849 command: The full, non-aliased name of the command. That is, "log"
845 not "history, "summary" not "summ", etc. 850 not "history, "summary" not "summ", etc.
846 """ 851 """
847 if (self.pageractive 852 if (self._neverpager
853 or self.pageractive
848 # TODO: if we want to allow HGPLAINEXCEPT=pager, 854 # TODO: if we want to allow HGPLAINEXCEPT=pager,
849 # formatted() will need some adjustment. 855 # formatted() will need some adjustment.
850 or not self.formatted() 856 or not self.formatted()
851 or self.plain() 857 or self.plain()
852 # TODO: expose debugger-enabled on the UI object 858 # TODO: expose debugger-enabled on the UI object