hgext/directaccess.py
changeset 1360 5c13945b32fc
parent 1347 b00c2fe51ac8
child 1363 2eaa2943f9f3
--- a/hgext/directaccess.py	Tue Jun 02 15:24:12 2015 -0700
+++ b/hgext/directaccess.py	Thu Jun 04 10:01:02 2015 -0700
@@ -64,6 +64,27 @@
         repo = repo.filtered("visible-directaccess-warn")
     return orig(ui, repo, *args, **kwargs)
 
+def uisetup(ui):
+    """ Change ordering of extensions to ensure that directaccess extsetup comes
+    after the one of the extensions in the loadsafter list """
+    loadsafter = ui.configlist('directaccess','loadsafter')
+    order = list(extensions._order)
+    directaccesidx = order.index('directaccess')
+
+    # The min idx for directaccess to load after all the extensions in loadafter
+    minidxdirectaccess = directaccesidx
+
+    for ext in loadsafter:
+        try:
+            minidxdirectaccess = max(minidxdirectaccess, order.index(ext))
+        except ValueError:
+            pass # extension not loaded
+
+    if minidxdirectaccess > directaccesidx:
+        order.insert(minidxdirectaccess + 1, 'directaccess')
+        order.remove('directaccess')
+        extensions._order = order
+
 def extsetup(ui):
     extensions.wrapfunction(revset, 'posttreebuilthook', _posttreebuilthook)
     setupdirectaccess()