# HG changeset patch # User Laurent Charignon # Date 1433437262 25200 # Node ID 5c13945b32fc4bcb4998a1bdd0b669ac43c26574 # Parent 82dd98428b8d85ea0c9acefebcff40ea59902c66 directaccess: add mechanism to load directaccess after some other extensions directaccess needs to load after some extensions to avoid interfering with them. This patch adds a mechanism to specify what extension directaccess needs to load after. diff -r 82dd98428b8d -r 5c13945b32fc hgext/directaccess.py --- 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() diff -r 82dd98428b8d -r 5c13945b32fc tests/test-inhibit.t --- a/tests/test-inhibit.t Tue Jun 02 15:24:12 2015 -0700 +++ b/tests/test-inhibit.t Thu Jun 04 10:01:02 2015 -0700 @@ -687,12 +687,39 @@ nothing changed [1] +Directaccess should load after some extensions precised in the conf +With no extension specified: + + $ cat >$TESTTMP/test_extension.py << EOF + > from mercurial import extensions + > def uisetup(ui): + > print extensions._order + > EOF + $ cat >> $HGRCPATH << EOF + > [extensions] + > testextension=$TESTTMP/test_extension.py + > EOF + $ hg id + ['rebase', 'strip', 'evolve', 'directaccess', 'inhibit', 'testextension'] + 721c3c279519 tip + +With test_extension specified: + $ cat >> $HGRCPATH << EOF + > [directaccess] + > loadsafter=testextension + > EOF + $ hg id + ['rebase', 'strip', 'evolve', 'inhibit', 'testextension', 'directaccess'] + 721c3c279519 tip + Inhibit should not work without directaccess $ cat >> $HGRCPATH < [extensions] > directaccess=! + > testextension=! > EOF $ hg up 15 abort: Cannot use inhibit without the direct access extension [255] +