mercurial/hg.py
changeset 49305 53e9422a9b45
parent 49301 c463f45fa114
child 49684 1e6c37360527
child 49775 7d6c8943353a
equal deleted inserted replaced
49304:48f1b314056b 49305:53e9422a9b45
     5 #
     5 #
     6 # This software may be used and distributed according to the terms of the
     6 # This software may be used and distributed according to the terms of the
     7 # GNU General Public License version 2 or any later version.
     7 # GNU General Public License version 2 or any later version.
     8 
     8 
     9 
     9 
    10 import errno
       
    11 import os
    10 import os
    12 import posixpath
    11 import posixpath
    13 import shutil
    12 import shutil
    14 import stat
    13 import stat
    15 import weakref
    14 import weakref
   526     # 2 clients may race creating or populating it.
   525     # 2 clients may race creating or populating it.
   527     pooldir = os.path.dirname(sharepath)
   526     pooldir = os.path.dirname(sharepath)
   528     # lock class requires the directory to exist.
   527     # lock class requires the directory to exist.
   529     try:
   528     try:
   530         util.makedir(pooldir, False)
   529         util.makedir(pooldir, False)
   531     except OSError as e:
   530     except FileExistsError:
   532         if e.errno != errno.EEXIST:
   531         pass
   533             raise
       
   534 
   532 
   535     poolvfs = vfsmod.vfs(pooldir)
   533     poolvfs = vfsmod.vfs(pooldir)
   536     basename = os.path.basename(sharepath)
   534     basename = os.path.basename(sharepath)
   537 
   535 
   538     with lock.lock(poolvfs, b'%s.lock' % basename):
   536     with lock.lock(poolvfs, b'%s.lock' % basename):
   891                     peeropts,
   889                     peeropts,
   892                     dest,
   890                     dest,
   893                     create=True,
   891                     create=True,
   894                     createopts=createopts,
   892                     createopts=createopts,
   895                 )
   893                 )
   896             except OSError as inst:
   894             except FileExistsError:
   897                 if inst.errno == errno.EEXIST:
   895                 cleandir = None
   898                     cleandir = None
   896                 raise error.Abort(_(b"destination '%s' already exists") % dest)
   899                     raise error.Abort(
       
   900                         _(b"destination '%s' already exists") % dest
       
   901                     )
       
   902                 raise
       
   903 
   897 
   904             if revs:
   898             if revs:
   905                 if not srcpeer.capable(b'lookup'):
   899                 if not srcpeer.capable(b'lookup'):
   906                     raise error.Abort(
   900                     raise error.Abort(
   907                         _(
   901                         _(