mercurial/windows.py
branchstable
changeset 24885 eea3977e6fca
parent 24692 144883a8d0d4
child 24908 30b910fea244
equal deleted inserted replaced
24884:d7778b88838c 24885:eea3977e6fca
   165     global _quotere
   165     global _quotere
   166     if _quotere is None:
   166     if _quotere is None:
   167         _quotere = re.compile(r'(\\*)("|\\$)')
   167         _quotere = re.compile(r'(\\*)("|\\$)')
   168     global _needsshellquote
   168     global _needsshellquote
   169     if _needsshellquote is None:
   169     if _needsshellquote is None:
   170         # ":" and "\\" are also treated as "safe character", because
   170         # ":" is also treated as "safe character", because it is used as a part
   171         # they are used as a part of path name (and the latter doesn't
   171         # of path name on Windows.  "\" is also part of a path name, but isn't
   172         # work as "escape character", like one on posix) on Windows
   172         # safe because shlex.split() (kind of) treats it as an escape char and
   173         _needsshellquote = re.compile(r'[^a-zA-Z0-9._:/\\-]').search
   173         # drops it.  It will leave the next character, even if it is another
       
   174         # "\".
       
   175         _needsshellquote = re.compile(r'[^a-zA-Z0-9._:/-]').search
   174     if s and not _needsshellquote(s) and not _quotere.search(s):
   176     if s and not _needsshellquote(s) and not _quotere.search(s):
   175         # "s" shouldn't have to be quoted
   177         # "s" shouldn't have to be quoted
   176         return s
   178         return s
   177     return '"%s"' % _quotere.sub(r'\1\1\\\2', s)
   179     return '"%s"' % _quotere.sub(r'\1\1\\\2', s)
   178 
   180