##// END OF EJS Templates
clone: use better names for temp files...
Arseniy Alekseyev -
r50085:4ff4e23d default
parent child Browse files
Show More
@@ -558,11 +558,15 b' def _filterfull(entry, copy, vfsmap):'
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)
@@ -572,6 +576,7 b' def maketempcopies():'
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):
@@ -2592,6 +2592,14 b' class atomictempfile:'
2592 self.close()
2592 self.close()
2593
2593
2594
2594
2595 def tryrmdir(f):
2596 try:
2597 removedirs(f)
2598 except OSError as e:
2599 if e.errno != errno.ENOENT and e.errno != errno.ENOTEMPTY:
2600 raise
2601
2602
2595 def unlinkpath(f, ignoremissing=False, rmdir=True):
2603 def unlinkpath(f, ignoremissing=False, rmdir=True):
2596 # type: (bytes, bool, bool) -> None
2604 # type: (bytes, bool, bool) -> None
2597 """unlink and remove the directory if it is empty"""
2605 """unlink and remove the directory if it is empty"""
General Comments 0
You need to be logged in to leave comments. Login now