[PATCH 2 of 8] obsolete: move the 'isenabled' function at the top of the file
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Fri May 19 10:28:01 EDT 2017
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at octobus.net>
# Date 1495192362 -7200
# Fri May 19 13:12:42 2017 +0200
# Node ID 0aed424624f8c7905951d964579df2088b82abc8
# Parent 1fe18fcc122b4d8e14264a3670d2d5f99f11bd75
# EXP-Topic obscache
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
# hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 0aed424624f8
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
@@ -1261,24 +1282,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
More information about the Mercurial-devel
mailing list