1. Matthew Turk
  2. cedit

Commits

Kacper Kowalik  committed f3a2076

handle API changes between 1.8 and 1.9 in mercurial

  • Participants
  • Parent commits 3f24820
  • Branches default

Comments (0)

Files changed (1)

File config.py

View file
 from __future__ import with_statement
 from iniparse import SafeConfigParser
 from mercurial.i18n import _
-from mercurial import commands, hg, util, error
+from mercurial import commands, hg, error
+try:
+    from mercurial.scmutil import systemrcpath
+    from mercurial.scmutil import userrcpath
+    from mercurial.scmutil import osrcpath
+    from mercurial.scmutil import rcpath
+except ImportError:
+    from mercurial.util import system_rcpath as systemrcpath
+    from mercurial.util import user_rcpath as userrcpath
+    from mercurial.util import os_rcpath as osrcpath
+    from mercurial.util import rcpath
+
 from ConfigParser import NoOptionError, NoSectionError
 import os
 import sys
     elif 'HGRCPATH' in os.environ:
         path = os.environ['HGRCPATH'].split(os.pathsep)[0]
     else:
-        path = util.user_rcpath()[0]
+        path = userrcpath()[0]
     if not os.path.exists(path):
         with open(path, "wb") as _empty:
             pass # create empty file
 
 def defaultpath(pathtype, ui, path = ""):
     if pathtype == "user":
-        paths = util.user_rcpath()
+        paths = userrcpath()
         path = os.path.abspath(paths[len(paths)-1])
     elif pathtype == "global":
         if os.name == 'posix':
             self.printhelp][index]()
 
     def setpaths(self):
-        paths = util.rcpath()
-        paths.extend(util.os_rcpath())
+        paths = rcpath()
+        paths.extend(osrcpath())
         paths.append(repoconfpath())
         self._paths = verifypaths(paths)
         if existslocalrepo():
         else:
             # This is a little silly, since without a valid config file
             # how could this extension be loaded? But for completeness...
-            self._path = default = util.user_rcpath()[0]
+            self._path = default = userrcpath()[0]
             msg = _("Unable to find configuration file."
                     " Would you like to make one at %s?") % default
             index = self._ui.promptchoice(msg, [_('&yes'), _('&no')], 0)
         pathtype = "[other]"
         if path == repoconfpath():
             pathtype = "[repository]"
-        if path in util.user_rcpath():
+        if path in userrcpath():
             pathtype = "[user]"
-        elif path in util.system_rcpath():
+        elif path in systemrcpath():
             pathtype = "[system-wide]"
         elif 'HGRCPATH' in os.environ:
             if path in os.environ['HGRCPATH'].split(os.pathsep):