Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.7.3, 0.7.4, and 0.7.5

shlib: apps should not import old settings

Fixes #124. It's probable that the DB deadlock could
be prevented more simply, by just not deleting the old
files, but doing the conversion implicitly this way was
simply not a good idea.

Changeset 944b5a53b1e3

Parent 945949090302

by Steve Borho

Changes to one file · Browse files at 944b5a53b1e3 Showing diff from parent 945949090302 Diff from another changeset...

Change 1 of 4 Show Entire File hggtk/​shlib.py Stacked
 
8
9
10
11
12
13
14
 
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
 
115
116
117
118
 
 
 
 
 
119
120
121
 
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
 
158
159
160
 
8
9
10
 
11
12
13
 
86
87
88
 
 
 
 
 
 
 
 
 
 
 
89
90
 
91
92
93
 
102
103
104
 
105
106
107
108
109
110
111
112
 
118
119
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
122
123
124
@@ -8,7 +8,6 @@
 """    import dumbdbm, anydbm -saved_default = anydbm._defaultmod  anydbm._defaultmod = dumbdbm    import os @@ -87,20 +86,8 @@
    def read(self):   self._data.clear() - if os.path.exists(self._path): - # One-time import of <=0.7 config file - anydbm._defaultmod = saved_default - dbase = shelve.open(self._path) - self._dbappname = dbase['APPNAME'] - self.version = dbase['VERSION'] - self._data.update(dbase.get('DATA', {})) - dbase.close() - anydbm._defaultmod = dumbdbm - os.unlink(self._path) - return   if not os.path.exists(self._path+'.dat'):   return -   dbase = shelve.open(self._path)   self._dbappname = dbase['APPNAME']   self.version = dbase['VERSION'] @@ -115,7 +102,11 @@
  dbase['VERSION'] = Settings.version   dbase['APPNAME'] = appname   dbase['DATA'] = data - dbase.close() + try: + dbase.close() + except IOError: + pass # Don't care too much about permission errors +     def _get_path(self, appname):   if os.name == 'nt': @@ -127,34 +118,7 @@
  def _audit(self):   if os.path.exists(os.path.dirname(self._path)):   return - try: - os.makedirs(os.path.dirname(self._path)) - self._import() - except: - pass - - def _import(self): - # import old settings data dir (TortoiseHg <= 0.7) - home = os.path.expanduser('~') - if os.name == 'nt': - olddir = os.path.join(home, '.tortoisehg', 'settings') - newdir = os.path.join(os.environ.get('APPDATA'), 'TortoiseHg') - if os.path.isdir(olddir): - for f in os.listdir(olddir): - src = os.path.join(olddir, f) - dst = os.path.join(newdir, f) - os.rename(src, dst) - os.removedirs(olddir) - - # import old settings data file (TortoiseHg <= 0.3) - oldpath = os.path.join(home, '.hgext', 'tortoisehg') - if os.path.isfile(oldpath): - olddb = shelve.open(oldpath) - for key in olddb.keys(): - self._write(key, olddb[key]) - olddb.close() - os.unlink(oldpath) - os.removedirs(os.path.dirname(oldpath)) + os.makedirs(os.path.dirname(self._path))    def get_system_times():   t = os.times()