##// END OF EJS Templates
engine: add `if True` to prepare for next patch...
Pulkit Goyal -
r47096:ee9002b9 default
parent child Browse files
Show More
@@ -449,85 +449,90 b' def upgrade(ui, srcrepo, dstrepo, upgrad'
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 )
461
462 # Now copy other files in the store directory.
463 for p in _files_to_copy_post_revlog_clone(srcrepo):
464 srcrepo.ui.status(_(b'copying %s\n') % p)
465 src = srcrepo.store.rawvfs.join(p)
466 dst = dstrepo.store.rawvfs.join(p)
467 util.copyfile(src, dst, copystat=True)
468
469 finishdatamigration(ui, srcrepo, dstrepo, requirements)
470
471 ui.status(_(b'data fully upgraded in a temporary repository\n'))
460
472
461 # Now copy other files in the store directory.
473 if upgrade_op.backup_store:
462 for p in _files_to_copy_post_revlog_clone(srcrepo):
474 backuppath = pycompat.mkdtemp(
463 srcrepo.ui.status(_(b'copying %s\n') % p)
475 prefix=b'upgradebackup.', dir=srcrepo.path
464 src = srcrepo.store.rawvfs.join(p)
476 )
465 dst = dstrepo.store.rawvfs.join(p)
477 backupvfs = vfsmod.vfs(backuppath)
466 util.copyfile(src, dst, copystat=True)
467
478
468 finishdatamigration(ui, srcrepo, dstrepo, requirements)
479 # Make a backup of requires file first, as it is the first to be modified.
480 util.copyfile(
481 srcrepo.vfs.join(b'requires'), backupvfs.join(b'requires')
482 )
469
483
470 ui.status(_(b'data fully upgraded in a temporary repository\n'))
484 # We install an arbitrary requirement that clients must not support
471
485 # as a mechanism to lock out new clients during the data swap. This is
472 if upgrade_op.backup_store:
486 # better than allowing a client to continue while the repository is in
473 backuppath = pycompat.mkdtemp(
487 # an inconsistent state.
474 prefix=b'upgradebackup.', dir=srcrepo.path
488 ui.status(
489 _(
490 b'marking source repository as being upgraded; clients will be '
491 b'unable to read from repository\n'
492 )
475 )
493 )
476 backupvfs = vfsmod.vfs(backuppath)
494 scmutil.writereporequirements(
477
495 srcrepo, srcrepo.requirements | {b'upgradeinprogress'}
478 # Make a backup of requires file first, as it is the first to be modified.
479 util.copyfile(
480 srcrepo.vfs.join(b'requires'), backupvfs.join(b'requires')
481 )
496 )
482
497
483 # We install an arbitrary requirement that clients must not support
498 ui.status(_(b'starting in-place swap of repository data\n'))
484 # as a mechanism to lock out new clients during the data swap. This is
499 if upgrade_op.backup_store:
485 # better than allowing a client to continue while the repository is in
500 ui.status(
486 # an inconsistent state.
501 _(b'replaced files will be backed up at %s\n') % backuppath
487 ui.status(
502 )
488 _(
489 b'marking source repository as being upgraded; clients will be '
490 b'unable to read from repository\n'
491 )
492 )
493 scmutil.writereporequirements(
494 srcrepo, srcrepo.requirements | {b'upgradeinprogress'}
495 )
496
497 ui.status(_(b'starting in-place swap of repository data\n'))
498 if upgrade_op.backup_store:
499 ui.status(_(b'replaced files will be backed up at %s\n') % backuppath)
500
503
501 # Now swap in the new store directory. Doing it as a rename should make
504 # Now swap in the new store directory. Doing it as a rename should make
502 # the operation nearly instantaneous and atomic (at least in well-behaved
505 # the operation nearly instantaneous and atomic (at least in well-behaved
503 # environments).
506 # environments).
504 ui.status(_(b'replacing store...\n'))
507 ui.status(_(b'replacing store...\n'))
505 tstart = util.timer()
508 tstart = util.timer()
506 _replacestores(srcrepo, dstrepo, backupvfs, upgrade_op)
509 _replacestores(srcrepo, dstrepo, backupvfs, upgrade_op)
507 elapsed = util.timer() - tstart
510 elapsed = util.timer() - tstart
508 ui.status(
511 ui.status(
509 _(
512 _(
510 b'store replacement complete; repository was inconsistent for '
513 b'store replacement complete; repository was inconsistent for '
511 b'%0.1fs\n'
514 b'%0.1fs\n'
515 )
516 % elapsed
512 )
517 )
513 % elapsed
514 )
515
518
516 # We first write the requirements file. Any new requirements will lock
519 # We first write the requirements file. Any new requirements will lock
517 # out legacy clients.
520 # out legacy clients.
518 ui.status(
521 ui.status(
519 _(
522 _(
520 b'finalizing requirements file and making repository readable '
523 b'finalizing requirements file and making repository readable '
521 b'again\n'
524 b'again\n'
525 )
522 )
526 )
523 )
527 scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements)
524 scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements)
525
528
526 if upgrade_op.backup_store:
529 if upgrade_op.backup_store:
527 # The lock file from the old store won't be removed because nothing has a
530 # The lock file from the old store won't be removed because nothing has a
528 # reference to its new location. So clean it up manually. Alternatively, we
531 # reference to its new location. So clean it up manually. Alternatively, we
529 # could update srcrepo.svfs and other variables to point to the new
532 # could update srcrepo.svfs and other variables to point to the new
530 # location. This is simpler.
533 # location. This is simpler.
531 backupvfs.unlink(b'store/lock')
534 backupvfs.unlink(b'store/lock')
535 else:
536 pass
532
537
533 return backuppath
538 return backuppath
General Comments 0
You need to be logged in to leave comments. Login now