mercurial/upgrade.py
changeset 42137 d086ba387ae8
parent 42136 10a6725dca6e
child 42689 896fb9deeaf8
equal deleted inserted replaced
42136:10a6725dca6e 42137:d086ba387ae8
    22     scmutil,
    22     scmutil,
    23     util,
    23     util,
    24     vfs as vfsmod,
    24     vfs as vfsmod,
    25 )
    25 )
    26 
    26 
       
    27 from .utils import (
       
    28     compression,
       
    29 )
       
    30 
    27 def requiredsourcerequirements(repo):
    31 def requiredsourcerequirements(repo):
    28     """Obtain requirements required to be present to upgrade a repo.
    32     """Obtain requirements required to be present to upgrade a repo.
    29 
    33 
    30     An upgrade will not be allowed if the repository doesn't have the
    34     An upgrade will not be allowed if the repository doesn't have the
    31     requirements returned by this function.
    35     requirements returned by this function.
    59 
    63 
    60     If an upgrade were to create a repository that dropped a requirement,
    64     If an upgrade were to create a repository that dropped a requirement,
    61     the dropped requirement must appear in the returned set for the upgrade
    65     the dropped requirement must appear in the returned set for the upgrade
    62     to be allowed.
    66     to be allowed.
    63     """
    67     """
    64     return {
    68     supported = {
    65         localrepo.SPARSEREVLOG_REQUIREMENT,
    69         localrepo.SPARSEREVLOG_REQUIREMENT,
    66     }
    70     }
       
    71     for name in compression.compengines:
       
    72         engine = compression.compengines[name]
       
    73         if engine.available() and engine.revlogheader():
       
    74             supported.add(b'exp-compression-%s' % name)
       
    75             if engine.name() == 'zstd':
       
    76                 supported.add(b'revlog-compression-zstd')
       
    77     return supported
    67 
    78 
    68 def supporteddestrequirements(repo):
    79 def supporteddestrequirements(repo):
    69     """Obtain requirements that upgrade supports in the destination.
    80     """Obtain requirements that upgrade supports in the destination.
    70 
    81 
    71     If the result of the upgrade would create requirements not in this set,
    82     If the result of the upgrade would create requirements not in this set,
    72     the upgrade is disallowed.
    83     the upgrade is disallowed.
    73 
    84 
    74     Extensions should monkeypatch this to add their custom requirements.
    85     Extensions should monkeypatch this to add their custom requirements.
    75     """
    86     """
    76     return {
    87     supported = {
    77         'dotencode',
    88         'dotencode',
    78         'fncache',
    89         'fncache',
    79         'generaldelta',
    90         'generaldelta',
    80         'revlogv1',
    91         'revlogv1',
    81         'store',
    92         'store',
    82         localrepo.SPARSEREVLOG_REQUIREMENT,
    93         localrepo.SPARSEREVLOG_REQUIREMENT,
    83     }
    94     }
       
    95     for name in compression.compengines:
       
    96         engine = compression.compengines[name]
       
    97         if engine.available() and engine.revlogheader():
       
    98             supported.add(b'exp-compression-%s' % name)
       
    99             if engine.name() == 'zstd':
       
   100                 supported.add(b'revlog-compression-zstd')
       
   101     return supported
    84 
   102 
    85 def allowednewrequirements(repo):
   103 def allowednewrequirements(repo):
    86     """Obtain requirements that can be added to a repository during upgrade.
   104     """Obtain requirements that can be added to a repository during upgrade.
    87 
   105 
    88     This is used to disallow proposed requirements from being added when
   106     This is used to disallow proposed requirements from being added when
    90 
   108 
    91     We use a list of allowed requirement additions instead of a list of known
   109     We use a list of allowed requirement additions instead of a list of known
    92     bad additions because the whitelist approach is safer and will prevent
   110     bad additions because the whitelist approach is safer and will prevent
    93     future, unknown requirements from accidentally being added.
   111     future, unknown requirements from accidentally being added.
    94     """
   112     """
    95     return {
   113     supported = {
    96         'dotencode',
   114         'dotencode',
    97         'fncache',
   115         'fncache',
    98         'generaldelta',
   116         'generaldelta',
    99         localrepo.SPARSEREVLOG_REQUIREMENT,
   117         localrepo.SPARSEREVLOG_REQUIREMENT,
   100     }
   118     }
       
   119     for name in compression.compengines:
       
   120         engine = compression.compengines[name]
       
   121         if engine.available() and engine.revlogheader():
       
   122             supported.add(b'exp-compression-%s' % name)
       
   123             if engine.name() == 'zstd':
       
   124                 supported.add(b'revlog-compression-zstd')
       
   125     return supported
   101 
   126 
   102 def preservedrequirements(repo):
   127 def preservedrequirements(repo):
   103     return set()
   128     return set()
   104 
   129 
   105 deficiency = 'deficiency'
   130 deficiency = 'deficiency'