Mercurial > evolve
changeset 1360:5c13945b32fc
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.
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Thu, 04 Jun 2015 10:01:02 -0700 |
parents | 82dd98428b8d |
children | 043e5ca9322f |
files | hgext/directaccess.py tests/test-inhibit.t |
diffstat | 2 files changed, 48 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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()
--- 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 <<EOF > [extensions] > directaccess=! + > testextension=! > EOF $ hg up 15 abort: Cannot use inhibit without the direct access extension [255] +