configwizard: import userrcpath from rcutil (
bug 1359640); r?glob
Mercurial 4.2 moved scmutil.userrcpath to rcutil.userrcpath. The old
symbol is not aliased. This commit refactors the logic for accessing
that symbol.
With this change, all tests pass on Mercurial 4.2.
MozReview-Commit-ID: 7zhdc1z1Mpe
--- a/hgext/configwizard/__init__.py
+++ b/hgext/configwizard/__init__.py
@@ -10,17 +10,16 @@ import stat
import subprocess
import sys
import uuid
from mercurial import (
cmdutil,
demandimport,
error,
- scmutil,
ui as uimod,
util,
)
from mercurial.i18n import _
OUR_DIR = os.path.dirname(__file__)
execfile(os.path.join(OUR_DIR, '..', 'bootstrap.py'))
@@ -333,18 +332,25 @@ def configwizard(ui, repo, statedir=None
ui.warn(VERSION_TOO_OLD % (
hgversion[0], hgversion[1],
MINIMUM_SUPPORTED_VERSION[0], MINIMUM_SUPPORTED_VERSION[1],
))
raise error.Abort('upgrade Mercurial then run again')
uiprompt(ui, INITIAL_MESSAGE, default='<RETURN>')
- configpaths = [p for p in scmutil.userrcpath() if os.path.exists(p)]
- path = configpaths[0] if configpaths else scmutil.userrcpath()[0]
+ with demandimport.deactivated():
+ # Mercurial 4.2 moved function from scmutil to rcutil.
+ try:
+ from mercurial.rcutil import userrcpath
+ except ImportError:
+ from mercurial.scmutil import userrcpath
+
+ configpaths = [p for p in userrcpath() if os.path.exists(p)]
+ path = configpaths[0] if configpaths else userrcpath()[0]
cw = configobjwrapper(path)
if 'hgversion' in runsteps:
if _checkhgversion(ui, hgversion):
return 1
if 'username' in runsteps:
_checkusername(ui, cw)