comparison mercurial/ui.py @ 23269:d9d8d2e0f701

ui: introduce util.system() wrapper to make sure ui.fout is used This change is intended to avoid future problem of data corruption under command server. out=ui.fout is mandatory as long as command server uses stdout as IPC channel.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 08 Nov 2014 12:57:42 +0900
parents e53f6b72a0e4
children 9c32eea2ca04
comparison
equal deleted inserted replaced
23268:0fd3862ef425 23269:d9d8d2e0f701
812 if editform: 812 if editform:
813 environ.update({'HGEDITFORM': editform}) 813 environ.update({'HGEDITFORM': editform})
814 814
815 editor = self.geteditor() 815 editor = self.geteditor()
816 816
817 util.system("%s \"%s\"" % (editor, name), 817 self.system("%s \"%s\"" % (editor, name),
818 environ=environ, 818 environ=environ,
819 onerr=util.Abort, errprefix=_("edit failed"), 819 onerr=util.Abort, errprefix=_("edit failed"))
820 out=self.fout)
821 820
822 f = open(name) 821 f = open(name)
823 t = f.read() 822 t = f.read()
824 f.close() 823 f.close()
825 finally: 824 finally:
826 os.unlink(name) 825 os.unlink(name)
827 826
828 return t 827 return t
828
829 def system(self, cmd, environ={}, cwd=None, onerr=None, errprefix=None):
830 '''execute shell command with appropriate output stream. command
831 output will be redirected if fout is not stdout.
832 '''
833 return util.system(cmd, environ=environ, cwd=cwd, onerr=onerr,
834 errprefix=errprefix, out=self.fout)
829 835
830 def traceback(self, exc=None, force=False): 836 def traceback(self, exc=None, force=False):
831 '''print exception traceback if traceback printing enabled or forced. 837 '''print exception traceback if traceback printing enabled or forced.
832 only to call in exception handler. returns true if traceback 838 only to call in exception handler. returns true if traceback
833 printed.''' 839 printed.'''