extensions: make disabled()/disabledext() load prebuilt index if available
authorYuya Nishihara <yuya@tcha.org>
Sat, 04 Jun 2011 20:19:30 +0900
changeset 14539 558ec14ba6be
parent 14538 3818c67a501e
child 14540 944d9088da96
extensions: make disabled()/disabledext() load prebuilt index if available __index__ contains a dict of {name: desc} of all extensions.
mercurial/extensions.py
--- a/mercurial/extensions.py	Sat Jun 04 20:11:10 2011 +0900
+++ b/mercurial/extensions.py	Sat Jun 04 20:19:30 2011 +0900
@@ -262,6 +262,14 @@
 
 def disabled():
     '''find disabled extensions from hgext. returns a dict of {name: desc}'''
+    try:
+        from hgext import __index__
+        return dict((name, gettext(desc))
+                    for name, desc in __index__.docs.iteritems()
+                    if name not in _order)
+    except ImportError:
+        pass
+
     paths = _disabledpaths()
     if not paths:
         return None
@@ -276,6 +284,15 @@
 
 def disabledext(name):
     '''find a specific disabled extension from hgext. returns desc'''
+    try:
+        from hgext import __index__
+        if name in _order:  # enabled
+            return
+        else:
+            return gettext(__index__.docs.get(name))
+    except ImportError:
+        pass
+
     paths = _disabledpaths()
     if name in paths:
         return _disabledhelp(paths[name])