OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2009 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 # Tool to quickly revert a change. | 6 # Tool to quickly revert a change. |
7 | 7 |
8 import exceptions | 8 import exceptions |
9 import optparse | 9 import optparse |
10 import os | 10 import os |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 if blames: | 128 if blames: |
129 print "Blaming %s\n" % ",".join(blames) | 129 print "Blaming %s\n" % ",".join(blames) |
130 if reviewers != blames: | 130 if reviewers != blames: |
131 print "Emailing %s\n" % ",".join(reviewers) | 131 print "Emailing %s\n" % ",".join(reviewers) |
132 print "These files were modified in %s:" % revisions_string | 132 print "These files were modified in %s:" % revisions_string |
133 print "\n".join(files) | 133 print "\n".join(files) |
134 print "" | 134 print "" |
135 | 135 |
136 # Make sure these files are unmodified with svn status. | 136 # Make sure these files are unmodified with svn status. |
137 status = gcl.GetSVNStatus(files) | 137 status = gclient.CaptureSVNStatus(files) |
138 if status: | 138 if status: |
139 if force: | 139 if force: |
140 # TODO(maruel): Use the tool to correctly revert '?' files. | 140 # TODO(maruel): Use the tool to correctly revert '?' files. |
141 gcl.RunShell(["svn", "revert"] + files) | 141 gcl.RunShell(["svn", "revert"] + files) |
142 else: | 142 else: |
143 raise ModifiedFile(status) | 143 raise ModifiedFile(status) |
144 # svn up on each of these files | 144 # svn up on each of these files |
145 gcl.RunShell(["svn", "up"] + files) | 145 gcl.RunShell(["svn", "up"] + files) |
146 | 146 |
147 files_status = {} | 147 files_status = {} |
(...skipping 23 matching lines...) Expand all Loading... |
171 | 171 |
172 print "Reverting %s in %s/" % (revisions_string, root) | 172 print "Reverting %s in %s/" % (revisions_string, root) |
173 if need_to_update: | 173 if need_to_update: |
174 # Make sure '.' revision is high enough otherwise merge will be | 174 # Make sure '.' revision is high enough otherwise merge will be |
175 # unhappy. | 175 # unhappy. |
176 retcode = gcl.RunShellWithReturnCode(['svn', 'up', '.', '-N'])[1] | 176 retcode = gcl.RunShellWithReturnCode(['svn', 'up', '.', '-N'])[1] |
177 if retcode: | 177 if retcode: |
178 print 'svn up . -N failed in %s/.' % root | 178 print 'svn up . -N failed in %s/.' % root |
179 return retcode | 179 return retcode |
180 | 180 |
| 181 # TODO(maruel): BUG WITH ONLY ONE FILE. |
181 command = ["svn", "merge", "-c", revisions_string_rev] | 182 command = ["svn", "merge", "-c", revisions_string_rev] |
182 command.extend(file_list) | 183 command.extend(file_list) |
183 (output, retcode) = gcl.RunShellWithReturnCode(command, print_output=True) | 184 (output, retcode) = gcl.RunShellWithReturnCode(command, print_output=True) |
184 if retcode: | 185 if retcode: |
185 print "'%s' failed:" % command | 186 print "'%s' failed:" % command |
186 return retcode | 187 return retcode |
187 | 188 |
188 # Grab the status | 189 # Grab the status |
189 lines = output.split('\n') | 190 lines = output.split('\n') |
190 for line in lines: | 191 for line in lines: |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 print "".join(e.args) | 276 print "".join(e.args) |
276 print "You can use the --force flag to revert the files." | 277 print "You can use the --force flag to revert the files." |
277 except OutsideOfCheckout, e: | 278 except OutsideOfCheckout, e: |
278 print "Your repository doesn't contain ", str(e) | 279 print "Your repository doesn't contain ", str(e) |
279 | 280 |
280 return retcode | 281 return retcode |
281 | 282 |
282 | 283 |
283 if __name__ == "__main__": | 284 if __name__ == "__main__": |
284 sys.exit(Main(sys.argv)) | 285 sys.exit(Main(sys.argv)) |
OLD | NEW |