diff -r eff102facb15 -r 14f3795a5ed7 mercurial/cmdutil.py --- a/mercurial/cmdutil.py Fri Feb 11 22:24:10 2011 +0800 +++ b/mercurial/cmdutil.py Fri Dec 24 15:23:01 2010 +0100 @@ -679,7 +679,9 @@ parents.reverse() prev = (parents and parents[0]) or nullid + shouldclose = False if not fp: + shouldclose = True fp = make_file(repo, template, node, total=total, seqno=seqno, revwidth=revwidth, mode='ab') if fp != sys.stdout and hasattr(fp, 'name'): @@ -700,7 +702,8 @@ for chunk in patch.diff(repo, prev, node, opts=opts): fp.write(chunk) - fp.flush() + if shouldclose: + fp.close() for seqno, rev in enumerate(revs): single(rev, seqno + 1, fp)