Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.9, 0.9.1, and 0.9.1.1

thgconfig: fall back to read only mode when iniparse is not available

Does not raise an error anymore (after showing the warning message)
uses mercurial.config instead of iniparse

Do not convert to list where it is not necessary

Changeset 4d53aac5f184

Parent 8f47f0b3dfe0

by Simon Heimberg

Changes to one file · Browse files at 4d53aac5f184 Showing diff from parent 8f47f0b3dfe0 Diff from another changeset...

 
519
520
521
522
523
 
 
524
525
526
527
528
 
615
616
617
618
 
619
620
621
 
694
695
696
697
 
698
699
700
 
1015
1016
1017
1018
1019
 
 
 
 
 
 
 
 
 
1020
1021
1022
 
1027
1028
1029
1030
 
1031
1032
1033
 
1042
1043
1044
 
 
 
1045
1046
1047
 
1058
1059
1060
1061
 
1062
1063
1064
 
519
520
521
 
 
522
523
524
 
525
526
527
 
614
615
616
 
617
618
619
620
 
693
694
695
 
696
697
698
699
 
1014
1015
1016
 
 
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
 
1033
1034
1035
 
1036
1037
1038
1039
 
1048
1049
1050
1051
1052
1053
1054
1055
1056
 
1067
1068
1069
 
1070
1071
1072
1073
@@ -519,10 +519,9 @@
  demandimport.enable()   except ImportError:   dialog.error_dialog(self, _('Iniparse package not found'), - _('Please install iniparse package')) - self.destroy() + _('Please install iniparse package') + '\n' + + _('Settings are only shown, no changing is possible'))   print 'Please install http://code.google.com/p/iniparse/' - return     # Catch close events   self.connect('response', self.should_live) @@ -615,7 +614,7 @@
  self.ini = self.load_config(self.rcpath)   self.refresh_vlist()   self.pathdata.clear() - if 'paths' in list(self.ini): + if 'paths' in self.ini:   for name in self.ini['paths']:   path = self.ini['paths'][name]   safepath = hglib.toutf(url.hidepassword(path)) @@ -694,7 +693,7 @@
    def dirty_event(self, *args):   if not self.dirty: - self._btn_apply.set_sensitive(True) + self._btn_apply.set_sensitive(not hasattr(self.ini, '_readonly'))   self.dirty = True     def _add_path(self, *args): @@ -1015,8 +1014,15 @@
  f.write(_('# Generated by tortoisehg-config\n'))   f.close()   self.fn = fn - import iniparse - return iniparse.INIConfig(file(fn), optionxformvalue=None) + try: + import iniparse + return iniparse.INIConfig(file(fn), optionxformvalue=None) + except ImportError: + from mercurial import config + cfg = config.config() + cfg.read(fn) + cfg._readonly = True + return cfg     def record_new_value(self, cpath, newvalue, keephistory=True):   # 'newvalue' is converted to local encoding @@ -1027,7 +1033,7 @@
  except KeyError:   pass   return - if section not in list(self.ini): + if section not in self.ini:   if hasattr(self.ini, '_new_namespace'):   self.ini._new_namespace(section)   else: @@ -1042,6 +1048,9 @@
  self.history.mrul(cpath).add(newvalue)     def _apply_clicked(self, *args): + if hasattr(self.ini, '_readonly'): + #dialog? Read only access, please install ... + return   # Reload history, since it may have been modified externally   self.history.read()   @@ -1058,7 +1067,7 @@
  cpath = '.'.join(['paths', name])   self.record_new_value(cpath, path, False)   refreshlist.append(name) - for name in list(self.ini.paths): + for name in self.ini.paths:   if name not in refreshlist:   del self.ini['paths'][name]   elif 'paths' in list(self.ini):