##// END OF EJS Templates
util: unify unlinkpath...
Ryan McElroy -
r31539:52361c4f default
parent child Browse files
Show More
@@ -536,19 +536,6 b' def gethgcmd():'
536 def makedir(path, notindexed):
536 def makedir(path, notindexed):
537 os.mkdir(path)
537 os.mkdir(path)
538
538
539 def unlinkpath(f, ignoremissing=False):
540 """unlink and remove the directory if it is empty"""
541 try:
542 unlink(f)
543 except OSError as e:
544 if not (ignoremissing and e.errno == errno.ENOENT):
545 raise
546 # try removing directories that might now be empty
547 try:
548 removedirs(os.path.dirname(f))
549 except OSError:
550 pass
551
552 def lookupreg(key, name=None, scope=None):
539 def lookupreg(key, name=None, scope=None):
553 return None
540 return None
554
541
@@ -136,7 +136,6 b' statislink = platform.statislink'
136 testpid = platform.testpid
136 testpid = platform.testpid
137 umask = platform.umask
137 umask = platform.umask
138 unlink = platform.unlink
138 unlink = platform.unlink
139 unlinkpath = platform.unlinkpath
140 username = platform.username
139 username = platform.username
141
140
142 # Python compatibility
141 # Python compatibility
@@ -1605,6 +1604,19 b' class atomictempfile(object):'
1605 else:
1604 else:
1606 self.close()
1605 self.close()
1607
1606
1607 def unlinkpath(f, ignoremissing=False):
1608 """unlink and remove the directory if it is empty"""
1609 try:
1610 unlink(f)
1611 except OSError as e:
1612 if not (ignoremissing and e.errno == errno.ENOENT):
1613 raise
1614 # try removing directories that might now be empty
1615 try:
1616 removedirs(os.path.dirname(f))
1617 except OSError:
1618 pass
1619
1608 def makedirs(name, mode=None, notindexed=False):
1620 def makedirs(name, mode=None, notindexed=False):
1609 """recursive directory creation with parent mode inheritance
1621 """recursive directory creation with parent mode inheritance
1610
1622
@@ -385,19 +385,6 b' def removedirs(name):'
385 break
385 break
386 head, tail = os.path.split(head)
386 head, tail = os.path.split(head)
387
387
388 def unlinkpath(f, ignoremissing=False):
389 """unlink and remove the directory if it is empty"""
390 try:
391 unlink(f)
392 except OSError as e:
393 if not (ignoremissing and e.errno == errno.ENOENT):
394 raise
395 # try removing directories that might now be empty
396 try:
397 removedirs(os.path.dirname(f))
398 except OSError:
399 pass
400
401 def rename(src, dst):
388 def rename(src, dst):
402 '''atomically rename file src to dst, replacing dst if it exists'''
389 '''atomically rename file src to dst, replacing dst if it exists'''
403 try:
390 try:
General Comments 0
You need to be logged in to leave comments. Login now