changeset 14539:558ec14ba6be

extensions: make disabled()/disabledext() load prebuilt index if available __index__ contains a dict of {name: desc} of all extensions.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 04 Jun 2011 20:19:30 +0900
parents 3818c67a501e
children 944d9088da96
files mercurial/extensions.py
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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])