changeset 49308: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 6f2a57ba2d13
children d54b213c4380
files mercurial/util.py
diffstat 1 files changed, 4 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Tue May 31 23:38:51 2022 +0200
+++ b/mercurial/util.py	Tue May 31 23:41:15 2022 +0200
@@ -2503,12 +2503,10 @@
         advanced = (old.stat[stat.ST_MTIME] + 1) & 0x7FFFFFFF
         try:
             os.utime(path, (advanced, advanced))
-        except OSError as inst:
-            if inst.errno == errno.EPERM:
-                # utime() on the file created by another user causes EPERM,
-                # if a process doesn't have appropriate privileges
-                return False
-            raise
+        except PermissionError:
+            # utime() on the file created by another user causes EPERM,
+            # if a process doesn't have appropriate privileges
+            return False
         return True
 
     def __ne__(self, other):