mercurial/hg.py
changeset 3100 09e8aecd8016
parent 3069 bc3fe3b5b785
child 3188 705e30c0a230
equal deleted inserted replaced
3099:c27d1e1798a3 3100:09e8aecd8016
   113 
   113 
   114     dest = localpath(dest)
   114     dest = localpath(dest)
   115     source = localpath(source)
   115     source = localpath(source)
   116 
   116 
   117     if os.path.exists(dest):
   117     if os.path.exists(dest):
   118         raise util.Abort(_("destination '%s' already exists"), dest)
   118         raise util.Abort(_("destination '%s' already exists") % dest)
   119 
   119 
   120     class DirCleanup(object):
   120     class DirCleanup(object):
   121         def __init__(self, dir_):
   121         def __init__(self, dir_):
   122             self.rmtree = shutil.rmtree
   122             self.rmtree = shutil.rmtree
   123             self.dir_ = dir_
   123             self.dir_ = dir_
   125             self.dir_ = None
   125             self.dir_ = None
   126         def __del__(self):
   126         def __del__(self):
   127             if self.dir_:
   127             if self.dir_:
   128                 self.rmtree(self.dir_, True)
   128                 self.rmtree(self.dir_, True)
   129 
   129 
   130     dest_repo = None
   130     dest_repo = repository(ui, dest, create=True)
   131     try:
       
   132         dest_repo = repository(ui, dest)
       
   133         raise util.Abort(_("destination '%s' already exists." % dest))
       
   134     except RepoError:
       
   135         dest_repo = repository(ui, dest, create=True)
       
   136 
   131 
   137     dest_path = None
   132     dest_path = None
   138     dir_cleanup = None
   133     dir_cleanup = None
   139     if dest_repo.local():
   134     if dest_repo.local():
   140         dest_path = os.path.realpath(dest_repo.root)
   135         dest_path = os.path.realpath(dest_repo.root)