mercurial/upgrade.py
changeset 41088 5608b5a6c323
parent 40997 038108a9811c
child 41089 a59a74721c76
equal deleted inserted replaced
41087:797a416a91bd 41088:5608b5a6c323
   346         if not fv.fromrepo(repo):
   346         if not fv.fromrepo(repo):
   347             deficiencies.append(fv)
   347             deficiencies.append(fv)
   348 
   348 
   349     return deficiencies
   349     return deficiencies
   350 
   350 
       
   351 # search without '-' to support older form on newer client.
       
   352 #
       
   353 # We don't enforce backward compatibility for debug command so this
       
   354 # might eventually be dropped. However, having to use two different
       
   355 # forms in script when comparing result is anoying enough to add
       
   356 # backward compatibility for a while.
       
   357 legacy_opts_map = {
       
   358     'redeltaparent': 're-delta-parent',
       
   359     'redeltamultibase': 're-delta-multibase',
       
   360     'redeltaall': 're-delta-all',
       
   361     'redeltafulladd': 're-delta-fulladd',
       
   362 }
       
   363 
   351 def findoptimizations(repo):
   364 def findoptimizations(repo):
   352     """Determine optimisation that could be used during upgrade"""
   365     """Determine optimisation that could be used during upgrade"""
   353     # These are unconditionally added. There is logic later that figures out
   366     # These are unconditionally added. There is logic later that figures out
   354     # which ones to apply.
   367     # which ones to apply.
   355     optimizations = []
   368     optimizations = []
   356 
   369 
   357     optimizations.append(improvement(
   370     optimizations.append(improvement(
   358         name='redeltaparent',
   371         name='re-delta-parent',
   359         type=optimisation,
   372         type=optimisation,
   360         description=_('deltas within internal storage will be recalculated to '
   373         description=_('deltas within internal storage will be recalculated to '
   361                       'choose an optimal base revision where this was not '
   374                       'choose an optimal base revision where this was not '
   362                       'already done; the size of the repository may shrink and '
   375                       'already done; the size of the repository may shrink and '
   363                       'various operations may become faster; the first time '
   376                       'various operations may become faster; the first time '
   366                       'not run noticeably slower'),
   379                       'not run noticeably slower'),
   367         upgrademessage=_('deltas within internal storage will choose a new '
   380         upgrademessage=_('deltas within internal storage will choose a new '
   368                          'base revision if needed')))
   381                          'base revision if needed')))
   369 
   382 
   370     optimizations.append(improvement(
   383     optimizations.append(improvement(
   371         name='redeltamultibase',
   384         name='re-delta-multibase',
   372         type=optimisation,
   385         type=optimisation,
   373         description=_('deltas within internal storage will be recalculated '
   386         description=_('deltas within internal storage will be recalculated '
   374                       'against multiple base revision and the smallest '
   387                       'against multiple base revision and the smallest '
   375                       'difference will be used; the size of the repository may '
   388                       'difference will be used; the size of the repository may '
   376                       'shrink significantly when there are many merges; this '
   389                       'shrink significantly when there are many merges; this '
   383                          'optimal delta by computing deltas against multiple '
   396                          'optimal delta by computing deltas against multiple '
   384                          'parents; may slow down execution time '
   397                          'parents; may slow down execution time '
   385                          'significantly')))
   398                          'significantly')))
   386 
   399 
   387     optimizations.append(improvement(
   400     optimizations.append(improvement(
   388         name='redeltaall',
   401         name='re-delta-all',
   389         type=optimisation,
   402         type=optimisation,
   390         description=_('deltas within internal storage will always be '
   403         description=_('deltas within internal storage will always be '
   391                       'recalculated without reusing prior deltas; this will '
   404                       'recalculated without reusing prior deltas; this will '
   392                       'likely make execution run several times slower; this '
   405                       'likely make execution run several times slower; this '
   393                       'optimization is typically not needed'),
   406                       'optimization is typically not needed'),
   394         upgrademessage=_('deltas within internal storage will be fully '
   407         upgrademessage=_('deltas within internal storage will be fully '
   395                          'recomputed; this will likely drastically slow down '
   408                          'recomputed; this will likely drastically slow down '
   396                          'execution time')))
   409                          'execution time')))
   397 
   410 
   398     optimizations.append(improvement(
   411     optimizations.append(improvement(
   399         name='redeltafulladd',
   412         name='re-delta-fulladd',
   400         type=optimisation,
   413         type=optimisation,
   401         description=_('every revision will be re-added as if it was new '
   414         description=_('every revision will be re-added as if it was new '
   402                       'content. It will go through the full storage '
   415                       'content. It will go through the full storage '
   403                       'mechanism giving extensions a chance to process it '
   416                       'mechanism giving extensions a chance to process it '
   404                       '(eg. lfs). This is similar to "redeltaall" but even '
   417                       '(eg. lfs). This is similar to "re-delta-all" but even '
   405                       'slower since more logic is involved.'),
   418                       'slower since more logic is involved.'),
   406         upgrademessage=_('each revision will be added as new content to the '
   419         upgrademessage=_('each revision will be added as new content to the '
   407                          'internal storage; this will likely drastically slow '
   420                          'internal storage; this will likely drastically slow '
   408                          'down execution time, but some extensions might need '
   421                          'down execution time, but some extensions might need '
   409                          'it')))
   422                          'it')))
   652     assert dstrepo.currentwlock()
   665     assert dstrepo.currentwlock()
   653 
   666 
   654     ui.write(_('(it is safe to interrupt this process any time before '
   667     ui.write(_('(it is safe to interrupt this process any time before '
   655                'data migration completes)\n'))
   668                'data migration completes)\n'))
   656 
   669 
   657     if 'redeltaall' in actions:
   670     if 're-delta-all' in actions:
   658         deltareuse = revlog.revlog.DELTAREUSENEVER
   671         deltareuse = revlog.revlog.DELTAREUSENEVER
   659     elif 'redeltaparent' in actions:
   672     elif 're-delta-parent' in actions:
   660         deltareuse = revlog.revlog.DELTAREUSESAMEREVS
   673         deltareuse = revlog.revlog.DELTAREUSESAMEREVS
   661     elif 'redeltamultibase' in actions:
   674     elif 're-delta-multibase' in actions:
   662         deltareuse = revlog.revlog.DELTAREUSESAMEREVS
   675         deltareuse = revlog.revlog.DELTAREUSESAMEREVS
   663     elif 'redeltafulladd' in actions:
   676     elif 're-delta-fulladd' in actions:
   664         deltareuse = revlog.revlog.DELTAREUSEFULLADD
   677         deltareuse = revlog.revlog.DELTAREUSEFULLADD
   665     else:
   678     else:
   666         deltareuse = revlog.revlog.DELTAREUSEALWAYS
   679         deltareuse = revlog.revlog.DELTAREUSEALWAYS
   667 
   680 
   668     with dstrepo.transaction('upgrade') as tr:
   681     with dstrepo.transaction('upgrade') as tr:
   669         _copyrevlogs(ui, srcrepo, dstrepo, tr, deltareuse,
   682         _copyrevlogs(ui, srcrepo, dstrepo, tr, deltareuse,
   670                      'redeltamultibase' in actions)
   683                      're-delta-multibase' in actions)
   671 
   684 
   672     # Now copy other files in the store directory.
   685     # Now copy other files in the store directory.
   673     # The sorted() makes execution deterministic.
   686     # The sorted() makes execution deterministic.
   674     for p, kind, st in sorted(srcrepo.store.vfs.readdir('', stat=True)):
   687     for p, kind, st in sorted(srcrepo.store.vfs.readdir('', stat=True)):
   675         if not _filterstorefile(srcrepo, dstrepo, requirements,
   688         if not _filterstorefile(srcrepo, dstrepo, requirements,
   729 
   742 
   730     return backuppath
   743     return backuppath
   731 
   744 
   732 def upgraderepo(ui, repo, run=False, optimize=None):
   745 def upgraderepo(ui, repo, run=False, optimize=None):
   733     """Upgrade a repository in place."""
   746     """Upgrade a repository in place."""
   734     optimize = set(optimize or [])
   747     if optimize is None:
       
   748         optimize = []
       
   749     optimize = set(legacy_opts_map.get(o, o) for o in optimize)
   735     repo = repo.unfiltered()
   750     repo = repo.unfiltered()
   736 
   751 
   737     # Ensure the repository can be upgraded.
   752     # Ensure the repository can be upgraded.
   738     missingreqs = requiredsourcerequirements(repo) - repo.requirements
   753     missingreqs = requiredsourcerequirements(repo) - repo.requirements
   739     if missingreqs:
   754     if missingreqs: