mercurial/hook.py
changeset 14999 f6a737357195
parent 14943 d3bb825ddae3
parent 14993 e5b2ee5157ae
child 15512 8b011ededfb2
equal deleted inserted replaced
14995:8d928799dab5 14999:f6a737357195
   132 def hook(ui, repo, name, throw=False, **args):
   132 def hook(ui, repo, name, throw=False, **args):
   133     r = False
   133     r = False
   134 
   134 
   135     oldstdout = -1
   135     oldstdout = -1
   136     if _redirect:
   136     if _redirect:
   137         stdoutno = sys.__stdout__.fileno()
   137         try:
   138         stderrno = sys.__stderr__.fileno()
   138             stdoutno = sys.__stdout__.fileno()
   139         # temporarily redirect stdout to stderr, if possible
   139             stderrno = sys.__stderr__.fileno()
   140         if stdoutno >= 0 and stderrno >= 0:
   140             # temporarily redirect stdout to stderr, if possible
   141             oldstdout = os.dup(stdoutno)
   141             if stdoutno >= 0 and stderrno >= 0:
   142             os.dup2(stderrno, stdoutno)
   142                 oldstdout = os.dup(stdoutno)
       
   143                 os.dup2(stderrno, stdoutno)
       
   144         except AttributeError:
       
   145             # __stdout/err__ doesn't have fileno(), it's not a real file
       
   146             pass
   143 
   147 
   144     try:
   148     try:
   145         for hname, cmd in ui.configitems('hooks'):
   149         for hname, cmd in ui.configitems('hooks'):
   146             if hname.split('.')[0] != name or not cmd:
   150             if hname.split('.')[0] != name or not cmd:
   147                 continue
   151                 continue