configwizard: work around ui.__class__ not working on hg <1.7 (
bug 1282293); r?glob
See the inline comment for why we do this.
This enables the extension to load on hg 1.4, which is what RHEL 6
ships and is hopefully the oldest version we'll encounter in the wild.
It may work on earlier versions but I haven't tested.
MozReview-Commit-ID: 3kL844ZnNdp
--- a/hgext/configwizard/__init__.py
+++ b/hgext/configwizard/__init__.py
@@ -291,17 +291,22 @@ wizardsteps = set([
'configchange',
'permissions',
])
def configwizard(ui, repo, statedir=None, **opts):
"""Ensure your Mercurial configuration is up to date."""
runsteps = set(wizardsteps)
- if ui.hasconfig('configwizard', 'steps'):
+
+ # Mercurial <1.7 had a bug where monkeypatching ui.__class__
+ # during uisetup() doesn't work. So we do our own ui.hasconfig()
+ # here. Other uses of ui.hasconfig() are allowed, as they will
+ # have a properly monkeypatched ui.__class__.
+ if 'steps' in ui._data(False)._data.get('configwizard', {}):
runsteps = set(ui.configlist('configwizard', 'steps'))
hgversion = util.versiontuple(n=3)
if hgversion < MINIMUM_SUPPORTED_VERSION:
ui.warn(VERSION_TOO_OLD % (
hgversion[0], hgversion[1],
MINIMUM_SUPPORTED_VERSION[0], MINIMUM_SUPPORTED_VERSION[1],