changeset 738:32a97c9d8e98

If the argument to make_file can act like a file, return it. This is useful for code that calls command functions, but doesn't want to send I/O through the filesystem.
author Bryan O'Sullivan <bos@serpentine.com>
date Wed, 20 Jul 2005 03:55:16 -0800
parents 8db4d406b3d3
children 36edb39e8e8c
files mercurial/commands.py
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Jul 20 03:52:06 2005 -0800
+++ b/mercurial/commands.py	Wed Jul 20 03:55:16 2005 -0800
@@ -121,6 +121,10 @@
     if not pat or pat == '-':
         if 'w' in mode: return sys.stdout
         else: return sys.stdin
+    if hasattr(pat, 'write') and 'w' in mode:
+        return pat
+    if hasattr(pat, 'read') and 'r' in mode:
+        return pat
     node_expander = {
         'H': lambda: hg.hex(node),
         'R': lambda: str(r.rev(node)),