original_docstring: Do the low-level work of upgrading a repository.
  
      The upgrade is effectively performed as a copy between a source
      repository and a temporary destination repository.
  
      The source repository is unmodified for as long as possible so the
      upgrade can abort at any time without causing loss of service for
      readers and without corrupting the source repository.
      
docstring: Do the low-level work of upgrading a repository.
  The upgrade is effectively performed as a copy between a source
  repository and a temporary destination repository.
  
  The source repository is unmodified for as long as possible so the
  upgrade can abort at any time without causing loss of service for
  readers and without corrupting the source repository.
docstring_tokens: Do the low - level work of upgrading a repository . The upgrade is effectively performed as a copy between a source repository and a temporary destination repository . The source repository is unmodified for as long as possible so the upgrade can abort at any time without causing loss of service for readers and without corrupting the source repository .
code: def upgrade(ui, srcrepo, dstrepo, upgrade_op):
      """Do the low-level work of upgrading a repository.
  
      The upgrade is effectively performed as a copy between a source
      repository and a temporary destination repository.
  
      The source repository is unmodified for as long as possible so the
      upgrade can abort at any time without causing loss of service for
      readers and without corrupting the source repository.
      """
      assert srcrepo.currentwlock()
      assert dstrepo.currentwlock()
  
      ui.status(
          _(
              b'(it is safe to interrupt this process any time before '
              b'data migration completes)\n'
          )
      )
  
      with dstrepo.transaction(b'upgrade') as tr:
          _clonerevlogs(
              ui,
              srcrepo,
              dstrepo,
              tr,
              upgrade_op,
          )
  
      # Now copy other files in the store directory.
      for p in _files_to_copy_post_revlog_clone(srcrepo):
          srcrepo.ui.status(_(b'copying %s\n') % p)
          src = srcrepo.store.rawvfs.join(p)
          dst = dstrepo.store.rawvfs.join(p)
          util.copyfile(src, dst, copystat=True)
  
      finishdatamigration(ui, srcrepo, dstrepo, requirements)
  
      ui.status(_(b'data fully upgraded in a temporary repository\n'))
  
      backuppath = pycompat.mkdtemp(prefix=b'upgradebackup.', dir=srcrepo.path)
      backupvfs = vfsmod.vfs(backuppath)
  
      # Make a backup of requires file first, as it is the first to be modified.
      util.copyfile(srcrepo.vfs.join(b'requires'), backupvfs.join(b'requires'))
  
      # We install an arbitrary requirement that clients must not support
      # as a mechanism to lock out new clients during the data swap. This is
      # better than allowing a client to continue while the repository is in
      # an inconsistent state.
      ui.status(
          _(
              b'marking source repository as being upgraded; clients will be '
              b'unable to read from repository\n'
          )
      )
      scmutil.writereporequirements(
          srcrepo, srcrepo.requirements | {b'upgradeinprogress'}
      )
  
      ui.status(_(b'starting in-place swap of repository data\n'))
      ui.status(_(b'replaced files will be backed up at %s\n') % backuppath)
  
      # Now swap in the new store directory. Doing it as a rename should make
      # the operation nearly instantaneous and atomic (at least in well-behaved
      # environments).
      ui.status(_(b'replacing store...\n'))
      tstart = util.timer()
      _replacestores(srcrepo, dstrepo, backupvfs, upgrade_op)
      elapsed = util.timer() - tstart
      ui.status(
          _(
              b'store replacement complete; repository was inconsistent for '
              b'%0.1fs\n'
          )
          % elapsed
      )
  
      # We first write the requirements file. Any new requirements will lock
      # out legacy clients.
      ui.status(
          _(
              b'finalizing requirements file and making repository readable '
              b'again\n'
          )
      )
      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
code_tokens: def upgrade ( ui , srcrepo , dstrepo , upgrade_op ) : assert srcrepo . currentwlock ( ) assert dstrepo . currentwlock ( ) ui . status ( _ ( b'(it is safe to interrupt this process any time before ' b'data migration completes)\n' ) ) with dstrepo . transaction ( b'upgrade' ) as tr : _clonerevlogs ( ui , srcrepo , dstrepo , tr , upgrade_op , ) for p in _files_to_copy_post_revlog_clone ( srcrepo ) : srcrepo . ui . status ( _ ( b'copying %s\n' ) % p ) src = srcrepo . store . rawvfs . join ( p ) dst = dstrepo . store . rawvfs . join ( p ) util . copyfile ( src , dst , copystat = True ) finishdatamigration ( ui , srcrepo , dstrepo , requirements ) ui . status ( _ ( b'data fully upgraded in a temporary repository\n' ) ) backuppath = pycompat . mkdtemp ( prefix = b'upgradebackup.' , dir = srcrepo . path ) backupvfs = vfsmod . vfs ( backuppath ) util . copyfile ( srcrepo . vfs . join ( b'requires' ) , backupvfs . join ( b'requires' ) ) ui . status ( _ ( b'marking source repository as being upgraded; clients will be ' b'unable to read from repository\n' ) ) scmutil . writereporequirements ( srcrepo , srcrepo . requirements | { b'upgradeinprogress' } ) ui . status ( _ ( b'starting in-place swap of repository data\n' ) ) ui . status ( _ ( b'replaced files will be backed up at %s\n' ) % backuppath ) ui . status ( _ ( b'replacing store...\n' ) ) tstart = util . timer ( ) _replacestores ( srcrepo , dstrepo , backupvfs , upgrade_op ) elapsed = util . timer ( ) - tstart ui . status ( _ ( b'store replacement complete; repository was inconsistent for ' b'%0.1fs\n' ) % elapsed ) ui . status ( _ ( b'finalizing requirements file and making repository readable ' b'again\n' ) ) scmutil . writereporequirements ( srcrepo , upgrade_op . new_requirements ) backupvfs . unlink ( b'store/lock' ) return backuppath
short_docstring: Do the low-level work of upgrading a repository.
short_docstring_tokens: Do the low - level work of upgrading a repository .
comment: """Do the low-level work of upgrading a repository.
  
      The upgrade is effectively performed as a copy between a source
      repository and a temporary destination repository.
  
      The source repository is unmodified for as long as possible so the
      upgrade can abort at any time without causing loss of service for
      readers and without corrupting the source repository.
      """$SEP$# Now copy other files in the store directory.$SEP$# Make a backup of requires file first, as it is the first to be modified.$SEP$# We install an arbitrary requirement that clients must not support$SEP$# as a mechanism to lock out new clients during the data swap. This is$SEP$# better than allowing a client to continue while the repository is in$SEP$# an inconsistent state.$SEP$# Now swap in the new store directory. Doing it as a rename should make$SEP$# the operation nearly instantaneous and atomic (at least in well-behaved$SEP$# environments).$SEP$# We first write the requirements file. Any new requirements will lock$SEP$# out legacy clients.$SEP$# The lock file from the old store won't be removed because nothing has a$SEP$# reference to its new location. So clean it up manually. Alternatively, we$SEP$# could update srcrepo.svfs and other variables to point to the new$SEP$# location. This is simpler.