Mercurial > public > mercurial-scm > hg-stable
diff mercurial/streamclone.py @ 49222:4ff4e23de7df
clone: use better names for temp files
Before this commit, the file names are /tmp/tmpn8smvlr8
After this commit, they are more like /tmp/hg-clone-n8smvlr8/00manifest.ndb3qj52v6,
which makes it much clearer what these files correspond to.
Differential Revision: https://phab.mercurial-scm.org/D12623
author | Arseniy Alekseyev <aalekseyev@janestreet.com> |
---|---|
date | Tue, 10 May 2022 20:30:26 +0100 |
parents | 642e31cb55f0 |
children | d44e3c45f0e4 |
line wrap: on
line diff
--- a/mercurial/streamclone.py Mon May 02 16:27:14 2022 +0400 +++ b/mercurial/streamclone.py Tue May 10 20:30:26 2022 +0100 @@ -558,11 +558,15 @@ @contextlib.contextmanager def maketempcopies(): """return a function to temporary copy file""" + files = [] + dst_dir = pycompat.mkdtemp(prefix=b'hg-clone-') try: def copy(src): - fd, dst = pycompat.mkstemp() + fd, dst = pycompat.mkstemp( + prefix=os.path.basename(src), dir=dst_dir + ) os.close(fd) files.append(dst) util.copyfiles(src, dst, hardlink=True) @@ -572,6 +576,7 @@ finally: for tmp in files: util.tryunlink(tmp) + util.tryrmdir(dst_dir) def _makemap(repo):