@@ -10,10 +10,11 @@ import errno
import os
import re
import shutil
-import tempfile
+
from mercurial.i18n import _
from mercurial import (
error,
+ pycompat,
util,
)
from mercurial.utils import dateutil
@@ -76,7 +77,7 @@ class darcs_source(common.converter_sour
self.ui.warn(_('failed to detect repository format!'))
def before(self):
- self.tmppath = tempfile.mkdtemp(
+ self.tmppath = pycompat.mkdtemp(
prefix='convert-' + os.path.basename(self.path) + '-')
output, status = self.run('init', repodir=self.tmppath)
self.checkexit(status)
@@ -71,7 +71,7 @@ import os
import re
import shutil
import stat
-import tempfile
+
from mercurial.i18n import _
from mercurial.node import (
nullid,
@@ -210,7 +210,7 @@ def dodiff(ui, repo, cmdline, pats, opts
if not common:
return 0
- tmproot = tempfile.mkdtemp(prefix='extdiff.')
+ tmproot = pycompat.mkdtemp(prefix='extdiff.')
try:
if not opts.get('patch'):
# Always make a copy of node1a (and node1b, if applicable)
@@ -87,7 +87,6 @@ from __future__ import absolute_import
import os
import re
-import tempfile
import weakref
from mercurial.i18n import _
@@ -434,7 +433,7 @@ def demo(ui, repo, *args, **opts):
ui.write('%s = %s\n' % (k, v))
fn = 'demo.txt'
- tmpdir = tempfile.mkdtemp('', 'kwdemo.')
+ tmpdir = pycompat.mkdtemp('', 'kwdemo.')
ui.note(_('creating temporary repository at %s\n') % tmpdir)
if repo is None:
baseui = ui
@@ -79,7 +79,6 @@ import email.utils as eutil
import errno
import os
import socket
-import tempfile
from mercurial.i18n import _
from mercurial import (
@@ -317,7 +316,7 @@ def _getbundle(repo, dest, **opts):
The bundle is a returned as a single in-memory binary blob.
"""
ui = repo.ui
- tmpdir = tempfile.mkdtemp(prefix='hg-email-bundle-')
+ tmpdir = pycompat.mkdtemp(prefix='hg-email-bundle-')
tmpfn = os.path.join(tmpdir, 'bundle')
btype = ui.config('patchbomb', 'bundletype')
if btype:
@@ -15,7 +15,6 @@ from __future__ import absolute_import
import os
import shutil
-import tempfile
from .i18n import _
from .node import nullid
@@ -270,7 +269,7 @@ class bundlerepository(localrepo.localre
try:
localrepo.localrepository.__init__(self, ui, repopath)
except error.RepoError:
- self._tempparent = tempfile.mkdtemp()
+ self._tempparent = pycompat.mkdtemp()
localrepo.instance(ui, self._tempparent, 1)
localrepo.localrepository.__init__(self, ui, self._tempparent)
self.ui.setconfig('phases', 'publish', False, 'bundlerepo')
@@ -11,7 +11,6 @@ import contextlib
import os
import re
import shutil
-import tempfile
from .i18n import _
from .node import nullid, short
@@ -713,7 +712,7 @@ def _maketempfiles(repo, fco, fca, local
tmproot = None
tmprootprefix = repo.ui.config('experimental', 'mergetempdirprefix')
if tmprootprefix:
- tmproot = tempfile.mkdtemp(prefix=tmprootprefix)
+ tmproot = pycompat.mkdtemp(prefix=tmprootprefix)
def maketempfrompath(prefix, path):
fullbase, ext = os.path.splitext(path)
@@ -18,7 +18,6 @@ import os
import posixpath
import re
import shutil
-import tempfile
import zlib
from .i18n import _
@@ -573,7 +572,7 @@ class filestore(object):
self.size += len(data)
else:
if self.opener is None:
- root = tempfile.mkdtemp(prefix='hg-patch-')
+ root = pycompat.mkdtemp(prefix='hg-patch-')
self.opener = vfsmod.vfs(root)
# Avoid filename issues with these simple names
fn = '%d' % self.created
@@ -386,6 +386,9 @@ def getoptb(args, shortlist, namelist):
def gnugetoptb(args, shortlist, namelist):
return _getoptbwrapper(getopt.gnu_getopt, args, shortlist, namelist)
+def mkdtemp(suffix=b'', prefix=b'tmp', dir=None):
+ return tempfile.mkdtemp(suffix, prefix, dir)
+
# text=True is not supported; use util.from/tonativeeol() instead
def mkstemp(suffix=b'', prefix=b'tmp', dir=None):
return tempfile.mkstemp(suffix, prefix, dir)
@@ -8,7 +8,6 @@
from __future__ import absolute_import
import stat
-import tempfile
from .i18n import _
from . import (
@@ -18,6 +17,7 @@ from . import (
hg,
localrepo,
manifest,
+ pycompat,
revlog,
scmutil,
util,
@@ -657,7 +657,7 @@ def _upgraderepo(ui, srcrepo, dstrepo, r
ui.write(_('data fully migrated to temporary repository\n'))
- backuppath = tempfile.mkdtemp(prefix='upgradebackup.', dir=srcrepo.path)
+ backuppath = pycompat.mkdtemp(prefix='upgradebackup.', dir=srcrepo.path)
backupvfs = vfsmod.vfs(backuppath)
# Make a backup of requires file first, as it is the first to be modified.
@@ -842,7 +842,7 @@ def upgraderepo(ui, repo, run=False, opt
# data. There are less heavyweight ways to do this, but it is easier
# to create a new repo object than to instantiate all the components
# (like the store) separately.
- tmppath = tempfile.mkdtemp(prefix='upgrade.', dir=repo.path)
+ tmppath = pycompat.mkdtemp(prefix='upgrade.', dir=repo.path)
backuppath = None
try:
ui.write(_('creating temporary repository to stage migrated '