diff -r 8568bbdfbafe -r bf763946f8b0 mercurial/cmdutil.py --- a/mercurial/cmdutil.py Fri Dec 10 19:20:11 2010 -0600 +++ b/mercurial/cmdutil.py Tue Dec 07 16:08:16 2010 +0100 @@ -233,7 +233,8 @@ writable = 'w' in mode or 'a' in mode if not pat or pat == '-': - return writable and sys.stdout or sys.stdin + fp = writable and sys.stdout or sys.stdin + return os.fdopen(os.dup(fp.fileno()), mode) if hasattr(pat, 'write') and writable: return pat if hasattr(pat, 'read') and 'r' in mode: