comparison mercurial/windows.py @ 13188:6c9345f9edca stable

util: concentrate quoting knowledge to windows.py quotecommand() This fixes all callers of util.quotecommand() and place special knowledge of the bugfix in 2.7.1 in a single platform specific place.
author Steve Borho <steve@borho.org>
date Wed, 22 Dec 2010 13:25:00 -0600
parents c52c629ce19e
children 650314ed845d
comparison
equal deleted inserted replaced
13183:f9d29777b4eb 13188:6c9345f9edca
158 _quotere = re.compile(r'(\\*)("|\\$)') 158 _quotere = re.compile(r'(\\*)("|\\$)')
159 return '"%s"' % _quotere.sub(r'\1\1\\\2', s) 159 return '"%s"' % _quotere.sub(r'\1\1\\\2', s)
160 160
161 def quotecommand(cmd): 161 def quotecommand(cmd):
162 """Build a command string suitable for os.popen* calls.""" 162 """Build a command string suitable for os.popen* calls."""
163 # The extra quotes are needed because popen* runs the command 163 if sys.version_info < (2, 7, 1):
164 # through the current COMSPEC. cmd.exe suppress enclosing quotes. 164 # Python versions since 2.7.1 do this extra quoting themselves
165 return '"' + cmd + '"' 165 return '"' + cmd + '"'
166 return cmd
166 167
167 def popen(command, mode='r'): 168 def popen(command, mode='r'):
168 # Work around "popen spawned process may not write to stdout 169 # Work around "popen spawned process may not write to stdout
169 # under windows" 170 # under windows"
170 # http://bugs.python.org/issue1366 171 # http://bugs.python.org/issue1366