mercurial/windows.py
changeset 8364 fa901423ac23
parent 8330 7de68012f86e
child 8421 b6d0fa8c7685
equal deleted inserted replaced
8363:c8e81f557da7 8364:fa901423ac23
   238     """Return the name of the group with the given gid.
   238     """Return the name of the group with the given gid.
   239 
   239 
   240     If gid is None, return the name of the current group."""
   240     If gid is None, return the name of the current group."""
   241     return None
   241     return None
   242 
   242 
       
   243 def _removedirs(name):
       
   244     """special version of os.removedirs that does not remove symlinked
       
   245     directories or junction points if they actually contain files"""
       
   246     if osutil.listdir(name):
       
   247         return
       
   248     os.rmdir(name)
       
   249     head, tail = os.path.split(name)
       
   250     if not tail:
       
   251         head, tail = os.path.split(head)
       
   252     while head and tail:
       
   253         try:
       
   254             if osutil.listdir(name):
       
   255                 return
       
   256             os.rmdir(head)
       
   257         except:
       
   258             break
       
   259         head, tail = os.path.split(head)
       
   260 
       
   261 def unlink(f):
       
   262     """unlink and remove the directory if it is empty"""
       
   263     os.unlink(f)
       
   264     # try removing directories that might now be empty
       
   265     try:
       
   266         _removedirs(os.path.dirname(f))
       
   267     except OSError:
       
   268         pass
       
   269 
   243 try:
   270 try:
   244     # override functions with win32 versions if possible
   271     # override functions with win32 versions if possible
   245     from win32 import *
   272     from win32 import *
   246     if not _is_win_9x():
   273     if not _is_win_9x():
   247         posixfile = posixfile_nt
   274         posixfile = posixfile_nt