mercurial/util.py
changeset 4087 587c6c652f82
parent 4086 cc8a52229620
child 4096 49237d6ae97d
child 4129 e817c68edfed
equal deleted inserted replaced
4086:cc8a52229620 4087:587c6c652f82
   796     readlock = _readlock_file
   796     readlock = _readlock_file
   797 
   797 
   798     def samestat(s1, s2):
   798     def samestat(s1, s2):
   799         return False
   799         return False
   800 
   800 
       
   801     # A sequence of backslashes is special iff it precedes a double quote:
       
   802     # - if there's an even number of backslashes, the double quote is not
       
   803     #   quoted (i.e. it ends the quoted region)
       
   804     # - if there's an odd number of backslashes, the double quote is quoted
       
   805     # - in both cases, every pair of backslashes is unquoted into a single
       
   806     #   backslash
       
   807     # (See http://msdn2.microsoft.com/en-us/library/a1y7w461.aspx )
       
   808     # So, to quote a string, we must surround it in double quotes, double
       
   809     # the number of backslashes that preceed double quotes and add another
       
   810     # backslash before every double quote (being careful with the double
       
   811     # quote we've appended to the end)
       
   812     _quotere = None
   801     def shellquote(s):
   813     def shellquote(s):
   802         return '"%s"' % s.replace('"', '\\"')
   814         global _quotere
       
   815         if _quotere is None:
       
   816             _quotere = re.compile(r'(\\*)("|\\$)')
       
   817         return '"%s"' % _quotere.sub(r'\1\1\\\2', s)
   803 
   818 
   804     def explain_exit(code):
   819     def explain_exit(code):
   805         return _("exited with status %d") % code, code
   820         return _("exited with status %d") % code, code
   806 
   821 
   807     # if you change this stub into a real check, please try to implement the
   822     # if you change this stub into a real check, please try to implement the