mercurial/windows.py
changeset 36415 0cb09c322647
parent 35513 c4caf530b1c7
child 36457 0e8b76644e20
equal deleted inserted replaced
36414:44c4a38bf563 36415:0cb09c322647
   294     if s and not _needsshellquote(s) and not _quotere.search(s):
   294     if s and not _needsshellquote(s) and not _quotere.search(s):
   295         # "s" shouldn't have to be quoted
   295         # "s" shouldn't have to be quoted
   296         return s
   296         return s
   297     return '"%s"' % _quotere.sub(r'\1\1\\\2', s)
   297     return '"%s"' % _quotere.sub(r'\1\1\\\2', s)
   298 
   298 
       
   299 def _unquote(s):
       
   300     if s.startswith(b'"') and s.endswith(b'"'):
       
   301         return s[1:-1]
       
   302     return s
       
   303 
       
   304 def shellsplit(s):
       
   305     """Parse a command string in cmd.exe way (best-effort)"""
       
   306     return pycompat.maplist(_unquote, pycompat.shlexsplit(s, posix=False))
       
   307 
   299 def quotecommand(cmd):
   308 def quotecommand(cmd):
   300     """Build a command string suitable for os.popen* calls."""
   309     """Build a command string suitable for os.popen* calls."""
   301     if sys.version_info < (2, 7, 1):
   310     if sys.version_info < (2, 7, 1):
   302         # Python versions since 2.7.1 do this extra quoting themselves
   311         # Python versions since 2.7.1 do this extra quoting themselves
   303         return '"' + cmd + '"'
   312         return '"' + cmd + '"'