comparison mercurial/ui.py @ 6303:577a7da1d44b

two fixes for the pager stuff - open pipe in binary mode - don't start a pager if stdout is not a tty (this prevents test-ssh from hanging if you set ui.usepager=True in run-tests.py)
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Wed, 19 Mar 2008 16:54:35 -0300
parents 8e3dc3de7e73
children 7240204121af
comparison
equal deleted inserted replaced
6302:8e3dc3de7e73 6303:577a7da1d44b
383 """Write to a pager if available, otherwise to stdout""" 383 """Write to a pager if available, otherwise to stdout"""
384 if self.buffers: 384 if self.buffers:
385 self.buffers[-1].extend([str(a) for a in args]) 385 self.buffers[-1].extend([str(a) for a in args])
386 else: 386 else:
387 if self.getpager() and not self.pager: 387 if self.getpager() and not self.pager:
388 self.pager = os.popen(self.getpager(), "w") 388 self.pager = os.popen(self.getpager(), "wb")
389 sys.stderr = self.pager 389 sys.stderr = self.pager
390 sys.stdout = self.pager 390 sys.stdout = self.pager
391 for a in args: 391 for a in args:
392 sys.stdout.write(str(a)) 392 sys.stdout.write(str(a))
393 393
493 os.environ.get("VISUAL") or 493 os.environ.get("VISUAL") or
494 os.environ.get("EDITOR", "vi")) 494 os.environ.get("EDITOR", "vi"))
495 495
496 def getpager(self): 496 def getpager(self):
497 '''return a pager''' 497 '''return a pager'''
498 if self.configbool("ui", "usepager", False): 498 if sys.stdout.isatty() and self.configbool("ui", "usepager", False):
499 return (self.config("ui", "pager") 499 return (self.config("ui", "pager")
500 or os.environ.get("PAGER")) 500 or os.environ.get("PAGER"))