Mercurial > public > mercurial-scm > hg
comparison mercurial/posix.py @ 49307:6f2a57ba2d13
py3: catch PermissionError instead of checking errno == EACCES
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Tue, 31 May 2022 23:38:51 +0200 |
parents | 2e726c934fcd |
children | 050dc8730858 |
comparison
equal
deleted
inserted
replaced
49306:2e726c934fcd | 49307:6f2a57ba2d13 |
---|---|
300 # already exists. | 300 # already exists. |
301 target = b'checklink-target' | 301 target = b'checklink-target' |
302 try: | 302 try: |
303 fullpath = os.path.join(cachedir, target) | 303 fullpath = os.path.join(cachedir, target) |
304 open(fullpath, b'w').close() | 304 open(fullpath, b'w').close() |
305 except IOError as inst: | 305 except PermissionError: |
306 # pytype: disable=unsupported-operands | 306 # If we can't write to cachedir, just pretend |
307 if inst[0] == errno.EACCES: | 307 # that the fs is readonly and by association |
308 # pytype: enable=unsupported-operands | 308 # that the fs won't support symlinks. This |
309 | 309 # seems like the least dangerous way to avoid |
310 # If we can't write to cachedir, just pretend | 310 # data loss. |
311 # that the fs is readonly and by association | 311 return False |
312 # that the fs won't support symlinks. This | |
313 # seems like the least dangerous way to avoid | |
314 # data loss. | |
315 return False | |
316 raise | |
317 try: | 312 try: |
318 os.symlink(target, name) | 313 os.symlink(target, name) |
319 if cachedir is None: | 314 if cachedir is None: |
320 unlink(name) | 315 unlink(name) |
321 else: | 316 else: |