Changeset e9e5e20fa8ff…
Parent d6c7008783eb…
by
Changes to 3 files · Browse files at e9e5e20fa8ff Showing diff from parent d6c7008783eb Diff from another changeset...
@@ -15,9 +15,7 @@
from tortoisehg.hgqt.i18n import _
from tortoisehg.util import hglib, shlib, wconfig
-
from tortoisehg.hgqt import qtlib, qscilib, status, cmdui, branchop, revpanel
-from tortoisehg.hgqt.sync import loadIniFile
# Technical Debt for CommitWidget
# disable commit button while no message is entered or no files are selected
@@ -767,7 +765,7 @@ self.saveToPath(util.user_rcpath())
def saveToPath(self, path):
- fn, cfg = loadIniFile(path, self)
+ fn, cfg = qtlib.loadIniFile(path, self)
if not hasattr(cfg, 'write'):
qtlib.WarningMsgBox(_('Unable to save username'),
_('Iniparse must be installed.'), parent=self)
@@ -790,7 +788,7 @@
def savePushAfter(self):
path = os.path.join(self.repo.root, '.hg', 'hgrc')
- fn, cfg = loadIniFile([path], self)
+ fn, cfg = qtlib.loadIniFile([path], self)
if not hasattr(cfg, 'write'):
qtlib.WarningMsgBox(_('Unable to save after commit push'),
_('Iniparse must be installed.'), parent=self)
@@ -813,7 +811,7 @@
def saveAutoInc(self):
path = os.path.join(self.repo.root, '.hg', 'hgrc')
- fn, cfg = loadIniFile([path], self)
+ fn, cfg = qtlib.loadIniFile([path], self)
if not hasattr(cfg, 'write'):
qtlib.WarningMsgBox(_('Unable to save auto include list'),
_('Iniparse must be installed.'), parent=self)
|
@@ -17,7 +17,7 @@ from PyQt4.QtGui import *
from mercurial import extensions
-from tortoisehg.util import hglib, paths
+from tortoisehg.util import hglib, paths, wconfig
from hgext.color import _styles
tmproot = None
@@ -50,6 +50,27 @@ return
QDesktopServices.openUrl(QUrl(fullurl))
+def loadIniFile(rcpath, parent):
+ for fn in rcpath:
+ if os.path.exists(fn):
+ break
+ else:
+ for fn in rcpath:
+ # Try to create a file from rcpath
+ try:
+ f = open(fn, 'w')
+ f.write('# Generated by TortoiseHg\n')
+ f.close()
+ break
+ except EnvironmentError:
+ pass
+ else:
+ qtlib.WarningMsgBox(_('Unable to create a config file'),
+ _('Insufficient access rights.'), parent=parent)
+ return None, {}
+
+ return fn, wconfig.readfile(fn)
+
# _styles maps from ui labels to effects
# _effects maps an effect to font style properties. We define a limited
# set of _effects, since we convert color effect names to font style
|
@@ -320,7 +320,7 @@ # Refresh configured paths
self.paths = {}
fn = self.repo.join('hgrc')
- fn, cfg = loadIniFile([fn], self)
+ fn, cfg = qtlib.loadIniFile([fn], self)
if 'paths' in cfg:
for alias in cfg['paths']:
self.paths[ alias ] = cfg['paths'][ alias ]
@@ -831,7 +831,7 @@ def removeAlias(self, alias):
alias = hglib.fromunicode(alias)
fn = self.repo.join('hgrc')
- fn, cfg = loadIniFile([fn], self)
+ fn, cfg = qtlib.loadIniFile([fn], self)
if not hasattr(cfg, 'write'):
qtlib.WarningMsgBox(_('Unable to remove URL'),
_('Iniparse must be installed.'), parent=self)
@@ -929,7 +929,7 @@
def accept(self):
path = self.repo.join('hgrc')
- fn, cfg = loadIniFile([path], self)
+ fn, cfg = qtlib.loadIniFile([path], self)
if not hasattr(cfg, 'write'):
qtlib.WarningMsgBox(_('Unable to save post pull operation'),
_('Iniparse must be installed.'), parent=self)
@@ -999,7 +999,7 @@
def accept(self):
fn = self.repo.join('hgrc')
- fn, cfg = loadIniFile([fn], self)
+ fn, cfg = qtlib.loadIniFile([fn], self)
if not hasattr(cfg, 'write'):
qtlib.WarningMsgBox(_('Unable to save an URL'),
_('Iniparse must be installed.'), parent=self)
@@ -1154,7 +1154,7 @@
def accept(self):
path = util.user_rcpath()
- fn, cfg = loadIniFile(path, self)
+ fn, cfg = qtlib.loadIniFile(path, self)
if not hasattr(cfg, 'write'):
qtlib.WarningMsgBox(_('Unable to save authentication'),
_('Iniparse must be installed.'), parent=self)
@@ -1312,27 +1312,6 @@ return self.rows[index.row()][2]
-def loadIniFile(rcpath, parent):
- for fn in rcpath:
- if os.path.exists(fn):
- break
- else:
- for fn in rcpath:
- # Try to create a file from rcpath
- try:
- f = open(fn, 'w')
- f.write('# Generated by TortoiseHg\n')
- f.close()
- break
- except EnvironmentError:
- pass
- else:
- qtlib.WarningMsgBox(_('Unable to create a config file'),
- _('Insufficient access rights.'), parent=parent)
- return None, {}
-
- return fn, wconfig.readfile(fn)
-
class OptionsDialog(QDialog):
'Utility dialog for configuring uncommon options'
|
Loading...