OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """This module uprevs a given package's ebuild to the next revision.""" | 7 """This module uprevs a given package's ebuild to the next revision.""" |
8 | 8 |
9 | 9 |
10 import fileinput | 10 import fileinput |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 for command in commands: | 103 for command in commands: |
104 command_usage += ' %s: %s\n' % (command, _COMMAND_DICTIONARY[command]) | 104 command_usage += ' %s: %s\n' % (command, _COMMAND_DICTIONARY[command]) |
105 commands_str = '|'.join(commands) | 105 commands_str = '|'.join(commands) |
106 print 'Usage: %s FLAGS [%s]\n\n%s\nFlags:%s' % (sys.argv[0], commands_str, | 106 print 'Usage: %s FLAGS [%s]\n\n%s\nFlags:%s' % (sys.argv[0], commands_str, |
107 command_usage, gflags.FLAGS) | 107 command_usage, gflags.FLAGS) |
108 if error_message: | 108 if error_message: |
109 generate_test_report.Die(error_message) | 109 generate_test_report.Die(error_message) |
110 else: | 110 else: |
111 sys.exit(1) | 111 sys.exit(1) |
112 | 112 |
113 def _BranchExists(name): | |
petkov
2010/08/26 03:39:35
Unused? Remove.
| |
114 """Returns True is the branch exists""" | |
115 return _RunCommand('git branch').split().count(name) != 0 | |
113 | 116 |
114 def _PushChange(): | 117 def _PushChange(): |
115 """Pushes changes to the git repository. | 118 """Pushes changes to the git repository. |
116 | 119 |
117 Pushes locals commits from calls to CommitChange to the remote git | 120 Pushes locals commits from calls to CommitChange to the remote git |
118 repository specified by os.pwd. | 121 repository specified by os.pwd. |
119 | 122 |
120 Raises: | 123 Raises: |
121 OSError: Error occurred while pushing. | 124 OSError: Error occurred while pushing. |
122 """ | 125 """ |
123 | 126 |
124 # TODO(sosa) - Add logic for buildbot to check whether other slaves have | 127 # TODO(sosa) - Add logic for buildbot to check whether other slaves have |
125 # completed and push this change only if they have. | 128 # completed and push this change only if they have. |
126 | 129 |
127 # Sanity check to make sure we're on a stabilizing branch before pushing. | 130 # Sanity check to make sure we're on a stabilizing branch before pushing. |
128 if not _CheckOnStabilizingBranch(): | 131 if not _CheckOnStabilizingBranch(): |
129 print 'Not on branch %s so no work found to push. Exiting' % \ | 132 print 'Not on branch %s so no work found to push. Exiting' % \ |
130 _STABLE_BRANCH_NAME | 133 _STABLE_BRANCH_NAME |
131 return | 134 return |
132 | 135 |
133 description = _RunCommand('git log --format=format:%s%n%n%b ' + | 136 description = _RunCommand('git log --format=format:%s%n%n%b ' + |
134 gflags.FLAGS.tracking_branch + '..') | 137 gflags.FLAGS.tracking_branch + '..') |
135 description = 'Marking set of ebuilds as stable\n\n%s' % description | 138 description = 'Marking set of ebuilds as stable\n\n%s' % description |
136 merge_branch_name = 'merge_branch' | 139 merge_branch_name = 'merge_branch' |
137 _RunCommand('git remote update') | 140 _RunCommand('git remote update') |
141 merge_branch = _GitBranch(merge_branch_name) | |
142 merge_branch.CreateBranch() | |
143 if not merge_branch.Exists(): | |
144 generate_test_report.Die('Unable to create merge branch.') | |
138 _RunCommand('git checkout -b %s %s' % ( | 145 _RunCommand('git checkout -b %s %s' % ( |
petkov
2010/08/26 03:39:35
This seems redundant with CreateBranch above. Does
petkov
2010/08/26 16:47:18
Btw, this does emit a "fatal" message:
...
HEAD i
| |
139 merge_branch_name, gflags.FLAGS.tracking_branch)) | 146 merge_branch_name, gflags.FLAGS.tracking_branch)) |
140 _RunCommand('git merge --squash %s' % _STABLE_BRANCH_NAME) | 147 _RunCommand('git merge --squash %s' % _STABLE_BRANCH_NAME) |
141 _RunCommand('git commit -m "%s"' % description) | 148 _RunCommand('git commit -m "%s"' % description) |
142 # Ugh. There has got to be an easier way to push to a tracking branch | 149 # Ugh. There has got to be an easier way to push to a tracking branch |
143 _RunCommand('git config push.default tracking') | 150 _RunCommand('git config push.default tracking') |
144 _RunCommand('git push') | 151 _RunCommand('git push') |
145 | 152 |
146 | 153 |
147 def _RunCommand(command): | 154 def _RunCommand(command): |
148 """Runs a shell command and returns stdout back to caller.""" | 155 """Runs a shell command and returns stdout back to caller.""" |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 'and reset the git repo yourself.' % | 375 'and reset the git repo yourself.' % |
369 (package_list[:index], overlay_directory)) | 376 (package_list[:index], overlay_directory)) |
370 raise e | 377 raise e |
371 elif command == 'push': | 378 elif command == 'push': |
372 _PushChange() | 379 _PushChange() |
373 | 380 |
374 | 381 |
375 if __name__ == '__main__': | 382 if __name__ == '__main__': |
376 main(sys.argv) | 383 main(sys.argv) |
377 | 384 |
OLD | NEW |