Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.0.1, 2.0.2, and 2.0.3

stable qtlib: move loadIniFile to qtlib to avoid circular import (fixes #172)

Changeset e9e5e20fa8ff

Parent d6c7008783eb

by Steve Borho

Changes to 3 files · Browse files at e9e5e20fa8ff Showing diff from parent d6c7008783eb Diff from another changeset...

 
15
16
17
18
19
20
21
22
23
 
767
768
769
770
 
771
772
773
 
790
791
792
793
 
794
795
796
 
813
814
815
816
 
817
818
819
 
15
16
17
 
18
 
19
20
21
 
765
766
767
 
768
769
770
771
 
788
789
790
 
791
792
793
794
 
811
812
813
 
814
815
816
817
@@ -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
18
19
20
 
21
22
23
 
50
51
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
54
55
 
17
18
19
 
20
21
22
23
 
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
@@ -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
321
322
323
 
324
325
326
 
831
832
833
834
 
835
836
837
 
929
930
931
932
 
933
934
935
 
999
1000
1001
1002
 
1003
1004
1005
 
1154
1155
1156
1157
 
1158
1159
1160
 
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
 
320
321
322
 
323
324
325
326
 
831
832
833
 
834
835
836
837
 
929
930
931
 
932
933
934
935
 
999
1000
1001
 
1002
1003
1004
1005
 
1154
1155
1156
 
1157
1158
1159
1160
 
1312
1313
1314
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1315
1316
1317
@@ -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'