# HG changeset patch # User Pierre-Yves David # Date 2017-05-19 11:12:42 # Node ID 566cfe9cbbb9b163bb58c8666759a634badacdd7 # Parent 7aa4a4cf0dde3a051990238be4e70ba18d45f7d7 obsolete: move the 'isenabled' function at the top of the file That is a simple and important function so having it at the top next to the related constant seems better. diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py --- a/mercurial/obsolete.py +++ b/mercurial/obsolete.py @@ -95,6 +95,27 @@ createmarkersopt = 'createmarkers' allowunstableopt = 'allowunstable' exchangeopt = 'exchange' +def isenabled(repo, option): + """Returns True if the given repository has the given obsolete option + enabled. + """ + result = set(repo.ui.configlist('experimental', 'evolution')) + if 'all' in result: + return True + + # For migration purposes, temporarily return true if the config hasn't been + # set but _enabled is true. + if len(result) == 0 and _enabled: + return True + + # createmarkers must be enabled if other options are enabled + if ((allowunstableopt in result or exchangeopt in result) and + not createmarkersopt in result): + raise error.Abort(_("'createmarkers' obsolete option must be enabled " + "if other obsolete options are enabled")) + + return option in result + ### obsolescence marker flag ## bumpedfix flag @@ -1264,24 +1285,3 @@ def createmarkers(repo, relations, flag= tr.close() finally: tr.release() - -def isenabled(repo, option): - """Returns True if the given repository has the given obsolete option - enabled. - """ - result = set(repo.ui.configlist('experimental', 'evolution')) - if 'all' in result: - return True - - # For migration purposes, temporarily return true if the config hasn't been - # set but _enabled is true. - if len(result) == 0 and _enabled: - return True - - # createmarkers must be enabled if other options are enabled - if ((allowunstableopt in result or exchangeopt in result) and - not createmarkersopt in result): - raise error.Abort(_("'createmarkers' obsolete option must be enabled " - "if other obsolete options are enabled")) - - return option in result