comparison mercurial/util.py @ 49316:d2adebe35635

py3: catch PermissionError instead of checking errno == EPERM
author Manuel Jacob <me@manueljacob.de>
date Tue, 31 May 2022 23:41:15 +0200
parents 2e726c934fcd
children c4f07a011714
comparison
equal deleted inserted replaced
49315:6f2a57ba2d13 49316:d2adebe35635
2501 Otherwise, this returns True, as "ambiguity is avoided". 2501 Otherwise, this returns True, as "ambiguity is avoided".
2502 """ 2502 """
2503 advanced = (old.stat[stat.ST_MTIME] + 1) & 0x7FFFFFFF 2503 advanced = (old.stat[stat.ST_MTIME] + 1) & 0x7FFFFFFF
2504 try: 2504 try:
2505 os.utime(path, (advanced, advanced)) 2505 os.utime(path, (advanced, advanced))
2506 except OSError as inst: 2506 except PermissionError:
2507 if inst.errno == errno.EPERM: 2507 # utime() on the file created by another user causes EPERM,
2508 # utime() on the file created by another user causes EPERM, 2508 # if a process doesn't have appropriate privileges
2509 # if a process doesn't have appropriate privileges 2509 return False
2510 return False
2511 raise
2512 return True 2510 return True
2513 2511
2514 def __ne__(self, other): 2512 def __ne__(self, other):
2515 return not self == other 2513 return not self == other
2516 2514