447 b'(it is safe to interrupt this process any time before ' |
447 b'(it is safe to interrupt this process any time before ' |
448 b'data migration completes)\n' |
448 b'data migration completes)\n' |
449 ) |
449 ) |
450 ) |
450 ) |
451 |
451 |
452 with dstrepo.transaction(b'upgrade') as tr: |
452 if True: |
453 _clonerevlogs( |
453 with dstrepo.transaction(b'upgrade') as tr: |
454 ui, |
454 _clonerevlogs( |
455 srcrepo, |
455 ui, |
456 dstrepo, |
456 srcrepo, |
457 tr, |
457 dstrepo, |
458 upgrade_op, |
458 tr, |
459 ) |
459 upgrade_op, |
460 |
460 ) |
461 # Now copy other files in the store directory. |
461 |
462 for p in _files_to_copy_post_revlog_clone(srcrepo): |
462 # Now copy other files in the store directory. |
463 srcrepo.ui.status(_(b'copying %s\n') % p) |
463 for p in _files_to_copy_post_revlog_clone(srcrepo): |
464 src = srcrepo.store.rawvfs.join(p) |
464 srcrepo.ui.status(_(b'copying %s\n') % p) |
465 dst = dstrepo.store.rawvfs.join(p) |
465 src = srcrepo.store.rawvfs.join(p) |
466 util.copyfile(src, dst, copystat=True) |
466 dst = dstrepo.store.rawvfs.join(p) |
467 |
467 util.copyfile(src, dst, copystat=True) |
468 finishdatamigration(ui, srcrepo, dstrepo, requirements) |
468 |
469 |
469 finishdatamigration(ui, srcrepo, dstrepo, requirements) |
470 ui.status(_(b'data fully upgraded in a temporary repository\n')) |
470 |
471 |
471 ui.status(_(b'data fully upgraded in a temporary repository\n')) |
472 if upgrade_op.backup_store: |
472 |
473 backuppath = pycompat.mkdtemp( |
473 if upgrade_op.backup_store: |
474 prefix=b'upgradebackup.', dir=srcrepo.path |
474 backuppath = pycompat.mkdtemp( |
475 ) |
475 prefix=b'upgradebackup.', dir=srcrepo.path |
476 backupvfs = vfsmod.vfs(backuppath) |
476 ) |
477 |
477 backupvfs = vfsmod.vfs(backuppath) |
478 # Make a backup of requires file first, as it is the first to be modified. |
478 |
479 util.copyfile( |
479 # Make a backup of requires file first, as it is the first to be modified. |
480 srcrepo.vfs.join(b'requires'), backupvfs.join(b'requires') |
480 util.copyfile( |
481 ) |
481 srcrepo.vfs.join(b'requires'), backupvfs.join(b'requires') |
482 |
482 ) |
483 # We install an arbitrary requirement that clients must not support |
483 |
484 # as a mechanism to lock out new clients during the data swap. This is |
484 # We install an arbitrary requirement that clients must not support |
485 # better than allowing a client to continue while the repository is in |
485 # as a mechanism to lock out new clients during the data swap. This is |
486 # an inconsistent state. |
486 # better than allowing a client to continue while the repository is in |
487 ui.status( |
487 # an inconsistent state. |
488 _( |
488 ui.status( |
489 b'marking source repository as being upgraded; clients will be ' |
489 _( |
490 b'unable to read from repository\n' |
490 b'marking source repository as being upgraded; clients will be ' |
491 ) |
491 b'unable to read from repository\n' |
492 ) |
492 ) |
493 scmutil.writereporequirements( |
493 ) |
494 srcrepo, srcrepo.requirements | {b'upgradeinprogress'} |
494 scmutil.writereporequirements( |
495 ) |
495 srcrepo, srcrepo.requirements | {b'upgradeinprogress'} |
496 |
496 ) |
497 ui.status(_(b'starting in-place swap of repository data\n')) |
497 |
498 if upgrade_op.backup_store: |
498 ui.status(_(b'starting in-place swap of repository data\n')) |
499 ui.status(_(b'replaced files will be backed up at %s\n') % backuppath) |
499 if upgrade_op.backup_store: |
500 |
500 ui.status( |
501 # Now swap in the new store directory. Doing it as a rename should make |
501 _(b'replaced files will be backed up at %s\n') % backuppath |
502 # the operation nearly instantaneous and atomic (at least in well-behaved |
502 ) |
503 # environments). |
503 |
504 ui.status(_(b'replacing store...\n')) |
504 # Now swap in the new store directory. Doing it as a rename should make |
505 tstart = util.timer() |
505 # the operation nearly instantaneous and atomic (at least in well-behaved |
506 _replacestores(srcrepo, dstrepo, backupvfs, upgrade_op) |
506 # environments). |
507 elapsed = util.timer() - tstart |
507 ui.status(_(b'replacing store...\n')) |
508 ui.status( |
508 tstart = util.timer() |
509 _( |
509 _replacestores(srcrepo, dstrepo, backupvfs, upgrade_op) |
510 b'store replacement complete; repository was inconsistent for ' |
510 elapsed = util.timer() - tstart |
511 b'%0.1fs\n' |
511 ui.status( |
512 ) |
512 _( |
513 % elapsed |
513 b'store replacement complete; repository was inconsistent for ' |
514 ) |
514 b'%0.1fs\n' |
515 |
515 ) |
516 # We first write the requirements file. Any new requirements will lock |
516 % elapsed |
517 # out legacy clients. |
517 ) |
518 ui.status( |
518 |
519 _( |
519 # We first write the requirements file. Any new requirements will lock |
520 b'finalizing requirements file and making repository readable ' |
520 # out legacy clients. |
521 b'again\n' |
521 ui.status( |
522 ) |
522 _( |
523 ) |
523 b'finalizing requirements file and making repository readable ' |
524 scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements) |
524 b'again\n' |
525 |
525 ) |
526 if upgrade_op.backup_store: |
526 ) |
527 # The lock file from the old store won't be removed because nothing has a |
527 scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements) |
528 # reference to its new location. So clean it up manually. Alternatively, we |
528 |
529 # could update srcrepo.svfs and other variables to point to the new |
529 if upgrade_op.backup_store: |
530 # location. This is simpler. |
530 # The lock file from the old store won't be removed because nothing has a |
531 backupvfs.unlink(b'store/lock') |
531 # reference to its new location. So clean it up manually. Alternatively, we |
|
532 # could update srcrepo.svfs and other variables to point to the new |
|
533 # location. This is simpler. |
|
534 backupvfs.unlink(b'store/lock') |
|
535 else: |
|
536 pass |
532 |
537 |
533 return backuppath |
538 return backuppath |