mercurial/util.py
changeset 4096 49237d6ae97d
parent 4083 33c369afec94
parent 4087 587c6c652f82
child 4097 403c4ddd74bb
equal deleted inserted replaced
4085:719488a98ebe 4096:49237d6ae97d
   372             try:
   372             try:
   373                 name_st = os.stat(name)
   373                 name_st = os.stat(name)
   374             except OSError:
   374             except OSError:
   375                 break
   375                 break
   376             if samestat(name_st, root_st):
   376             if samestat(name_st, root_st):
       
   377                 if not rel:
       
   378                     # name was actually the same as root (maybe a symlink)
       
   379                     return ''
   377                 rel.reverse()
   380                 rel.reverse()
   378                 name = os.path.join(*rel)
   381                 name = os.path.join(*rel)
   379                 audit_path(name)
   382                 audit_path(name)
   380                 return pconvert(name)
   383                 return pconvert(name)
   381             dirname, basename = os.path.split(name)
   384             dirname, basename = os.path.split(name)
   844     readlock = _readlock_file
   847     readlock = _readlock_file
   845 
   848 
   846     def samestat(s1, s2):
   849     def samestat(s1, s2):
   847         return False
   850         return False
   848 
   851 
       
   852     # A sequence of backslashes is special iff it precedes a double quote:
       
   853     # - if there's an even number of backslashes, the double quote is not
       
   854     #   quoted (i.e. it ends the quoted region)
       
   855     # - if there's an odd number of backslashes, the double quote is quoted
       
   856     # - in both cases, every pair of backslashes is unquoted into a single
       
   857     #   backslash
       
   858     # (See http://msdn2.microsoft.com/en-us/library/a1y7w461.aspx )
       
   859     # So, to quote a string, we must surround it in double quotes, double
       
   860     # the number of backslashes that preceed double quotes and add another
       
   861     # backslash before every double quote (being careful with the double
       
   862     # quote we've appended to the end)
       
   863     _quotere = None
   849     def shellquote(s):
   864     def shellquote(s):
   850         return '"%s"' % s.replace('"', '\\"')
   865         global _quotere
       
   866         if _quotere is None:
       
   867             _quotere = re.compile(r'(\\*)("|\\$)')
       
   868         return '"%s"' % _quotere.sub(r'\1\1\\\2', s)
   851 
   869 
   852     def explain_exit(code):
   870     def explain_exit(code):
   853         return _("exited with status %d") % code, code
   871         return _("exited with status %d") % code, code
   854 
   872 
   855     # if you change this stub into a real check, please try to implement the
   873     # if you change this stub into a real check, please try to implement the