changeset 37131:d30810d09d6f

obsolete: refactor function for getting obsolete options The function for returning obsolete option values obtains all options, validates, then returns the option that was requested. Let's create a new function to return all obsolete option values so callers needing multiple values can call that. Differential Revision: https://phab.mercurial-scm.org/D2667
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 04 Mar 2018 09:58:57 -0500
parents a1d2d0420e22
children a54113fcc8c9
files mercurial/obsolete.py
diffstat 1 files changed, 19 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/obsolete.py	Mon Mar 26 14:17:01 2018 -0700
+++ b/mercurial/obsolete.py	Sun Mar 04 09:58:57 2018 -0500
@@ -133,20 +133,29 @@
 
         return option in result
 
+def getoptions(repo):
+    """Returns dicts showing state of obsolescence features."""
+
+    createmarkersvalue = _getoptionvalue(repo, createmarkersopt)
+    unstablevalue = _getoptionvalue(repo, allowunstableopt)
+    exchangevalue = _getoptionvalue(repo, exchangeopt)
+
+    # createmarkers must be enabled if other options are enabled
+    if ((unstablevalue or exchangevalue) and not createmarkersvalue):
+        raise error.Abort(_("'createmarkers' obsolete option must be enabled "
+                            "if other obsolete options are enabled"))
+
+    return {
+        createmarkersopt: createmarkersvalue,
+        allowunstableopt: unstablevalue,
+        exchangeopt: exchangevalue,
+    }
+
 def isenabled(repo, option):
     """Returns True if the given repository has the given obsolete option
     enabled.
     """
-    createmarkersvalue = _getoptionvalue(repo, createmarkersopt)
-    unstabluevalue = _getoptionvalue(repo, allowunstableopt)
-    exchangevalue = _getoptionvalue(repo, exchangeopt)
-
-    # createmarkers must be enabled if other options are enabled
-    if ((unstabluevalue or exchangevalue) and not createmarkersvalue):
-        raise error.Abort(_("'createmarkers' obsolete option must be enabled "
-                            "if other obsolete options are enabled"))
-
-    return _getoptionvalue(repo, option)
+    return getoptions(repo)[option]
 
 # Creating aliases for marker flags because evolve extension looks for
 # bumpedfix in obsolete.py