Commits

Steve Borho  committed 6442338

hglib: isolate scmutil knowledge to hglib.py until thg 2.1

  • Participants
  • Parent commits c8e1bd3

Comments (0)

Files changed (6)

File tortoisehg/hgqt/commit.py

 
 import os
 
-from mercurial import ui, scmutil, util, error
+from mercurial import ui, util, error
 
 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
         self.saveToPath([fn])
 
     def saveGlobal(self):
-        self.saveToPath(scmutil.user_rcpath())
+        self.saveToPath(hglib.user_rcpath())
 
     def saveToPath(self, path):
         fn, cfg = qtlib.loadIniFile(path, self)

File tortoisehg/hgqt/rename.py

                       'from folder<p>%s</p>' % cwd))
             return ('', '')
         try:
-            fname = util.canonpath(self.root, cwd, pats[0])
-            target = util.canonpath(self.root, cwd, pats[1])
+            fname = hglib.canonpath(self.root, cwd, pats[0])
+            target = hglib.canonpath(self.root, cwd, pats[1])
         except:
             pass
         os.chdir(self.root)
 
         cmdline, vcl = self.compose_command(src, dest)
         self.show_command((cmdline, vcl))
-        new_name = util.canonpath(self.root, self.root, new_name)
+        new_name = hglib.canonpath(self.root, self.root, new_name)
         if self.isCaseFoldingOnWin():
             # We do the rename ourselves if it's a pure casefolding
             # action on Windows. Because there is no way to make Hg

File tortoisehg/hgqt/run.py

 from PyQt4.QtGui import *
 
 import mercurial.ui as uimod
-from mercurial import hg, scmutil, util, fancyopts, cmdutil, extensions, error
+from mercurial import hg, util, fancyopts, cmdutil, extensions, error
 
 from tortoisehg.hgqt.i18n import agettext as _
 from tortoisehg.util import hglib, paths, shlib, i18n
     files = []
     for f in lines:
         try:
-            cpath = scmutil.canonpath(root, cwd, f)
+            cpath = hglib.canonpath(root, cwd, f)
             # canonpath will abort on .hg/ paths
         except util.Abort:
             continue

File tortoisehg/hgqt/settings.py

 
 import os
 
-from mercurial import ui, scmutil, util, error
+from mercurial import ui, util, error
 
 from tortoisehg.util import hglib, settings, paths, wconfig, i18n, bugtraq
 from tortoisehg.hgqt.i18n import _
 
         self.conftabs = QTabWidget()
         layout.addWidget(self.conftabs)
-        utab = SettingsForm(rcpath=scmutil.user_rcpath(), focus=focus)
+        utab = SettingsForm(rcpath=hglib.user_rcpath(), focus=focus)
         self.conftabs.addTab(utab, qtlib.geticon('settings_user'),
                              _("%s's global settings") % username())
         utab.restartRequested.connect(self._pushRestartRequest)
                 w = func(opts)
             w.installEventFilter(self)
             if e.globalonly:
-                w.setEnabled(self.rcpath == scmutil.user_rcpath())
+                w.setEnabled(self.rcpath == hglib.user_rcpath())
             lbl = QLabel(e.label)
             lbl.installEventFilter(self)
             lbl.setToolTip(e.tooltip)

File tortoisehg/hgqt/sync.py

 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
 
-from mercurial import hg, ui, url, scmutil, util, error, demandimport
+from mercurial import hg, ui, url, util, error, demandimport
 from mercurial import merge as mergemod
 
 from tortoisehg.util import hglib, wconfig
         qtlib.openhelpcontents('sync.html#security')
 
     def accept(self):
-        path = scmutil.user_rcpath()
+        path = hglib.user_rcpath()
         fn, cfg = qtlib.loadIniFile(path, self)
         if not hasattr(cfg, 'write'):
             qtlib.WarningMsgBox(_('Unable to save authentication'),

File tortoisehg/util/hglib.py

 
 from mercurial import ui, util, extensions, match, bundlerepo, url, cmdutil
 from mercurial import dispatch, encoding, templatefilters, filemerge, error
-from mercurial import scmutil
+from mercurial import demandimport
+
+demandimport.disable()
+try:
+    # hg >= 1.9
+    from mercurial.scmutil import canonpath, user_rcpath
+except (ImportError, AttributeError):
+    # hg <= 1.8
+    from mercurial.util import canonpath, user_rcpath
+demandimport.enable()
 
 _encoding = encoding.encoding
 _encodingmode = encoding.encodingmode
     root = paths.find_root(cwd)
     for f in list:
         try:
-            canonpats.append(scmutil.canonpath(root, cwd, f))
+            canonpats.append(canonpath(root, cwd, f))
         except util.Abort:
             # Attempt to resolve case folding conflicts.
             fu = f.upper()
             cwdu = cwd.upper()
             if fu.startswith(cwdu):
-                canonpats.append(scmutil.canonpath(root, cwd, f[len(cwd+os.sep):]))
+                canonpats.append(canonpath(root, cwd, f[len(cwd+os.sep):]))
             else:
                 # May already be canonical
                 canonpats.append(f)