OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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/git repository or by directly | 7 the try server by either writting to a svn/git repository or by directly |
8 connecting to the server by HTTP. | 8 connecting to the server by HTTP. |
9 """ | 9 """ |
10 | 10 |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 def add_and_commit(filename, comment_filename): | 633 def add_and_commit(filename, comment_filename): |
634 patch_git('add', filename) | 634 patch_git('add', filename) |
635 patch_git('commit', '-F', comment_filename) | 635 patch_git('commit', '-F', comment_filename) |
636 | 636 |
637 assert scm.GIT.IsInsideWorkTree(patch_dir) | 637 assert scm.GIT.IsInsideWorkTree(patch_dir) |
638 assert not scm.GIT.IsWorkTreeDirty(patch_dir) | 638 assert not scm.GIT.IsWorkTreeDirty(patch_dir) |
639 | 639 |
640 with _PrepareDescriptionAndPatchFiles(description, options) as ( | 640 with _PrepareDescriptionAndPatchFiles(description, options) as ( |
641 patch_filename, description_filename): | 641 patch_filename, description_filename): |
642 logging.info('Committing patch') | 642 logging.info('Committing patch') |
643 target_branch = ('refs/patches/' + | 643 target_branch = 'refs/patches/%s/%s' % ( |
644 os.path.basename(patch_filename).replace(' ','-')) | 644 Escape(options.user), |
| 645 os.path.basename(patch_filename).replace(' ','_')) |
645 target_filename = os.path.join(patch_dir, 'patch.diff') | 646 target_filename = os.path.join(patch_dir, 'patch.diff') |
646 branch_file = os.path.join(patch_dir, GIT_BRANCH_FILE) | 647 branch_file = os.path.join(patch_dir, GIT_BRANCH_FILE) |
647 try: | 648 try: |
648 # Crete a new branch and put the patch there | 649 # Create a new branch and put the patch there. |
649 patch_git('checkout', '--orphan', target_branch) | 650 patch_git('checkout', '--orphan', target_branch) |
650 patch_git('reset') | 651 patch_git('reset') |
651 patch_git('clean', '-f') | 652 patch_git('clean', '-f') |
652 shutil.copyfile(patch_filename, target_filename) | 653 shutil.copyfile(patch_filename, target_filename) |
653 add_and_commit(target_filename, description_filename) | 654 add_and_commit(target_filename, description_filename) |
654 assert not scm.GIT.IsWorkTreeDirty(patch_dir) | 655 assert not scm.GIT.IsWorkTreeDirty(patch_dir) |
655 | 656 |
656 # Update the branch file in the master | 657 # Update the branch file in the master |
657 patch_git('checkout', 'master') | 658 patch_git('checkout', 'master') |
658 | 659 |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1120 return 1 | 1121 return 1 |
1121 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 1122 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
1122 print >> sys.stderr, e | 1123 print >> sys.stderr, e |
1123 return 1 | 1124 return 1 |
1124 return 0 | 1125 return 0 |
1125 | 1126 |
1126 | 1127 |
1127 if __name__ == "__main__": | 1128 if __name__ == "__main__": |
1128 fix_encoding.fix_encoding() | 1129 fix_encoding.fix_encoding() |
1129 sys.exit(TryChange(None, None, False)) | 1130 sys.exit(TryChange(None, None, False)) |
OLD | NEW |