comparison mercurial/cmdutil.py @ 13769:8796fb6af67e

cmdutil: fix mode handling in make_file
author Adrian Buehlmann <adrian@cadifra.com>
date Wed, 23 Feb 2011 23:30:48 +0100
parents 4ec34de8bbb1
children a8d13ee0ce68
comparison
equal deleted inserted replaced
13768:10aea25fb519 13769:8796fb6af67e
228 inst.args[0]) 228 inst.args[0])
229 229
230 def make_file(repo, pat, node=None, 230 def make_file(repo, pat, node=None,
231 total=None, seqno=None, revwidth=None, mode='wb', pathname=None): 231 total=None, seqno=None, revwidth=None, mode='wb', pathname=None):
232 232
233 writable = 'w' in mode or 'a' in mode 233 writable = mode not in ('r', 'rb')
234 234
235 if not pat or pat == '-': 235 if not pat or pat == '-':
236 fp = writable and sys.stdout or sys.stdin 236 fp = writable and sys.stdout or sys.stdin
237 return os.fdopen(os.dup(fp.fileno()), mode) 237 return os.fdopen(os.dup(fp.fileno()), mode)
238 if hasattr(pat, 'write') and writable: 238 if hasattr(pat, 'write') and writable: