Commits

Yuya Nishihara committed 29806ee

hglib: move function to list up all known extensions to hglib

It'll be useful for PyQt port.

Comments (0)

Files changed (2)

tortoisehg/hgtk/thgconfig.py

                 self.presetcombo.set_active(0)
 
     def fill_extensions_frame(self, parent, table):
-        def allexts():
-            enabledexts, maxnamelen = extensions.enabled()
-            disabledexts, maxnamelen = extensions.disabled()
-            exts = (disabledexts or {}).copy()
-            exts.update(enabledexts)
-            return iter((name, exts[name])
-                        for name in sorted(exts.iterkeys()))
-
-        allextslist = list(allexts())
+        allexts = hglib.allextensions()
 
         MAXCOLUMNS = 3
-        maxrows = (len(allextslist) + MAXCOLUMNS - 1) / MAXCOLUMNS
+        maxrows = (len(allexts) + MAXCOLUMNS - 1) / MAXCOLUMNS
         extstable = gtk.Table()
         parent.pack_start(extstable, False, False)
 
         self.extensionschecks = {}
-        for i, (name, shortdesc) in enumerate(allextslist):
+        for i, name in enumerate(sorted(allexts)):
+            shortdesc = allexts[name]
             ck = gtk.CheckButton(name, use_underline=False)
             ck.connect('toggled', self.dirty_event)
             ck.connect('focus-in-event', self.set_help,

tortoisehg/util/hglib.py

     if 'mq' in repo.__dict__: #do not create if it does not exist
         repo.mq.invalidate()
 
+def allextensions():
+    """Return the {name: shortdesc} dict of known extensions
+
+    shortdesc is in local encoding.
+    """
+    enabledexts = extensions.enabled()[0]
+    disabledexts = extensions.disabled()[0]
+    exts = (disabledexts or {}).copy()
+    exts.update(enabledexts)
+    return exts
+
 def loadextension(ui, name):
     # Between Mercurial revisions 1.2 and 1.3, extensions.load() stopped
     # calling uisetup() after loading an extension.  This could do