Mercurial > hg
changeset 24692:144883a8d0d4
util: add removedirs as platform depending function
According to fa901423ac23 introducing "windows._removedirs()":
If a hg repository including working directory is a reparse point
(directory symlinked or a junction point), then using
os.removedirs will remove the reparse point erroneously.
"windows._removedirs()" should be used instead of "os.removedirs()" on
Windows.
This patch adds "removedirs" as platform depending function to replace
"os.removedirs()" invocations for portability and safety
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Sat, 11 Apr 2015 00:47:09 +0900 |
parents | def1145cec2d |
children | 0d28b0df77ea |
files | mercurial/posix.py mercurial/util.py mercurial/windows.py |
diffstat | 3 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/posix.py Sat Apr 11 00:47:09 2015 +0900 +++ b/mercurial/posix.py Sat Apr 11 00:47:09 2015 +0900 @@ -16,6 +16,7 @@ oslink = os.link unlink = os.unlink rename = os.rename +removedirs = os.removedirs expandglobs = False umask = os.umask(0)
--- a/mercurial/util.py Sat Apr 11 00:47:09 2015 +0900 +++ b/mercurial/util.py Sat Apr 11 00:47:09 2015 +0900 @@ -59,6 +59,7 @@ quotecommand = platform.quotecommand readpipe = platform.readpipe rename = platform.rename +removedirs = platform.removedirs samedevice = platform.samedevice samefile = platform.samefile samestat = platform.samestat
--- a/mercurial/windows.py Sat Apr 11 00:47:09 2015 +0900 +++ b/mercurial/windows.py Sat Apr 11 00:47:09 2015 +0900 @@ -270,7 +270,7 @@ If gid is None, return the name of the current group.""" return None -def _removedirs(name): +def removedirs(name): """special version of os.removedirs that does not remove symlinked directories or junction points if they actually contain files""" if osutil.listdir(name): @@ -297,7 +297,7 @@ raise # try removing directories that might now be empty try: - _removedirs(os.path.dirname(f)) + removedirs(os.path.dirname(f)) except OSError: pass