mercurial/hg.py
changeset 49305 53e9422a9b45
parent 49301 c463f45fa114
child 49684 1e6c37360527
child 49775 7d6c8943353a
--- a/mercurial/hg.py	Tue May 31 16:54:58 2022 +0200
+++ b/mercurial/hg.py	Tue May 31 21:16:17 2022 +0200
@@ -7,7 +7,6 @@
 # GNU General Public License version 2 or any later version.
 
 
-import errno
 import os
 import posixpath
 import shutil
@@ -528,9 +527,8 @@
     # lock class requires the directory to exist.
     try:
         util.makedir(pooldir, False)
-    except OSError as e:
-        if e.errno != errno.EEXIST:
-            raise
+    except FileExistsError:
+        pass
 
     poolvfs = vfsmod.vfs(pooldir)
     basename = os.path.basename(sharepath)
@@ -893,13 +891,9 @@
                     create=True,
                     createopts=createopts,
                 )
-            except OSError as inst:
-                if inst.errno == errno.EEXIST:
-                    cleandir = None
-                    raise error.Abort(
-                        _(b"destination '%s' already exists") % dest
-                    )
-                raise
+            except FileExistsError:
+                cleandir = None
+                raise error.Abort(_(b"destination '%s' already exists") % dest)
 
             if revs:
                 if not srcpeer.capable(b'lookup'):