configwizard: import userrcpath from rcutil (bug 1359640); r?glob draft
authorGregory Szorc <gps@mozilla.com>
Tue, 25 Apr 2017 16:47:04 -0700
changeset 10864 2876fa200d0238a157c2fe88d57dc1eef766b999
parent 10863 fe3153ff250873d1d9661886d29a381c4c66ddde
push id1639
push userbmo:gps@mozilla.com
push dateTue, 25 Apr 2017 23:47:15 +0000
reviewersglob
bugs1359640
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
hgext/configwizard/__init__.py
--- 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)