comparison mercurial/obsolete.py @ 34864:fec79a3f250f

config: update evolution-related config Update the evolution helpers function to support both old-style configuration and new-style configuration: experimental.evolution=all is renamed into experimental.evolution=true experimental.evolution=createmarkers is renamed into experimental.evolution.createmarkers=true experimental.evolution=allowunstable is renamed into experimental.evolution.allowunstable=true experimental.evolution=exchange is renamed into experimental.evolution.exchange=true We choose to not rename individual config options; keeping the same names would easy the transition for users but it's something that could be easily done in the future. Differential Revision: https://phab.mercurial-scm.org/D1147
author Boris Feld <boris.feld@octobus.net>
date Mon, 16 Oct 2017 17:14:47 +0200
parents b1e3f609bf45
children cc977ec0b8b9
comparison
equal deleted inserted replaced
34863:b1e3f609bf45 34864:fec79a3f250f
96 # Options for obsolescence 96 # Options for obsolescence
97 createmarkersopt = 'createmarkers' 97 createmarkersopt = 'createmarkers'
98 allowunstableopt = 'allowunstable' 98 allowunstableopt = 'allowunstable'
99 exchangeopt = 'exchange' 99 exchangeopt = 'exchange'
100 100
101 def _getoptionvalue(repo, option):
102 """Returns True if the given repository has the given obsolete option
103 enabled.
104 """
105 configkey = 'evolution.%s' % option
106 newconfig = repo.ui.configbool('experimental', configkey)
107
108 # Return the value only if defined
109 if newconfig is not None:
110 return newconfig
111
112 # Fallback on generic option
113 try:
114 return repo.ui.configbool('experimental', 'evolution')
115 except (error.ConfigError, AttributeError):
116 # Fallback on old-fashion config
117 # inconsistent config: experimental.evolution
118 result = set(repo.ui.configlist('experimental', 'evolution'))
119
120 if 'all' in result:
121 return True
122
123 # For migration purposes, temporarily return true if the config hasn't
124 # been set but _enabled is true.
125 if len(result) == 0 and _enabled:
126 return True
127
128 # Temporary hack for next check
129 newconfig = repo.ui.config('experimental', 'evolution.createmarkers')
130 if newconfig:
131 result.add('createmarkers')
132
133 return option in result
134
101 def isenabled(repo, option): 135 def isenabled(repo, option):
102 """Returns True if the given repository has the given obsolete option 136 """Returns True if the given repository has the given obsolete option
103 enabled. 137 enabled.
104 """ 138 """
105 result = set(repo.ui.configlist('experimental', 'evolution')) 139 createmarkersvalue = _getoptionvalue(repo, createmarkersopt)
106 if 'all' in result: 140 unstabluevalue = _getoptionvalue(repo, allowunstableopt)
107 return True 141 exchangevalue = _getoptionvalue(repo, exchangeopt)
108
109 # For migration purposes, temporarily return true if the config hasn't been
110 # set but _enabled is true.
111 if len(result) == 0 and _enabled:
112 return True
113 142
114 # createmarkers must be enabled if other options are enabled 143 # createmarkers must be enabled if other options are enabled
115 if ((allowunstableopt in result or exchangeopt in result) and 144 if ((unstabluevalue or exchangevalue) and not createmarkersvalue):
116 not createmarkersopt in result):
117 raise error.Abort(_("'createmarkers' obsolete option must be enabled " 145 raise error.Abort(_("'createmarkers' obsolete option must be enabled "
118 "if other obsolete options are enabled")) 146 "if other obsolete options are enabled"))
119 147
120 return option in result 148 return _getoptionvalue(repo, option)
121 149
122 ### obsolescence marker flag 150 ### obsolescence marker flag
123 151
124 ## bumpedfix flag 152 ## bumpedfix flag
125 # 153 #