original_docstring: Copy revlogs between 2 repos.
docstring: Copy revlogs between 2 repos.
docstring_tokens: Copy revlogs between 2 repos .
code: def _clonerevlogs(
      ui,
      srcrepo,
      dstrepo,
      tr,
      upgrade_op,
  ):
      """Copy revlogs between 2 repos."""
      revcount = 0
      srcsize = 0
      srcrawsize = 0
      dstsize = 0
      fcount = 0
      frevcount = 0
      fsrcsize = 0
      frawsize = 0
      fdstsize = 0
      mcount = 0
      mrevcount = 0
      msrcsize = 0
      mrawsize = 0
      mdstsize = 0
      crevcount = 0
      csrcsize = 0
      crawsize = 0
      cdstsize = 0
  
      alldatafiles = list(srcrepo.store.walk())
      # mapping of data files which needs to be cloned
      # key is unencoded filename
      # value is revlog_object_from_srcrepo
      manifests = {}
      changelogs = {}
      filelogs = {}
  
      # Perform a pass to collect metadata. This validates we can open all
      # source files and allows a unified progress bar to be displayed.
      for unencoded, encoded, size in alldatafiles:
          if not unencoded.endswith(b'.i'):
              continue
  
          rl = _revlogfrompath(srcrepo, unencoded)
  
          info = rl.storageinfo(
              exclusivefiles=True,
              revisionscount=True,
              trackedsize=True,
              storedsize=True,
          )
  
          revcount += info[b'revisionscount'] or 0
          datasize = info[b'storedsize'] or 0
          rawsize = info[b'trackedsize'] or 0
  
          srcsize += datasize
          srcrawsize += rawsize
  
          # This is for the separate progress bars.
          if isinstance(rl, changelog.changelog):
              changelogs[unencoded] = rl
              crevcount += len(rl)
              csrcsize += datasize
              crawsize += rawsize
          elif isinstance(rl, manifest.manifestrevlog):
              manifests[unencoded] = rl
              mcount += 1
              mrevcount += len(rl)
              msrcsize += datasize
              mrawsize += rawsize
          elif isinstance(rl, filelog.filelog):
              filelogs[unencoded] = rl
              fcount += 1
              frevcount += len(rl)
              fsrcsize += datasize
              frawsize += rawsize
          else:
              error.ProgrammingError(b'unknown revlog type')
  
      if not revcount:
          return
  
      ui.status(
          _(
              b'migrating %d total revisions (%d in filelogs, %d in manifests, '
              b'%d in changelog)\n'
          )
          % (revcount, frevcount, mrevcount, crevcount)
      )
      ui.status(
          _(b'migrating %s in store; %s tracked data\n')
          % ((util.bytecount(srcsize), util.bytecount(srcrawsize)))
      )
  
      # Used to keep track of progress.
      progress = None
  
      def oncopiedrevision(rl, rev, node):
          progress.increment()
  
      sidedatacompanion = getsidedatacompanion(srcrepo, dstrepo)
  
      # Migrating filelogs
      ui.status(
          _(
              b'migrating %d filelogs containing %d revisions '
              b'(%s in store; %s tracked data)\n'
          )
          % (
              fcount,
              frevcount,
              util.bytecount(fsrcsize),
              util.bytecount(frawsize),
          )
      )
      progress = srcrepo.ui.makeprogress(_(b'file revisions'), total=frevcount)
      for unencoded, oldrl in sorted(filelogs.items()):
          newrl = _perform_clone(
              ui,
              dstrepo,
              tr,
              oldrl,
              unencoded,
              upgrade_op,
              sidedatacompanion,
              oncopiedrevision,
          )
          info = newrl.storageinfo(storedsize=True)
          fdstsize += info[b'storedsize'] or 0
      ui.status(
          _(
              b'finished migrating %d filelog revisions across %d '
              b'filelogs; change in size: %s\n'
          )
          % (frevcount, fcount, util.bytecount(fdstsize - fsrcsize))
      )
  
      # Migrating manifests
      ui.status(
          _(
              b'migrating %d manifests containing %d revisions '
              b'(%s in store; %s tracked data)\n'
          )
          % (
              mcount,
              mrevcount,
              util.bytecount(msrcsize),
              util.bytecount(mrawsize),
          )
      )
      if progress:
          progress.complete()
      progress = srcrepo.ui.makeprogress(
          _(b'manifest revisions'), total=mrevcount
      )
      for unencoded, oldrl in sorted(manifests.items()):
          newrl = _perform_clone(
              ui,
              dstrepo,
              tr,
              oldrl,
              unencoded,
              upgrade_op,
              sidedatacompanion,
              oncopiedrevision,
          )
          info = newrl.storageinfo(storedsize=True)
          mdstsize += info[b'storedsize'] or 0
      ui.status(
          _(
              b'finished migrating %d manifest revisions across %d '
              b'manifests; change in size: %s\n'
          )
          % (mrevcount, mcount, util.bytecount(mdstsize - msrcsize))
      )
  
      # Migrating changelog
      ui.status(
          _(
              b'migrating changelog containing %d revisions '
              b'(%s in store; %s tracked data)\n'
          )
          % (
              crevcount,
              util.bytecount(csrcsize),
              util.bytecount(crawsize),
          )
      )
      if progress:
          progress.complete()
      progress = srcrepo.ui.makeprogress(
          _(b'changelog revisions'), total=crevcount
      )
      for unencoded, oldrl in sorted(changelogs.items()):
          newrl = _perform_clone(
              ui,
              dstrepo,
              tr,
              oldrl,
              unencoded,
              upgrade_op,
              sidedatacompanion,
              oncopiedrevision,
          )
          info = newrl.storageinfo(storedsize=True)
          cdstsize += info[b'storedsize'] or 0
      progress.complete()
      ui.status(
          _(
              b'finished migrating %d changelog revisions; change in size: '
              b'%s\n'
          )
          % (crevcount, util.bytecount(cdstsize - csrcsize))
      )
  
      dstsize = fdstsize + mdstsize + cdstsize
      ui.status(
          _(
              b'finished migrating %d total revisions; total change in store '
              b'size: %s\n'
          )
          % (revcount, util.bytecount(dstsize - srcsize))
      )
code_tokens: def _clonerevlogs ( ui , srcrepo , dstrepo , tr , upgrade_op , ) : revcount = 0 srcsize = 0 srcrawsize = 0 dstsize = 0 fcount = 0 frevcount = 0 fsrcsize = 0 frawsize = 0 fdstsize = 0 mcount = 0 mrevcount = 0 msrcsize = 0 mrawsize = 0 mdstsize = 0 crevcount = 0 csrcsize = 0 crawsize = 0 cdstsize = 0 alldatafiles = list ( srcrepo . store . walk ( ) ) manifests = { } changelogs = { } filelogs = { } for unencoded , encoded , size in alldatafiles : if not unencoded . endswith ( b'.i' ) : continue rl = _revlogfrompath ( srcrepo , unencoded ) info = rl . storageinfo ( exclusivefiles = True , revisionscount = True , trackedsize = True , storedsize = True , ) revcount += info [ b'revisionscount' ] or 0 datasize = info [ b'storedsize' ] or 0 rawsize = info [ b'trackedsize' ] or 0 srcsize += datasize srcrawsize += rawsize if isinstance ( rl , changelog . changelog ) : changelogs [ unencoded ] = rl crevcount += len ( rl ) csrcsize += datasize crawsize += rawsize elif isinstance ( rl , manifest . manifestrevlog ) : manifests [ unencoded ] = rl mcount += 1 mrevcount += len ( rl ) msrcsize += datasize mrawsize += rawsize elif isinstance ( rl , filelog . filelog ) : filelogs [ unencoded ] = rl fcount += 1 frevcount += len ( rl ) fsrcsize += datasize frawsize += rawsize else : error . ProgrammingError ( b'unknown revlog type' ) if not revcount : return ui . status ( _ ( b'migrating %d total revisions (%d in filelogs, %d in manifests, ' b'%d in changelog)\n' ) % ( revcount , frevcount , mrevcount , crevcount ) ) ui . status ( _ ( b'migrating %s in store; %s tracked data\n' ) % ( ( util . bytecount ( srcsize ) , util . bytecount ( srcrawsize ) ) ) ) progress = None def oncopiedrevision ( rl , rev , node ) : progress . increment ( ) sidedatacompanion = getsidedatacompanion ( srcrepo , dstrepo ) ui . status ( _ ( b'migrating %d filelogs containing %d revisions ' b'(%s in store; %s tracked data)\n' ) % ( fcount , frevcount , util . bytecount ( fsrcsize ) , util . bytecount ( frawsize ) , ) ) progress = srcrepo . ui . makeprogress ( _ ( b'file revisions' ) , total = frevcount ) for unencoded , oldrl in sorted ( filelogs . items ( ) ) : newrl = _perform_clone ( ui , dstrepo , tr , oldrl , unencoded , upgrade_op , sidedatacompanion , oncopiedrevision , ) info = newrl . storageinfo ( storedsize = True ) fdstsize += info [ b'storedsize' ] or 0 ui . status ( _ ( b'finished migrating %d filelog revisions across %d ' b'filelogs; change in size: %s\n' ) % ( frevcount , fcount , util . bytecount ( fdstsize - fsrcsize ) ) ) ui . status ( _ ( b'migrating %d manifests containing %d revisions ' b'(%s in store; %s tracked data)\n' ) % ( mcount , mrevcount , util . bytecount ( msrcsize ) , util . bytecount ( mrawsize ) , ) ) if progress : progress . complete ( ) progress = srcrepo . ui . makeprogress ( _ ( b'manifest revisions' ) , total = mrevcount ) for unencoded , oldrl in sorted ( manifests . items ( ) ) : newrl = _perform_clone ( ui , dstrepo , tr , oldrl , unencoded , upgrade_op , sidedatacompanion , oncopiedrevision , ) info = newrl . storageinfo ( storedsize = True ) mdstsize += info [ b'storedsize' ] or 0 ui . status ( _ ( b'finished migrating %d manifest revisions across %d ' b'manifests; change in size: %s\n' ) % ( mrevcount , mcount , util . bytecount ( mdstsize - msrcsize ) ) ) ui . status ( _ ( b'migrating changelog containing %d revisions ' b'(%s in store; %s tracked data)\n' ) % ( crevcount , util . bytecount ( csrcsize ) , util . bytecount ( crawsize ) , ) ) if progress : progress . complete ( ) progress = srcrepo . ui . makeprogress ( _ ( b'changelog revisions' ) , total = crevcount ) for unencoded , oldrl in sorted ( changelogs . items ( ) ) : newrl = _perform_clone ( ui , dstrepo , tr , oldrl , unencoded , upgrade_op , sidedatacompanion , oncopiedrevision , ) info = newrl . storageinfo ( storedsize = True ) cdstsize += info [ b'storedsize' ] or 0 progress . complete ( ) ui . status ( _ ( b'finished migrating %d changelog revisions; change in size: ' b'%s\n' ) % ( crevcount , util . bytecount ( cdstsize - csrcsize ) ) ) dstsize = fdstsize + mdstsize + cdstsize ui . status ( _ ( b'finished migrating %d total revisions; total change in store ' b'size: %s\n' ) % ( revcount , util . bytecount ( dstsize - srcsize ) ) )
short_docstring: Copy revlogs between 2 repos.
short_docstring_tokens: Copy revlogs between 2 repos .
comment: """Copy revlogs between 2 repos."""$SEP$# mapping of data files which needs to be cloned$SEP$# key is unencoded filename$SEP$# value is revlog_object_from_srcrepo$SEP$# Perform a pass to collect metadata. This validates we can open all$SEP$# source files and allows a unified progress bar to be displayed.$SEP$# This is for the separate progress bars.$SEP$# Used to keep track of progress.$SEP$# Migrating filelogs$SEP$# Migrating manifests$SEP$# Migrating changelog