Patchwork D2667: obsolete: refactor function for getting obsolete options

login
register
mail settings
Submitter phabricator
Date March 27, 2018, 7:27 a.m.
Message ID <8ea1ed3fe0e7f6f6edefef3f36446e5e@localhost.localdomain>
Download mbox | patch
Permalink /patch/29899/
State Not Applicable
Headers show

Comments

phabricator - March 27, 2018, 7:27 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGd30810d09d6f: obsolete: refactor function for getting obsolete options (authored by indygreg, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D2667?vs=6608&id=7333#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2667?vs=6608&id=7333

REVISION DETAIL
  https://phab.mercurial-scm.org/D2667

AFFECTED FILES
  mercurial/obsolete.py

CHANGE DETAILS




To: indygreg, #hg-reviewers, pulkit
Cc: mercurial-devel

Patch

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -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