| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 # TODO(hinoka): Use logging. | 6 # TODO(hinoka): Use logging. |
| 7 | 7 |
| 8 import cStringIO | 8 import cStringIO |
| 9 import codecs | 9 import codecs |
| 10 import collections | 10 import collections |
| (...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 # Only try once, since subsequent failures hide the real failure. | 1100 # Only try once, since subsequent failures hide the real failure. |
| 1101 try: | 1101 try: |
| 1102 call(*cmd, tries=1) | 1102 call(*cmd, tries=1) |
| 1103 except SubprocessFailed as e: | 1103 except SubprocessFailed as e: |
| 1104 raise PatchFailed(e.message, e.code, e.output) | 1104 raise PatchFailed(e.message, e.code, e.output) |
| 1105 | 1105 |
| 1106 def apply_gerrit_ref(gerrit_repo, gerrit_ref, root): | 1106 def apply_gerrit_ref(gerrit_repo, gerrit_ref, root): |
| 1107 gerrit_repo = gerrit_repo or 'origin' | 1107 gerrit_repo = gerrit_repo or 'origin' |
| 1108 assert gerrit_ref | 1108 assert gerrit_ref |
| 1109 try: | 1109 try: |
| 1110 base_rev = git('rev-parse', 'HEAD', cwd=root).strip() |
| 1110 git('retry', 'fetch', gerrit_repo, gerrit_ref, cwd=root, tries=1) | 1111 git('retry', 'fetch', gerrit_repo, gerrit_ref, cwd=root, tries=1) |
| 1111 git('reset', '--soft', 'FETCH_HEAD', cwd=root) | 1112 git('checkout', 'FETCH_HEAD', cwd=root) |
| 1113 git('reset', '--soft', base_rev, cwd=root) |
| 1112 except SubprocessFailed as e: | 1114 except SubprocessFailed as e: |
| 1113 raise PatchFailed(e.message, e.code, e.output) | 1115 raise PatchFailed(e.message, e.code, e.output) |
| 1114 | 1116 |
| 1115 def check_flag(flag_file): | 1117 def check_flag(flag_file): |
| 1116 """Returns True if the flag file is present.""" | 1118 """Returns True if the flag file is present.""" |
| 1117 return os.path.isfile(flag_file) | 1119 return os.path.isfile(flag_file) |
| 1118 | 1120 |
| 1119 | 1121 |
| 1120 def delete_flag(flag_file): | 1122 def delete_flag(flag_file): |
| 1121 """Remove bot update flag.""" | 1123 """Remove bot update flag.""" |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1700 except Exception: | 1702 except Exception: |
| 1701 # Unexpected failure. | 1703 # Unexpected failure. |
| 1702 emit_flag(options.flag_file) | 1704 emit_flag(options.flag_file) |
| 1703 raise | 1705 raise |
| 1704 else: | 1706 else: |
| 1705 emit_flag(options.flag_file) | 1707 emit_flag(options.flag_file) |
| 1706 | 1708 |
| 1707 | 1709 |
| 1708 if __name__ == '__main__': | 1710 if __name__ == '__main__': |
| 1709 sys.exit(main()) | 1711 sys.exit(main()) |
| OLD | NEW |