Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Side by Side Diff: revert.py

Issue 125253: Fix revert.py which was broken on r18272. (Closed)
Patch Set: Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests/revert_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 reviewers overrides the blames email addresses for review email.""" 85 reviewers overrides the blames email addresses for review email."""
86 86
87 # Use the oldest revision as the primary revision. 87 # Use the oldest revision as the primary revision.
88 changename = "revert%d" % revisions[len(revisions)-1] 88 changename = "revert%d" % revisions[len(revisions)-1]
89 if not force and os.path.exists(gcl.GetChangelistInfoFile(changename)): 89 if not force and os.path.exists(gcl.GetChangelistInfoFile(changename)):
90 print "Error, change %s already exist." % changename 90 print "Error, change %s already exist." % changename
91 return 1 91 return 1
92 92
93 # Move to the repository root and make the revision numbers sorted in 93 # Move to the repository root and make the revision numbers sorted in
94 # decreasing order. 94 # decreasing order.
95 os.chdir(gcl.GetRepositoryRoot()) 95 local_root = gcl.GetRepositoryRoot()
96 os.chdir(local_root)
96 revisions.sort(reverse=True) 97 revisions.sort(reverse=True)
97 revisions_string = ",".join([str(rev) for rev in revisions]) 98 revisions_string = ",".join([str(rev) for rev in revisions])
98 revisions_string_rev = ",".join([str(-rev) for rev in revisions]) 99 revisions_string_rev = ",".join([str(-rev) for rev in revisions])
99 100
100 # Get all the modified files by the revision. We'll use this list to optimize 101 # Get all the modified files by the revision. We'll use this list to optimize
101 # the svn merge. 102 # the svn merge.
102 logs = [] 103 logs = []
103 for revision in revisions: 104 for revision in revisions:
104 logs.extend(CaptureSVNLog(["-r", str(revision), "-v"])) 105 logs.extend(CaptureSVNLog(["-r", str(revision), "-v"]))
105 106
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 os.chdir('..') 215 os.chdir('..')
215 216
216 # Transform files_status from a dictionary to a list of tuple. 217 # Transform files_status from a dictionary to a list of tuple.
217 files_status = [(files_status[file], file) for file in files] 218 files_status = [(files_status[file], file) for file in files]
218 219
219 description = "Reverting %s." % revisions_string 220 description = "Reverting %s." % revisions_string
220 if message: 221 if message:
221 description += "\n\n" 222 description += "\n\n"
222 description += message 223 description += message
223 # Don't use gcl.Change() since it prompts the user for infos. 224 # Don't use gcl.Change() since it prompts the user for infos.
224 change_info = gcl.ChangeInfo(name=changename, issue='', 225 change_info = gcl.ChangeInfo(changename, 0, 0, description, files_status,
225 description=description, files=files_status) 226 local_root)
226 change_info.Save() 227 change_info.Save()
227 228
228 upload_args = ['--no_presubmit', '-r', ",".join(reviewers)] 229 upload_args = ['--no_presubmit', '-r', ",".join(reviewers)]
229 if send_email: 230 if send_email:
230 upload_args.append('--send_mail') 231 upload_args.append('--send_mail')
231 if commit: 232 if commit:
232 upload_args.append('--no_try') 233 upload_args.append('--no_try')
233 gcl.UploadCL(change_info, upload_args) 234 gcl.UploadCL(change_info, upload_args)
234 235
235 retcode = 0 236 retcode = 0
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 print "".join(e.args) 285 print "".join(e.args)
285 print "You can use the --force flag to revert the files." 286 print "You can use the --force flag to revert the files."
286 except OutsideOfCheckout, e: 287 except OutsideOfCheckout, e:
287 print "Your repository doesn't contain ", str(e) 288 print "Your repository doesn't contain ", str(e)
288 289
289 return retcode 290 return retcode
290 291
291 292
292 if __name__ == "__main__": 293 if __name__ == "__main__":
293 sys.exit(Main(sys.argv)) 294 sys.exit(Main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | tests/revert_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698