obsolete: move the 'isenabled' function at the top of the file
authorPierre-Yves David <pierre-yves.david@octobus.net>
Fri, 19 May 2017 13:12:42 +0200
changeset 32372 566cfe9cbbb9
parent 32371 7aa4a4cf0dde
child 32373 6e0d1043e8fc
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.
mercurial/obsolete.py
--- a/mercurial/obsolete.py	Fri May 19 13:09:23 2017 +0200
+++ b/mercurial/obsolete.py	Fri May 19 13:12:42 2017 +0200
@@ -95,6 +95,27 @@
 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 @@
         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