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

Side by Side Diff: trychange.py

Issue 1783009: Add support for svn 1.4 to trychange.py (Closed)
Patch Set: Created 10 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
« 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) 2009 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 """Client-side script to send a try job to the try server. It communicates to 5 """Client-side script to send a try job to the try server. It communicates to
6 the try server by either writting to a svn repository or by directly connecting 6 the try server by either writting to a svn repository or by directly connecting
7 to the server by HTTP. 7 to the server by HTTP.
8 """ 8 """
9 9
10 import datetime 10 import datetime
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 328
329 values = _ParseSendChangeOptions(options) 329 values = _ParseSendChangeOptions(options)
330 description = ''.join("%s=%s\n" % (k,v) for (k,v) in values.iteritems()) 330 description = ''.join("%s=%s\n" % (k,v) for (k,v) in values.iteritems())
331 logging.info('Sending by SVN') 331 logging.info('Sending by SVN')
332 logging.info(description) 332 logging.info(description)
333 logging.info(options.svn_repo) 333 logging.info(options.svn_repo)
334 logging.info(options.diff) 334 logging.info(options.diff)
335 if options.dry_run: 335 if options.dry_run:
336 return 336 return
337 337
338 # Do an empty checkout. 338 # Create a temporary directory, put a uniquely named file in it with the diff
339 # content and svn import that.
339 temp_dir = tempfile.mkdtemp() 340 temp_dir = tempfile.mkdtemp()
340 temp_file = tempfile.NamedTemporaryFile() 341 temp_file = tempfile.NamedTemporaryFile()
341 try: 342 try:
342 try: 343 try:
343 command = ['svn', 'checkout', '--depth', 'empty', '-q', 344 # Description
344 options.svn_repo, temp_dir] 345 temp_file.write(description)
345 gclient_utils.CheckCall(command) 346 temp_file.flush()
346 347
347 # TODO(maruel): Use a subdirectory per user? 348 # Diff file
348 current_time = str(datetime.datetime.now()).replace(':', '.') 349 current_time = str(datetime.datetime.now()).replace(':', '.')
349 file_name = (EscapeDot(options.user) + '.' + EscapeDot(options.name) + 350 file_name = (EscapeDot(options.user) + '.' + EscapeDot(options.name) +
350 '.%s.diff' % current_time) 351 '.%s.diff' % current_time)
351 full_path = os.path.join(temp_dir, file_name) 352 full_path = os.path.join(temp_dir, file_name)
352 full_url = options.svn_repo + '/' + file_name 353 gclient_utils.FileWrite(full_path, options.diff, 'wb')
353 file_found = False 354
354 try: 355 # Committing it will trigger a try job.
355 gclient_utils.CheckCall(['svn', 'ls', full_url], print_error=False) 356 command = ['svn', 'import', '-q', temp_dir, options.svn_repo, '--file',
356 file_found = True 357 temp_file.name]
357 except gclient_utils.CheckCallError: 358 gclient_utils.CheckCall(command)
358 pass
359 if file_found:
360 # The file already exists in the repo. Note that commiting a file is a
361 # no-op if the file's content (the diff) is not modified. This is why
362 # the file name contains the date and time.
363 gclient_utils.CheckCall(['svn', 'update', full_path],
364 print_error=False)
365 gclient_utils.FileWrite(full_path, options.diff, 'wb')
366 else:
367 # Add the file to the repo.
368 gclient_utils.FileWrite(full_path, options.diff, 'wb')
369 gclient_utils.CheckCall(["svn", "add", full_path], print_error=False)
370 temp_file.write(description)
371 temp_file.flush()
372 gclient_utils.CheckCall(["svn", "commit", full_path, '--file',
373 temp_file.name], print_error=False)
374 except gclient_utils.CheckCallError, e: 359 except gclient_utils.CheckCallError, e:
375 out = e.stdout 360 out = e.stdout
376 if e.stderr: 361 if e.stderr:
377 out += e.stderr 362 out += e.stderr
378 raise NoTryServerAccess(' '.join(e.command) + '\nOuput:\n' + out) 363 raise NoTryServerAccess(' '.join(e.command) + '\nOuput:\n' + out)
379 finally: 364 finally:
380 temp_file.close() 365 temp_file.close()
381 shutil.rmtree(temp_dir, True) 366 shutil.rmtree(temp_dir, True)
382 367
383 368
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 except (InvalidScript, NoTryServerAccess), e: 687 except (InvalidScript, NoTryServerAccess), e:
703 if swallow_exception: 688 if swallow_exception:
704 return 1 689 return 1
705 print e 690 print e
706 return 1 691 return 1
707 return 0 692 return 0
708 693
709 694
710 if __name__ == "__main__": 695 if __name__ == "__main__":
711 sys.exit(TryChange(None, [], False)) 696 sys.exit(TryChange(None, [], False))
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