mercurial/upgrade_utils/actions.py
changeset 46705 fd55a9eb1507
parent 46638 b4c2a2af25e2
child 46706 7d9d9265d40f
equal deleted inserted replaced
46704:913485776542 46705:fd55a9eb1507
   326 
   326 
   327 @registerformatvariant
   327 @registerformatvariant
   328 class sidedata(requirementformatvariant):
   328 class sidedata(requirementformatvariant):
   329     name = b'sidedata'
   329     name = b'sidedata'
   330 
   330 
   331     _requirement = requirements.SIDEDATA_REQUIREMENT
   331     _requirement = requirements.REVLOGV2_REQUIREMENT
   332 
   332 
   333     default = False
   333     default = False
   334 
   334 
   335     description = _(
   335     description = _(
   336         b'Allows storage of extra data alongside a revision, '
   336         b'Allows storage of extra data alongside a revision, '
   337         b'unlocking various caching options.'
   337         b'unlocking various caching options.'
   338     )
   338     )
   339 
   339 
   340     upgrademessage = _(b'Allows storage of extra data alongside a revision.')
   340     upgrademessage = _(b'Allows storage of extra data alongside a revision.')
   341 
   341 
       
   342     @classmethod
       
   343     def fromrepo(cls, repo):
       
   344         assert cls._requirement is not None
       
   345         return cls._requirement in repo.requirements
       
   346 
   342 
   347 
   343 @registerformatvariant
   348 @registerformatvariant
   344 class persistentnodemap(requirementformatvariant):
   349 class persistentnodemap(requirementformatvariant):
   345     name = b'persistent-nodemap'
   350     name = b'persistent-nodemap'
   346 
   351 
   366     description = _(b'Stores copies information alongside changesets.')
   371     description = _(b'Stores copies information alongside changesets.')
   367 
   372 
   368     upgrademessage = _(
   373     upgrademessage = _(
   369         b'Allows to use more efficient algorithm to deal with ' b'copy tracing.'
   374         b'Allows to use more efficient algorithm to deal with ' b'copy tracing.'
   370     )
   375     )
       
   376 
       
   377 
       
   378 @registerformatvariant
       
   379 class revlogv2(requirementformatvariant):
       
   380     name = b'revlog-v2'
       
   381     _requirement = requirements.REVLOGV2_REQUIREMENT
       
   382     default = False
       
   383     description = _(b'Version 2 of the revlog.')
       
   384     upgrademessage = _(b'very experimental')
   371 
   385 
   372 
   386 
   373 @registerformatvariant
   387 @registerformatvariant
   374 class removecldeltachain(formatvariant):
   388 class removecldeltachain(formatvariant):
   375     name = b'plain-cl-delta'
   389     name = b'plain-cl-delta'
   855     An upgrade will not be allowed if the repository doesn't have the
   869     An upgrade will not be allowed if the repository doesn't have the
   856     requirements returned by this function.
   870     requirements returned by this function.
   857     """
   871     """
   858     return {
   872     return {
   859         # Introduced in Mercurial 0.9.2.
   873         # Introduced in Mercurial 0.9.2.
   860         requirements.REVLOGV1_REQUIREMENT,
       
   861         # Introduced in Mercurial 0.9.2.
       
   862         requirements.STORE_REQUIREMENT,
   874         requirements.STORE_REQUIREMENT,
   863     }
   875     }
   864 
   876 
   865 
   877 
   866 def blocksourcerequirements(repo):
   878 def blocksourcerequirements(repo):
   879         # Upgrade should operate on the actual store, not the shared link.
   891         # Upgrade should operate on the actual store, not the shared link.
   880         requirements.SHARED_REQUIREMENT,
   892         requirements.SHARED_REQUIREMENT,
   881     }
   893     }
   882 
   894 
   883 
   895 
       
   896 def check_revlog_version(reqs):
       
   897     """Check that the requirements contain at least one Revlog version"""
       
   898     all_revlogs = {
       
   899         requirements.REVLOGV1_REQUIREMENT,
       
   900         requirements.REVLOGV2_REQUIREMENT,
       
   901     }
       
   902     if not all_revlogs.intersection(reqs):
       
   903         msg = _(b'cannot upgrade repository; missing a revlog version')
       
   904         raise error.Abort(msg)
       
   905 
       
   906 
   884 def check_source_requirements(repo):
   907 def check_source_requirements(repo):
   885     """Ensure that no existing requirements prevent the repository upgrade"""
   908     """Ensure that no existing requirements prevent the repository upgrade"""
   886 
   909 
       
   910     check_revlog_version(repo.requirements)
   887     required = requiredsourcerequirements(repo)
   911     required = requiredsourcerequirements(repo)
   888     missingreqs = required - repo.requirements
   912     missingreqs = required - repo.requirements
   889     if missingreqs:
   913     if missingreqs:
   890         msg = _(b'cannot upgrade repository; requirement missing: %s')
   914         msg = _(b'cannot upgrade repository; requirement missing: %s')
   891         missingreqs = b', '.join(sorted(missingreqs))
   915         missingreqs = b', '.join(sorted(missingreqs))
   913         requirements.SPARSEREVLOG_REQUIREMENT,
   937         requirements.SPARSEREVLOG_REQUIREMENT,
   914         requirements.SIDEDATA_REQUIREMENT,
   938         requirements.SIDEDATA_REQUIREMENT,
   915         requirements.COPIESSDC_REQUIREMENT,
   939         requirements.COPIESSDC_REQUIREMENT,
   916         requirements.NODEMAP_REQUIREMENT,
   940         requirements.NODEMAP_REQUIREMENT,
   917         requirements.SHARESAFE_REQUIREMENT,
   941         requirements.SHARESAFE_REQUIREMENT,
       
   942         requirements.REVLOGV2_REQUIREMENT,
       
   943         requirements.REVLOGV1_REQUIREMENT,
   918     }
   944     }
   919     for name in compression.compengines:
   945     for name in compression.compengines:
   920         engine = compression.compengines[name]
   946         engine = compression.compengines[name]
   921         if engine.available() and engine.revlogheader():
   947         if engine.available() and engine.revlogheader():
   922             supported.add(b'exp-compression-%s' % name)
   948             supported.add(b'exp-compression-%s' % name)
   935     """
   961     """
   936     supported = {
   962     supported = {
   937         requirements.DOTENCODE_REQUIREMENT,
   963         requirements.DOTENCODE_REQUIREMENT,
   938         requirements.FNCACHE_REQUIREMENT,
   964         requirements.FNCACHE_REQUIREMENT,
   939         requirements.GENERALDELTA_REQUIREMENT,
   965         requirements.GENERALDELTA_REQUIREMENT,
   940         requirements.REVLOGV1_REQUIREMENT,
   966         requirements.REVLOGV1_REQUIREMENT,  # allowed in case of downgrade
   941         requirements.STORE_REQUIREMENT,
   967         requirements.STORE_REQUIREMENT,
   942         requirements.SPARSEREVLOG_REQUIREMENT,
   968         requirements.SPARSEREVLOG_REQUIREMENT,
   943         requirements.SIDEDATA_REQUIREMENT,
   969         requirements.SIDEDATA_REQUIREMENT,
   944         requirements.COPIESSDC_REQUIREMENT,
   970         requirements.COPIESSDC_REQUIREMENT,
   945         requirements.NODEMAP_REQUIREMENT,
   971         requirements.NODEMAP_REQUIREMENT,
   946         requirements.SHARESAFE_REQUIREMENT,
   972         requirements.SHARESAFE_REQUIREMENT,
       
   973         requirements.REVLOGV2_REQUIREMENT,
   947     }
   974     }
   948     for name in compression.compengines:
   975     for name in compression.compengines:
   949         engine = compression.compengines[name]
   976         engine = compression.compengines[name]
   950         if engine.available() and engine.revlogheader():
   977         if engine.available() and engine.revlogheader():
   951             supported.add(b'exp-compression-%s' % name)
   978             supported.add(b'exp-compression-%s' % name)
   971         requirements.SPARSEREVLOG_REQUIREMENT,
   998         requirements.SPARSEREVLOG_REQUIREMENT,
   972         requirements.SIDEDATA_REQUIREMENT,
   999         requirements.SIDEDATA_REQUIREMENT,
   973         requirements.COPIESSDC_REQUIREMENT,
  1000         requirements.COPIESSDC_REQUIREMENT,
   974         requirements.NODEMAP_REQUIREMENT,
  1001         requirements.NODEMAP_REQUIREMENT,
   975         requirements.SHARESAFE_REQUIREMENT,
  1002         requirements.SHARESAFE_REQUIREMENT,
       
  1003         requirements.REVLOGV1_REQUIREMENT,
       
  1004         requirements.REVLOGV2_REQUIREMENT,
   976     }
  1005     }
   977     for name in compression.compengines:
  1006     for name in compression.compengines:
   978         engine = compression.compengines[name]
  1007         engine = compression.compengines[name]
   979         if engine.available() and engine.revlogheader():
  1008         if engine.available() and engine.revlogheader():
   980             supported.add(b'exp-compression-%s' % name)
  1009             supported.add(b'exp-compression-%s' % name)
   983     return supported
  1012     return supported
   984 
  1013 
   985 
  1014 
   986 def check_requirements_changes(repo, new_reqs):
  1015 def check_requirements_changes(repo, new_reqs):
   987     old_reqs = repo.requirements
  1016     old_reqs = repo.requirements
   988 
  1017     check_revlog_version(repo.requirements)
   989     support_removal = supportremovedrequirements(repo)
  1018     support_removal = supportremovedrequirements(repo)
   990     no_remove_reqs = old_reqs - new_reqs - support_removal
  1019     no_remove_reqs = old_reqs - new_reqs - support_removal
   991     if no_remove_reqs:
  1020     if no_remove_reqs:
   992         msg = _(b'cannot upgrade repository; requirement would be removed: %s')
  1021         msg = _(b'cannot upgrade repository; requirement would be removed: %s')
   993         no_remove_reqs = b', '.join(sorted(no_remove_reqs))
  1022         no_remove_reqs = b', '.join(sorted(no_remove_reqs))