mercurial/upgrade.py
changeset 33438 8056481caa81
parent 32291 bd872f64a8ba
child 35302 ad2b35ebf670
equal deleted inserted replaced
33437:0720e6265c8a 33438:8056481caa81
   790     printupgradeactions()
   790     printupgradeactions()
   791 
   791 
   792     upgradeactions = [a.name for a in actions]
   792     upgradeactions = [a.name for a in actions]
   793 
   793 
   794     ui.write(_('beginning upgrade...\n'))
   794     ui.write(_('beginning upgrade...\n'))
   795     with repo.wlock():
   795     with repo.wlock(), repo.lock():
   796         with repo.lock():
   796         ui.write(_('repository locked and read-only\n'))
   797             ui.write(_('repository locked and read-only\n'))
   797         # Our strategy for upgrading the repository is to create a new,
   798             # Our strategy for upgrading the repository is to create a new,
   798         # temporary repository, write data to it, then do a swap of the
   799             # temporary repository, write data to it, then do a swap of the
   799         # data. There are less heavyweight ways to do this, but it is easier
   800             # data. There are less heavyweight ways to do this, but it is easier
   800         # to create a new repo object than to instantiate all the components
   801             # to create a new repo object than to instantiate all the components
   801         # (like the store) separately.
   802             # (like the store) separately.
   802         tmppath = tempfile.mkdtemp(prefix='upgrade.', dir=repo.path)
   803             tmppath = tempfile.mkdtemp(prefix='upgrade.', dir=repo.path)
   803         backuppath = None
   804             backuppath = None
   804         try:
   805             try:
   805             ui.write(_('creating temporary repository to stage migrated '
   806                 ui.write(_('creating temporary repository to stage migrated '
   806                        'data: %s\n') % tmppath)
   807                            'data: %s\n') % tmppath)
   807             dstrepo = localrepo.localrepository(repo.baseui,
   808                 dstrepo = localrepo.localrepository(repo.baseui,
   808                                                 path=tmppath,
   809                                                     path=tmppath,
   809                                                 create=True)
   810                                                     create=True)
   810 
   811 
   811             with dstrepo.wlock(), dstrepo.lock():
   812                 with dstrepo.wlock():
   812                 backuppath = _upgraderepo(ui, repo, dstrepo, newreqs,
   813                     with dstrepo.lock():
   813                                           upgradeactions)
   814                         backuppath = _upgraderepo(ui, repo, dstrepo, newreqs,
   814 
   815                                                   upgradeactions)
   815         finally:
   816 
   816             ui.write(_('removing temporary repository %s\n') % tmppath)
   817             finally:
   817             repo.vfs.rmtree(tmppath, forcibly=True)
   818                 ui.write(_('removing temporary repository %s\n') % tmppath)
   818 
   819                 repo.vfs.rmtree(tmppath, forcibly=True)
   819             if backuppath:
   820 
   820                 ui.warn(_('copy of old repository backed up at %s\n') %
   821                 if backuppath:
   821                         backuppath)
   822                     ui.warn(_('copy of old repository backed up at %s\n') %
   822                 ui.warn(_('the old repository will not be deleted; remove '
   823                             backuppath)
   823                           'it to free up disk space once the upgraded '
   824                     ui.warn(_('the old repository will not be deleted; remove '
   824                           'repository is verified\n'))
   825                               'it to free up disk space once the upgraded '
       
   826                               'repository is verified\n'))