Mercurial > hg
changeset 31541:bd9daafbf87c
util: use tryunlink in unlinkpath
We just introduced a func to attempt a file removal. Start using it.
author | Ryan McElroy <rmcelroy@fb.com> |
---|---|
date | Tue, 21 Mar 2017 06:50:28 -0700 |
parents | 6d5b77abf306 |
children | fad440db3565 |
files | mercurial/util.py |
diffstat | 1 files changed, 3 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/util.py Tue Mar 21 06:50:28 2017 -0700 +++ b/mercurial/util.py Tue Mar 21 06:50:28 2017 -0700 @@ -1606,11 +1606,10 @@ def unlinkpath(f, ignoremissing=False): """unlink and remove the directory if it is empty""" - try: + if ignoremissing: + tryunlink(f) + else: unlink(f) - except OSError as e: - if not (ignoremissing and e.errno == errno.ENOENT): - raise # try removing directories that might now be empty try: removedirs(os.path.dirname(f))