extensions: fix reposetup() not getting called for DEFAULT_EXTENSIONS

Summary:
`_peerorrepo` calls `extensions.extensions()` to figure out on which modules to run reposetup. This uses a slightly
different code path than that patched by D6716674 and double-checks if an extension is enabled. So we need to patch here too.

Reviewed By: quark-zju

Differential Revision: D6758486

fbshipit-source-id: b5bfe2d11e5e2aeb2d3a0ee7c9d6e3e2c213233d
This commit is contained in:
Phil Cohen 2018-01-23 12:08:44 -08:00 committed by Saurabh Singh
parent b0ad111094
commit 02d588a3bc
2 changed files with 31 additions and 3 deletions

View File

@ -65,6 +65,10 @@ def extensions(ui=None):
conf = ui.config('extensions', format % name)
if conf is not None and not conf.startswith('!'):
return True
# Check DEFAULT_EXTENSIONS if no config for this extension was
# specified.
if conf is None and name in DEFAULT_EXTENSIONS:
return True
else:
enabled = lambda name: True
for name in _order:

View File

@ -1,6 +1,7 @@
Tests the behavior of the DEFAULT_EXTENSIONS constant in extensions.py
$ hg init
$ hg init a
$ cd a
hg githelp works without enabling:
@ -34,8 +35,31 @@ Or overriden by a different path:
>
> @command('githelp')
> def githhelp(ui, repo, *args, **opts):
> ui.warn('Custom version of hg githelp')
> ui.warn('Custom version of hg githelp\n')
>
> EOF
$ hg githelp --config extensions.githelp=`pwd`/githelp2.py -- git reset HEAD
Custom version of hg githelp (no-eol)
Custom version of hg githelp
A default extension's reposetup and extsetup are run:
$ cd $TESTTMP
$ mkdir hgext
$ cat > hgext/mofunc.py <<EOF
> from hgext import githelp
> def extsetup(ui):
> # Only print reposetup() once so that this test output doesn't change
> # the number of times repo gets wrapped as we enable extensions.
> githelp.reposetupcount = 0
> def reposetup(ui, repo):
> if githelp.reposetupcount == 0:
> ui.warn('githelp reposetup()\n')
> githelp.reposetupcount += 1
> def extsetup(ui):
> ui.warn('githelp extsetup()\n')
> githelp.reposetup = reposetup
> githelp.extsetup = extsetup
> EOF
$ hg -R a githelp --config extensions.path=hgext/mofunc.py -- git status
githelp extsetup()
githelp reposetup()
hg status