OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 | 5 |
6 """Client-side script to send a try job to the try server. It communicates to | 6 """Client-side script to send a try job to the try server. It communicates to |
7 the try server by either writting to a svn repository or by directly connecting | 7 the try server by either writting to a svn repository or by directly connecting |
8 to the server by HTTP. | 8 to the server by HTTP. |
9 """ | 9 """ |
10 | 10 |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 # Windows' svn.exe has no clue about cygwin paths. Hence force to use | 394 # Windows' svn.exe has no clue about cygwin paths. Hence force to use |
395 # the cygwin version in this particular context. | 395 # the cygwin version in this particular context. |
396 exe = "/usr/bin/svn" | 396 exe = "/usr/bin/svn" |
397 else: | 397 else: |
398 exe = "svn" | 398 exe = "svn" |
399 command = [exe, 'import', '-q', temp_dir, options.svn_repo, '--file', | 399 command = [exe, 'import', '-q', temp_dir, options.svn_repo, '--file', |
400 temp_file.name] | 400 temp_file.name] |
401 if scm.SVN.AssertVersion("1.5")[0]: | 401 if scm.SVN.AssertVersion("1.5")[0]: |
402 command.append('--no-ignore') | 402 command.append('--no-ignore') |
403 | 403 |
404 gclient_utils.CheckCall(command) | 404 subprocess2.check_output(command, stdout=subprocess2.VOID) |
405 except gclient_utils.CheckCallError, e: | 405 except subprocess2.CalledProcessError, e: |
406 out = e.stdout | 406 out = e.stdout |
407 if e.stderr: | 407 if e.stderr: |
408 out += e.stderr | 408 out += e.stderr |
409 raise NoTryServerAccess(' '.join(e.command) + '\nOuput:\n' + out) | 409 raise NoTryServerAccess(' '.join(e.command) + '\nOuput:\n' + out) |
410 finally: | 410 finally: |
411 temp_file.close() | 411 temp_file.close() |
412 shutil.rmtree(temp_dir, True) | 412 shutil.rmtree(temp_dir, True) |
413 | 413 |
414 | 414 |
415 def PrintSuccess(options): | 415 def PrintSuccess(options): |
(...skipping 20 matching lines...) Expand all Loading... |
436 __pychecker__ = 'no-returnvalues' | 436 __pychecker__ = 'no-returnvalues' |
437 real_path = path.split('@')[0] | 437 real_path = path.split('@')[0] |
438 logging.info("GuessVCS(%s)" % path) | 438 logging.info("GuessVCS(%s)" % path) |
439 # Subversion has a .svn in all working directories. | 439 # Subversion has a .svn in all working directories. |
440 if os.path.isdir(os.path.join(real_path, '.svn')): | 440 if os.path.isdir(os.path.join(real_path, '.svn')): |
441 return SVN(options, path) | 441 return SVN(options, path) |
442 | 442 |
443 # Git has a command to test if you're in a git tree. | 443 # Git has a command to test if you're in a git tree. |
444 # Try running it, but don't die if we don't have git installed. | 444 # Try running it, but don't die if we don't have git installed. |
445 try: | 445 try: |
446 gclient_utils.CheckCall(['git', 'rev-parse', '--is-inside-work-tree'], | 446 subprocess2.check_output( |
447 cwd=real_path) | 447 ['git', 'rev-parse', '--is-inside-work-tree'], cwd=real_path, |
| 448 stdout=subprocess2.VOID) |
448 return GIT(options, path) | 449 return GIT(options, path) |
449 except gclient_utils.CheckCallError, e: | 450 except subprocess2.CalledProcessError, e: |
450 if e.returncode != errno.ENOENT and e.returncode != 128: | 451 if e.returncode != errno.ENOENT and e.returncode != 128: |
451 # ENOENT == 2 = they don't have git installed. | 452 # ENOENT == 2 = they don't have git installed. |
452 # 128 = git error code when not in a repo. | 453 # 128 = git error code when not in a repo. |
453 logging.warning('Unexpected error code: %s' % e.returncode) | 454 logging.warning('Unexpected error code: %s' % e.returncode) |
454 raise | 455 raise |
455 raise NoTryServerAccess("Could not guess version control system. " | 456 raise NoTryServerAccess("Could not guess version control system. " |
456 "Are you in a working copy directory?") | 457 "Are you in a working copy directory?") |
457 | 458 |
458 | 459 |
459 def GetMungedDiff(path_diff, diff): | 460 def GetMungedDiff(path_diff, diff): |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 return 1 | 764 return 1 |
764 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 765 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
765 print >> sys.stderr, e | 766 print >> sys.stderr, e |
766 return 1 | 767 return 1 |
767 return 0 | 768 return 0 |
768 | 769 |
769 | 770 |
770 if __name__ == "__main__": | 771 if __name__ == "__main__": |
771 fix_encoding.fix_encoding() | 772 fix_encoding.fix_encoding() |
772 sys.exit(TryChange(None, [], False)) | 773 sys.exit(TryChange(None, [], False)) |
OLD | NEW |