diff --git a/mercurial/upgrade_utils/engine.py b/mercurial/upgrade_utils/engine.py --- a/mercurial/upgrade_utils/engine.py +++ b/mercurial/upgrade_utils/engine.py @@ -412,7 +412,35 @@ """ # TODO: don't blindly rename everything in store # There can be upgrades where store is not touched at all - util.rename(currentrepo.spath, backupvfs.join(b'store')) + backupstorevfs = vfsmod.vfs(backupvfs.join(b'store')) + util.makedirs(backupstorevfs.base) + for path, kind, st in sorted(currentrepo.store.vfs.readdir(b'', stat=True)): + # Skip transaction related files. + if path.startswith(b'undo'): + continue + # Only copy regular files. + if kind != stat.S_IFREG: + continue + # Skip other skipped files. + if path in (b'lock',): + continue + src = currentrepo.store.rawvfs.join(path) + dst = backupstorevfs.join(path) + util.copyfile(src, dst, copystat=True) + if currentrepo.svfs.exists(b'data'): + util.copyfiles( + currentrepo.svfs.join(b'data'), + backupstorevfs.join(b'data'), + hardlink=False, + ) + if currentrepo.svfs.exists(b'meta'): + util.copyfiles( + currentrepo.svfs.join(b'meta'), + backupstorevfs.join(b'meta'), + hardlink=False, + ) + + currentrepo.vfs.rmtree(b'store', forcibly=True) util.rename(upgradedrepo.spath, currentrepo.spath) @@ -512,10 +540,4 @@ ) scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements) - # The lock file from the old store won't be removed because nothing has a - # reference to its new location. So clean it up manually. Alternatively, we - # could update srcrepo.svfs and other variables to point to the new - # location. This is simpler. - backupvfs.unlink(b'store/lock') - return backuppath diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t --- a/tests/test-upgrade-repo.t +++ b/tests/test-upgrade-repo.t @@ -592,10 +592,6 @@ data fncache phaseroots - undo - undo.backup.fncache - undo.backupfiles - undo.phaseroots unless --no-backup is passed