Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 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 |
comparison
equal
deleted
inserted
replaced
737:8db4d406b3d3 | 738:32a97c9d8e98 |
---|---|
119 def make_file(repo, r, pat, node=None, | 119 def make_file(repo, r, pat, node=None, |
120 total=None, seqno=None, revwidth=None, mode='wb'): | 120 total=None, seqno=None, revwidth=None, mode='wb'): |
121 if not pat or pat == '-': | 121 if not pat or pat == '-': |
122 if 'w' in mode: return sys.stdout | 122 if 'w' in mode: return sys.stdout |
123 else: return sys.stdin | 123 else: return sys.stdin |
124 if hasattr(pat, 'write') and 'w' in mode: | |
125 return pat | |
126 if hasattr(pat, 'read') and 'r' in mode: | |
127 return pat | |
124 node_expander = { | 128 node_expander = { |
125 'H': lambda: hg.hex(node), | 129 'H': lambda: hg.hex(node), |
126 'R': lambda: str(r.rev(node)), | 130 'R': lambda: str(r.rev(node)), |
127 'h': lambda: hg.short(node), | 131 'h': lambda: hg.short(node), |
128 } | 132 } |