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

shlib: move configs to %APPDATA%\TortoiseHg on Windows

import old configs the first time we try to open in the new
location, delete old configs after import.
fixes #50
fixes #79

Changeset b972f1cb8836

Parent e24dd34219bc

by Steve Borho

Changes to one file · Browse files at b972f1cb8836 Showing diff from parent e24dd34219bc Diff from another changeset...

Change 1 of 2 Show Entire File hggtk/​shlib.py Stacked
 
103
104
105
106
107
 
 
 
 
 
108
109
110
 
113
114
115
116
117
118
119
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
122
123
 
 
124
125
126
 
103
104
105
 
 
106
107
108
109
110
111
112
113
 
116
117
118
 
 
 
 
 
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
@@ -103,8 +103,11 @@
  dbase.close()     def _get_path(self, appname): - return os.path.join(os.path.expanduser('~'), '.tortoisehg', - 'settings', appname) + if os.name == 'nt': + return os.path.join(os.environ.get('APPDATA'), 'TortoiseHg', appname) + else: + return os.path.join(os.path.expanduser('~'), '.tortoisehg', + 'settings', appname)     def _audit(self):   if os.path.exists(os.path.dirname(self._path)): @@ -113,14 +116,27 @@
  self._import()     def _import(self): - # import old settings data (TortoiseHg <= 0.3) - old_path = os.path.join(os.path.expanduser('~'), '.hgext', 'tortoisehg') - if os.path.isfile(old_path): - print "converting old history..." - olddb = shelve.open(old_path) + # 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))    def get_system_times():   t = os.times()