mercurial/streamclone.py
changeset 49190 4ff4e23de7df
parent 48946 642e31cb55f0
child 49284 d44e3c45f0e4
equal deleted inserted replaced
49189:237855525f64 49190:4ff4e23de7df
   556 
   556 
   557 
   557 
   558 @contextlib.contextmanager
   558 @contextlib.contextmanager
   559 def maketempcopies():
   559 def maketempcopies():
   560     """return a function to temporary copy file"""
   560     """return a function to temporary copy file"""
       
   561 
   561     files = []
   562     files = []
       
   563     dst_dir = pycompat.mkdtemp(prefix=b'hg-clone-')
   562     try:
   564     try:
   563 
   565 
   564         def copy(src):
   566         def copy(src):
   565             fd, dst = pycompat.mkstemp()
   567             fd, dst = pycompat.mkstemp(
       
   568                 prefix=os.path.basename(src), dir=dst_dir
       
   569             )
   566             os.close(fd)
   570             os.close(fd)
   567             files.append(dst)
   571             files.append(dst)
   568             util.copyfiles(src, dst, hardlink=True)
   572             util.copyfiles(src, dst, hardlink=True)
   569             return dst
   573             return dst
   570 
   574 
   571         yield copy
   575         yield copy
   572     finally:
   576     finally:
   573         for tmp in files:
   577         for tmp in files:
   574             util.tryunlink(tmp)
   578             util.tryunlink(tmp)
       
   579         util.tryrmdir(dst_dir)
   575 
   580 
   576 
   581 
   577 def _makemap(repo):
   582 def _makemap(repo):
   578     """make a (src -> vfs) map for the repo"""
   583     """make a (src -> vfs) map for the repo"""
   579     vfsmap = {
   584     vfsmap = {