configwizard: work around ui.__class__ not working on hg <1.7 (bug 1282293); r?glob draft
authorGregory Szorc <gps@mozilla.com>
Tue, 28 Jun 2016 08:08:47 -0700
changeset 8668 45abe127c72597ee52ea23f36cc861e87458a7e1
parent 8667 55bf9b956205489b8ef47bc98a9e1c9f24dec617
push id956
push usergszorc@mozilla.com
push dateTue, 28 Jun 2016 15:11:38 +0000
reviewersglob
bugs1282293
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
hgext/configwizard/__init__.py
--- 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],