changeset 22949:714f6ef43f3a

obsolete: add isenabled function for option checking Previously, obsolete used the module level _enabled flag to determine whether it was on or off. We need a bit more granular control, so we'll be introducing toggle options. The isenabled() function is how you check if a particular option is enabled for the given repository. Future patches will add options such as 'createmarkers', 'allowunstable', and 'exchange' to enable various features of obsolete markers.
author Durham Goode <durham@fb.com>
date Tue, 14 Oct 2014 13:17:35 -0700
parents c136e26953aa
children bb8278b289ee
files mercurial/obsolete.py
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/obsolete.py	Wed Oct 15 12:52:10 2014 -0700
+++ b/mercurial/obsolete.py	Tue Oct 14 13:17:35 2014 -0700
@@ -1144,3 +1144,18 @@
         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
+
+    return option in result