mirror of
https://github.com/facebook/sapling.git
synced 2025-01-07 14:10:42 +03:00
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:
parent
b0ad111094
commit
02d588a3bc
@ -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:
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user