OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 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 | 6 |
7 """Merge Skia into Android.""" | 7 """Merge Skia into Android.""" |
8 | 8 |
9 | 9 |
10 import os | 10 import os |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 | 50 |
51 class MergeIntoAndroid(BuildStep): | 51 class MergeIntoAndroid(BuildStep): |
52 """BuildStep which merges Skia into Android, with a generated Android.mk and | 52 """BuildStep which merges Skia into Android, with a generated Android.mk and |
53 SkUserConfig.h""" | 53 SkUserConfig.h""" |
54 | 54 |
55 def _Run(self): | 55 def _Run(self): |
56 with misc.ChDir(EXTERNAL_SKIA): | 56 with misc.ChDir(EXTERNAL_SKIA): |
57 # Check to see whether there is an upstream yet. | 57 # Check to see whether there is an upstream yet. |
58 if not UPSTREAM_REMOTE_NAME in shell_utils.run([GIT, 'remote', 'show']): | 58 if not UPSTREAM_REMOTE_NAME in shell_utils.run([GIT, 'remote', 'show']): |
59 shell_utils.run([GIT, 'remote', 'add', UPSTREAM_REMOTE_NAME, | 59 try: |
60 SKIA_REPO_URL]) | 60 shell_utils.run([GIT, 'remote', 'add', UPSTREAM_REMOTE_NAME, |
| 61 SKIA_REPO_URL]) |
| 62 except shell_utils.CommandFailedException as e: |
| 63 if 'remote %s already exists' % UPSTREAM_REMOTE_NAME in e.output: |
| 64 # Accept this error. The upstream remote name should have been in |
| 65 # the output of git remote show, which would have made us skip this |
| 66 # redundant command anyway. |
| 67 print ('%s was already added. Why did it not show in git remote' |
| 68 ' show?' % UPSTREAM_REMOTE_NAME) |
| 69 else: |
| 70 raise e |
61 | 71 |
62 # Update the upstream remote. | 72 # Update the upstream remote. |
63 shell_utils.run([GIT, 'fetch', UPSTREAM_REMOTE_NAME]) | 73 shell_utils.run([GIT, 'fetch', UPSTREAM_REMOTE_NAME]) |
64 | 74 |
65 # Create a stack of commits to submit, one at a time, until we reach a | 75 # Create a stack of commits to submit, one at a time, until we reach a |
66 # commit that has already been merged. | 76 # commit that has already been merged. |
67 commit_stack = [] | 77 commit_stack = [] |
68 head = git_utils.ShortHash('HEAD') | 78 head = git_utils.ShortHash('HEAD') |
69 | 79 |
70 print 'HEAD is at %s' % head | 80 print 'HEAD is at %s' % head |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 RepoAbandon(LOCAL_BRANCH_NAME) | 182 RepoAbandon(LOCAL_BRANCH_NAME) |
173 raise BuildStepFailure('git push failed!') | 183 raise BuildStepFailure('git push failed!') |
174 | 184 |
175 # Our branch is no longer needed. Remove it. | 185 # Our branch is no longer needed. Remove it. |
176 shell_utils.run([REPO, 'sync', '-j32', '.']) | 186 shell_utils.run([REPO, 'sync', '-j32', '.']) |
177 shell_utils.run([REPO, 'prune', '.']) | 187 shell_utils.run([REPO, 'prune', '.']) |
178 | 188 |
179 | 189 |
180 if '__main__' == __name__: | 190 if '__main__' == __name__: |
181 sys.exit(BuildStep.RunBuildStep(MergeIntoAndroid)) | 191 sys.exit(BuildStep.RunBuildStep(MergeIntoAndroid)) |
OLD | NEW |