comparison mercurial/upgrade.py @ 38165:2ce60954b1b7

py3: wrap tempfile.mkdtemp() to use bytes path This also flips the default to use a bytes path on Python 3.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 26 May 2018 12:20:36 +0900
parents c8666a9e9e11
children f273b768b60f
comparison
equal deleted inserted replaced
38164:aac4be30e250 38165:2ce60954b1b7
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 from __future__ import absolute_import 8 from __future__ import absolute_import
9 9
10 import stat 10 import stat
11 import tempfile
12 11
13 from .i18n import _ 12 from .i18n import _
14 from . import ( 13 from . import (
15 changelog, 14 changelog,
16 error, 15 error,
17 filelog, 16 filelog,
18 hg, 17 hg,
19 localrepo, 18 localrepo,
20 manifest, 19 manifest,
20 pycompat,
21 revlog, 21 revlog,
22 scmutil, 22 scmutil,
23 util, 23 util,
24 vfs as vfsmod, 24 vfs as vfsmod,
25 ) 25 )
655 655
656 _finishdatamigration(ui, srcrepo, dstrepo, requirements) 656 _finishdatamigration(ui, srcrepo, dstrepo, requirements)
657 657
658 ui.write(_('data fully migrated to temporary repository\n')) 658 ui.write(_('data fully migrated to temporary repository\n'))
659 659
660 backuppath = tempfile.mkdtemp(prefix='upgradebackup.', dir=srcrepo.path) 660 backuppath = pycompat.mkdtemp(prefix='upgradebackup.', dir=srcrepo.path)
661 backupvfs = vfsmod.vfs(backuppath) 661 backupvfs = vfsmod.vfs(backuppath)
662 662
663 # Make a backup of requires file first, as it is the first to be modified. 663 # Make a backup of requires file first, as it is the first to be modified.
664 util.copyfile(srcrepo.vfs.join('requires'), backupvfs.join('requires')) 664 util.copyfile(srcrepo.vfs.join('requires'), backupvfs.join('requires'))
665 665
840 # Our strategy for upgrading the repository is to create a new, 840 # Our strategy for upgrading the repository is to create a new,
841 # temporary repository, write data to it, then do a swap of the 841 # temporary repository, write data to it, then do a swap of the
842 # data. There are less heavyweight ways to do this, but it is easier 842 # data. There are less heavyweight ways to do this, but it is easier
843 # to create a new repo object than to instantiate all the components 843 # to create a new repo object than to instantiate all the components
844 # (like the store) separately. 844 # (like the store) separately.
845 tmppath = tempfile.mkdtemp(prefix='upgrade.', dir=repo.path) 845 tmppath = pycompat.mkdtemp(prefix='upgrade.', dir=repo.path)
846 backuppath = None 846 backuppath = None
847 try: 847 try:
848 ui.write(_('creating temporary repository to stage migrated ' 848 ui.write(_('creating temporary repository to stage migrated '
849 'data: %s\n') % tmppath) 849 'data: %s\n') % tmppath)
850 850