mercurial/hg.py
changeset 31218 4cc3797aa59c
parent 31168 41a9edc5d00f
child 31311 f59b6cf663a9
equal deleted inserted replaced
31217:0f31830fbfc4 31218:4cc3797aa59c
    38     ui as uimod,
    38     ui as uimod,
    39     unionrepo,
    39     unionrepo,
    40     url,
    40     url,
    41     util,
    41     util,
    42     verify as verifymod,
    42     verify as verifymod,
       
    43     vfs as vfsmod,
    43 )
    44 )
    44 
    45 
    45 release = lock.release
    46 release = lock.release
    46 
    47 
    47 # shared features
    48 # shared features
   217         origsource = source = srcrepo.url()
   218         origsource = source = srcrepo.url()
   218         checkout = None
   219         checkout = None
   219 
   220 
   220     sharedpath = srcrepo.sharedpath # if our source is already sharing
   221     sharedpath = srcrepo.sharedpath # if our source is already sharing
   221 
   222 
   222     destwvfs = scmutil.vfs(dest, realpath=True)
   223     destwvfs = vfsmod.vfs(dest, realpath=True)
   223     destvfs = scmutil.vfs(os.path.join(destwvfs.base, '.hg'), realpath=True)
   224     destvfs = vfsmod.vfs(os.path.join(destwvfs.base, '.hg'), realpath=True)
   224 
   225 
   225     if destvfs.lexists():
   226     if destvfs.lexists():
   226         raise error.Abort(_('destination already exists'))
   227         raise error.Abort(_('destination already exists'))
   227 
   228 
   228     if not destwvfs.isdir():
   229     if not destwvfs.isdir():
   310             if pos is None:
   311             if pos is None:
   311                 closetopic[0] = topic
   312                 closetopic[0] = topic
   312             else:
   313             else:
   313                 ui.progress(topic, pos + num)
   314                 ui.progress(topic, pos + num)
   314         srcpublishing = srcrepo.publishing()
   315         srcpublishing = srcrepo.publishing()
   315         srcvfs = scmutil.vfs(srcrepo.sharedpath)
   316         srcvfs = vfsmod.vfs(srcrepo.sharedpath)
   316         dstvfs = scmutil.vfs(destpath)
   317         dstvfs = vfsmod.vfs(destpath)
   317         for f in srcrepo.store.copylist():
   318         for f in srcrepo.store.copylist():
   318             if srcpublishing and f.endswith('phaseroots'):
   319             if srcpublishing and f.endswith('phaseroots'):
   319                 continue
   320                 continue
   320             dstbase = os.path.dirname(f)
   321             dstbase = os.path.dirname(f)
   321             if dstbase and not dstvfs.exists(dstbase):
   322             if dstbase and not dstvfs.exists(dstbase):
   367         util.makedir(pooldir, False)
   368         util.makedir(pooldir, False)
   368     except OSError as e:
   369     except OSError as e:
   369         if e.errno != errno.EEXIST:
   370         if e.errno != errno.EEXIST:
   370             raise
   371             raise
   371 
   372 
   372     poolvfs = scmutil.vfs(pooldir)
   373     poolvfs = vfsmod.vfs(pooldir)
   373     basename = os.path.basename(sharepath)
   374     basename = os.path.basename(sharepath)
   374 
   375 
   375     with lock.lock(poolvfs, '%s.lock' % basename):
   376     with lock.lock(poolvfs, '%s.lock' % basename):
   376         if os.path.exists(sharepath):
   377         if os.path.exists(sharepath):
   377             ui.status(_('(sharing from existing pooled repository %s)\n') %
   378             ui.status(_('(sharing from existing pooled repository %s)\n') %
   472     source = util.urllocalpath(source)
   473     source = util.urllocalpath(source)
   473 
   474 
   474     if not dest:
   475     if not dest:
   475         raise error.Abort(_("empty destination path is not valid"))
   476         raise error.Abort(_("empty destination path is not valid"))
   476 
   477 
   477     destvfs = scmutil.vfs(dest, expandpath=True)
   478     destvfs = vfsmod.vfs(dest, expandpath=True)
   478     if destvfs.lexists():
   479     if destvfs.lexists():
   479         if not destvfs.isdir():
   480         if not destvfs.isdir():
   480             raise error.Abort(_("destination '%s' already exists") % dest)
   481             raise error.Abort(_("destination '%s' already exists") % dest)
   481         elif destvfs.listdir():
   482         elif destvfs.listdir():
   482             raise error.Abort(_("destination '%s' is not empty") % dest)
   483             raise error.Abort(_("destination '%s' is not empty") % dest)