Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: tools/dom/scripts/idlsync.py

Issue 13162002: Save all version control dirs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3 # for details. All rights reserved. Use of this source code is governed by a 3 # for details. All rights reserved. Use of this source code is governed by a
4 # BSD-style license that can be found in the LICENSE file. 4 # BSD-style license that can be found in the LICENSE file.
5 5
6 import optparse 6 import optparse
7 import os 7 import os
8 import os.path 8 import os.path
9 import re 9 import re
10 import shutil 10 import shutil
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 readme = template % { 170 readme = template % {
171 'script': os.path.basename(__file__), 171 'script': os.path.basename(__file__),
172 'url': url, 172 'url': url,
173 'revision': revision } 173 'revision': revision }
174 174
175 readme_path = os.path.join(local_path, 'README') 175 readme_path = os.path.join(local_path, 'README')
176 out = open(readme_path, 'w') 176 out = open(readme_path, 'w')
177 out.write(readme) 177 out.write(readme)
178 out.close() 178 out.close()
179 179
180 ZIP_ARCHIVE = 'version-control-dirs.zip'
181
180 def SaveVersionControlDir(local_path): 182 def SaveVersionControlDir(local_path):
181 version_control_dir = os.path.join(local_path, '.git') 183 RunCommand([
182 if not os.path.isdir(version_control_dir): 184 'sh', '-c',
183 version_control_dir = os.path.join(local_path, '.svn') 185 'find %s -name .svn -or -name .git | zip -r %s -@' % (
184 if not os.path.isdir(version_control_dir): 186 os.path.relpath(local_path), ZIP_ARCHIVE)
185 raise '%s is not a git or svn directory' % local_path 187 ])
186 temp_dir = tempfile.mkdtemp()
187 shutil.move(version_control_dir, temp_dir)
188 return temp_dir
189 188
190 189
191 def RestoreVersionControlDir(local_path, saved_version_control_dir): 190 def RestoreVersionControlDir():
192 version_control_dir = os.path.join(saved_version_control_dir, '.git') 191 RunCommand(['unzip', ZIP_ARCHIVE, '-d', '.'])
193 if not os.path.isdir(version_control_dir): 192 RunCommand(['rm', ZIP_ARCHIVE])
194 version_control_dir = os.path.join(saved_version_control_dir, '.svn')
195 if not os.path.isdir(version_control_dir):
196 raise 'Failed restoring version control directory'
197 shutil.move(version_control_dir, local_path)
198 shutil.rmtree(saved_version_control_dir)
199
200 193
201 def ParseOptions(): 194 def ParseOptions():
202 parser = optparse.OptionParser() 195 parser = optparse.OptionParser()
203 parser.add_option('--webkit-revision', '-w', dest='webkit_revision', 196 parser.add_option('--webkit-revision', '-w', dest='webkit_revision',
204 help='WebKit IDL revision to install', default=None) 197 help='WebKit IDL revision to install', default=None)
205 parser.add_option('--chrome-revision', '-c', dest='chrome_revision', 198 parser.add_option('--chrome-revision', '-c', dest='chrome_revision',
206 help='Chrome IDL revision to install', default=None) 199 help='Chrome IDL revision to install', default=None)
207 parser.add_option('--update', '-u', dest='update', 200 parser.add_option('--update', '-u', dest='update',
208 help='IDL to update (webkit | chrome | all)', 201 help='IDL to update (webkit | chrome | all)',
209 default='webkit') 202 default='webkit')
210 args, _ = parser.parse_args() 203 args, _ = parser.parse_args()
211 update = {} 204 update = {}
212 if args.update == 'all' or args.update == 'chrome': 205 if args.update == 'all' or args.update == 'chrome':
213 update['chrome'] = args.chrome_revision 206 update['chrome'] = args.chrome_revision
214 if args.update == 'all' or args.update == 'webkit': 207 if args.update == 'all' or args.update == 'webkit':
215 update['webkit'] = args.webkit_revision 208 update['webkit'] = args.webkit_revision
216 return update 209 return update
217 210
218 211
219 def main(): 212 def main():
220 deps = GetDeps() 213 deps = GetDeps()
221 update = ParseOptions() 214 update = ParseOptions()
222 for (component, remote_path, local_path, readme, depth) in UPDATE_LIST: 215 for (component, remote_path, local_path, readme, depth) in UPDATE_LIST:
223 if component in update.keys(): 216 if component in update.keys():
224 revision = update[component] 217 revision = update[component]
225 url, latest = GetSvnRevision(deps, component) 218 url, latest = GetSvnRevision(deps, component)
226 if revision is None: 219 if revision is None:
227 revision = latest 220 revision = latest
228 saved_version_control_dir = SaveVersionControlDir(local_path); 221 SaveVersionControlDir(local_path);
229 RefreshFiles(url, revision, remote_path, local_path, depth) 222 RefreshFiles(url, revision, remote_path, local_path, depth)
230 PruneExtraFiles(local_path) 223 PruneExtraFiles(local_path)
231 GenerateReadme(local_path, readme, url, revision) 224 GenerateReadme(local_path, readme, url, revision)
232 RestoreVersionControlDir(local_path, saved_version_control_dir); 225 RestoreVersionControlDir();
233 226
234 if __name__ == '__main__': 227 if __name__ == '__main__':
235 main() 228 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698