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

Side by Side Diff: trychange.py

Issue 223009: Fix svn diff mungling. (Closed)
Patch Set: Created 11 years, 2 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 | no next file » | 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) 2009 The Chromium Authors. All rights reserved. 2 # Copyright (c) 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 """Client-side script to send a try job to the try server. It communicates to 5 """Client-side script to send a try job to the try server. It communicates to
6 the try server by either writting to a svn repository or by directly connecting 6 the try server by either writting to a svn repository or by directly connecting
7 to the server by HTTP. 7 to the server by HTTP.
8 """ 8 """
9 9
10 10
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 # Grabs the diff data. 160 # Grabs the diff data.
161 data = gcl.RunShell(["svn", "diff", "--config-dir", bogus_dir, file]) 161 data = gcl.RunShell(["svn", "diff", "--config-dir", bogus_dir, file])
162 162
163 # We know the diff will be incorrectly formatted. Fix it. 163 # We know the diff will be incorrectly formatted. Fix it.
164 if gcl.IsSVNMoved(file): 164 if gcl.IsSVNMoved(file):
165 # The file is "new" in the patch sense. Generate a homebrew diff. 165 # The file is "new" in the patch sense. Generate a homebrew diff.
166 # We can't use ReadFile() since it's not using binary mode. 166 # We can't use ReadFile() since it's not using binary mode.
167 file_handle = open(file, 'rb') 167 file_handle = open(file, 'rb')
168 file_content = file_handle.read() 168 file_content = file_handle.read()
169 file_handle.close() 169 file_handle.close()
170 # Prepend '+ ' to every lines. 170 # Prepend '+' to every lines.
171 file_content = ['+ ' + i for i in file_content.splitlines(True)] 171 file_content = ['+' + i for i in file_content.splitlines(True)]
172 nb_lines = len(file_content) 172 nb_lines = len(file_content)
173 # We need to use / since patch on unix will fail otherwise. 173 # We need to use / since patch on unix will fail otherwise.
174 file = file.replace('\\', '/') 174 file = file.replace('\\', '/')
175 data = "Index: %s\n" % file 175 data = "Index: %s\n" % file
176 data += ("=============================================================" 176 data += ("============================================================="
177 "======\n") 177 "======\n")
178 # Note: Should we use /dev/null instead? 178 # Note: Should we use /dev/null instead?
179 data += "--- %s\n" % file 179 data += "--- %s\n" % file
180 data += "+++ %s\n" % file 180 data += "+++ %s\n" % file
181 data += "@@ -0,0 +1,%d @@\n" % nb_lines 181 data += "@@ -0,0 +1,%d @@\n" % nb_lines
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 if patch_name == 'Unnamed': 532 if patch_name == 'Unnamed':
533 print "Note: use --name NAME to change the try's name." 533 print "Note: use --name NAME to change the try's name."
534 except (InvalidScript, NoTryServerAccess), e: 534 except (InvalidScript, NoTryServerAccess), e:
535 if swallow_exception: 535 if swallow_exception:
536 return 536 return
537 print e 537 print e
538 538
539 539
540 if __name__ == "__main__": 540 if __name__ == "__main__":
541 TryChange(None, None, False) 541 TryChange(None, None, False)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698