mercurial/hg.py
changeset 3791 8643b9f90b51
parent 3713 8ae88ed2a3b6
child 3841 aaeb7f5d1052
child 3849 972d14a5a227
equal deleted inserted replaced
3790:f183c18568df 3791:8643b9f90b51
   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 = repository(ui, dest, create=True)
   130     dest_repo = repository(ui, dest, create=True)
   131 
   131 
   132     dest_path = None
       
   133     dir_cleanup = None
   132     dir_cleanup = None
   134     if dest_repo.local():
   133     if dest_repo.local():
   135         dest_path = os.path.realpath(dest_repo.root)
   134         dir_cleanup = DirCleanup(os.path.realpath(dest_repo.root))
   136         dir_cleanup = DirCleanup(dest_path)
       
   137 
   135 
   138     abspath = source
   136     abspath = source
   139     copy = False
   137     copy = False
   140     if src_repo.local() and dest_repo.local():
   138     if src_repo.local() and dest_repo.local():
   141         abspath = os.path.abspath(source)
   139         abspath = os.path.abspath(source)
   152         except lock.LockException:
   150         except lock.LockException:
   153             copy = False
   151             copy = False
   154 
   152 
   155     if copy:
   153     if copy:
   156         # we lock here to avoid premature writing to the target
   154         # we lock here to avoid premature writing to the target
   157         dest_lock = lock.lock(os.path.join(dest_path, ".hg", "lock"))
   155         src_store = os.path.realpath(src_repo.spath)
       
   156         dest_store = os.path.realpath(dest_repo.spath)
       
   157         dest_lock = lock.lock(os.path.join(dest_store, "lock"))
   158 
   158 
   159         files = ("data",
   159         files = ("data",
   160                  "00manifest.d", "00manifest.i",
   160                  "00manifest.d", "00manifest.i",
   161                  "00changelog.d", "00changelog.i")
   161                  "00changelog.d", "00changelog.i")
   162         for f in files:
   162         for f in files:
   163             src = os.path.join(source, ".hg", f)
   163             src = os.path.join(src_store, f)
   164             dst = os.path.join(dest_path, ".hg", f)
   164             dst = os.path.join(dest_store, f)
   165             try:
   165             try:
   166                 util.copyfiles(src, dst)
   166                 util.copyfiles(src, dst)
   167             except OSError, inst:
   167             except OSError, inst:
   168                 if inst.errno != errno.ENOENT:
   168                 if inst.errno != errno.ENOENT:
   169                     raise
   169                     raise