| OLD | NEW |
| 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 | 5 |
| 6 import getpass | 6 import getpass |
| 7 import optparse | 7 import optparse |
| 8 import os | 8 import os |
| 9 import subprocess | 9 import subprocess |
| 10 import tempfile | 10 import tempfile |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 def GetRietveldIssueNumber(): | 55 def GetRietveldIssueNumber(): |
| 56 return Backquote(['git', 'config', | 56 return Backquote(['git', 'config', |
| 57 'branch.%s.rietveldissue' % GetBranchName()]) | 57 'branch.%s.rietveldissue' % GetBranchName()]) |
| 58 | 58 |
| 59 | 59 |
| 60 def GetRietveldPatchsetNumber(): | 60 def GetRietveldPatchsetNumber(): |
| 61 return Backquote(['git', 'config', | 61 return Backquote(['git', 'config', |
| 62 'branch.%s.rietveldpatchset' % GetBranchName()]) | 62 'branch.%s.rietveldpatchset' % GetBranchName()]) |
| 63 | 63 |
| 64 | 64 |
| 65 def GetMungedDiff(branch): | 65 def GetMungedDiff(branch, prefix='src/'): |
| 66 """Get the diff we'll send to the try server. We munge paths to match svn.""" | 66 """Get the diff we'll send to the try server. We munge paths to match svn.""" |
| 67 # Make the following changes: | 67 # Make the following changes: |
| 68 # - Prepend "src/" to paths as svn is expecting | 68 # - Prepend "src/" (or some other prefix) to paths as svn is expecting |
| 69 # - In the case of added files, replace /dev/null with the path to the file | 69 # - In the case of added files, replace /dev/null with the path to the file |
| 70 # being added. | 70 # being added. |
| 71 output = [] | 71 output = [] |
| 72 if not branch: | 72 if not branch: |
| 73 # Try to guess the upstream branch. | 73 # Try to guess the upstream branch. |
| 74 branch = Backquote(['git', 'cl', 'upstream']) | 74 branch = Backquote(['git', 'cl', 'upstream']) |
| 75 diff = subprocess.Popen(['git', 'diff-tree', '-p', '--no-prefix', | 75 diff = subprocess.Popen(['git', 'diff-tree', '-p', '--no-prefix', |
| 76 branch, 'HEAD'], | 76 branch, 'HEAD'], |
| 77 stdout=subprocess.PIPE).stdout.readlines() | 77 stdout=subprocess.PIPE).stdout.readlines() |
| 78 for i in range(len(diff)): | 78 for i in range(len(diff)): |
| 79 line = diff[i] | 79 line = diff[i] |
| 80 if line.startswith('--- /dev/null'): | 80 if line.startswith('--- /dev/null'): |
| 81 line = '--- %s' % diff[i+1][4:] | 81 line = '--- %s' % prefix + diff[i+1][4:] |
| 82 elif line.startswith('--- ') or line.startswith('+++ '): | 82 elif line.startswith('--- ') or line.startswith('+++ '): |
| 83 line = line[0:4] + 'src/' + line[4:] | 83 line = line[0:4] + prefix + line[4:] |
| 84 output.append(line) | 84 output.append(line) |
| 85 | 85 |
| 86 munged_diff = ''.join(output) | 86 munged_diff = ''.join(output) |
| 87 if len(munged_diff.strip()) == 0: | 87 if len(munged_diff.strip()) == 0: |
| 88 raise Exception("Patch was empty, did you give the right remote branch?") | 88 raise Exception("Patch was empty, did you give the right remote branch?") |
| 89 | 89 |
| 90 return munged_diff | 90 return munged_diff |
| 91 | 91 |
| 92 | 92 |
| 93 def ValidEmail(email): | 93 def ValidEmail(email): |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 if options.revision: | 169 if options.revision: |
| 170 args.extend(['-r', options.revision]) | 170 args.extend(['-r', options.revision]) |
| 171 if GetRietveldPatchsetNumber(): | 171 if GetRietveldPatchsetNumber(): |
| 172 args.extend([ | 172 args.extend([ |
| 173 '--issue', GetRietveldIssueNumber(), | 173 '--issue', GetRietveldIssueNumber(), |
| 174 '--patchset', GetRietveldPatchsetNumber(), | 174 '--patchset', GetRietveldPatchsetNumber(), |
| 175 ]) | 175 ]) |
| 176 | 176 |
| 177 print sendmsg | 177 print sendmsg |
| 178 TryChange(args=args) | 178 TryChange(args=args) |
| OLD | NEW |