| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Repo lives in ~evanm/projects/git-try -- feel free to send patches. | 3 # Repo lives in ~evanm/projects/git-try -- feel free to send patches. |
| 4 | 4 |
| 5 import getpass | 5 import getpass |
| 6 import optparse | 6 import optparse |
| 7 import os | 7 import os |
| 8 import subprocess | 8 import subprocess |
| 9 import tempfile | 9 import tempfile |
| 10 import traceback | 10 import traceback |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 """Return name of current git branch.""" | 38 """Return name of current git branch.""" |
| 39 branch = Backquote(['git', 'symbolic-ref', 'HEAD']) | 39 branch = Backquote(['git', 'symbolic-ref', 'HEAD']) |
| 40 if not branch.startswith('refs/heads/'): | 40 if not branch.startswith('refs/heads/'): |
| 41 raise "Couldn't figure out branch name" | 41 raise "Couldn't figure out branch name" |
| 42 branch = branch[len('refs/heads/'):] | 42 branch = branch[len('refs/heads/'):] |
| 43 return branch | 43 return branch |
| 44 | 44 |
| 45 | 45 |
| 46 def GetPatchName(): | 46 def GetPatchName(): |
| 47 """Construct a name for this patch.""" | 47 """Construct a name for this patch.""" |
| 48 # TODO: perhaps include the hash of the current commit, to distinguish | 48 short_sha = Backquote(['git', 'rev-parse', '--short=4', 'HEAD']) |
| 49 # patches? | 49 return GetBranchName() + '-' + short_sha |
| 50 return GetBranchName() | |
| 51 | 50 |
| 52 | 51 |
| 53 def GetRevision(): | 52 def GetRevision(): |
| 54 """Get the latest Subversion revision number.""" | 53 """Get the latest Subversion revision number.""" |
| 55 for line in Backquote(['git', 'svn', 'info']).split('\n'): | 54 for line in Backquote(['git', 'svn', 'info']).split('\n'): |
| 56 if line.startswith('Revision:'): | 55 if line.startswith('Revision:'): |
| 57 return line[len('Revision:'):].strip() | 56 return line[len('Revision:'):].strip() |
| 58 raise "Couldn't figure out latest revision" | 57 raise "Couldn't figure out latest revision" |
| 59 | 58 |
| 60 | 59 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 user = email.partition('@')[0] | 168 user = email.partition('@')[0] |
| 170 args = [ | 169 args = [ |
| 171 '--use_svn', | 170 '--use_svn', |
| 172 '--svn_repo', 'svn://svn.chromium.org/chrome-try/try', | 171 '--svn_repo', 'svn://svn.chromium.org/chrome-try/try', |
| 173 '-u', user, | 172 '-u', user, |
| 174 '-e', email, | 173 '-e', email, |
| 175 '-n', patch_name, | 174 '-n', patch_name, |
| 176 '-r', GetRevision(), | 175 '-r', GetRevision(), |
| 177 '--diff', diff_file.name, | 176 '--diff', diff_file.name, |
| 178 ] | 177 ] |
| 178 if options.bot: |
| 179 args.extend(['--bot', options.bot]) |
| 180 if options.clobber: |
| 181 args.append('--clobber') |
| 179 if GetRietveldPatchsetNumber(): | 182 if GetRietveldPatchsetNumber(): |
| 180 args.extend([ | 183 args.extend([ |
| 181 '--issue', GetRietveldIssueNumber(), | 184 '--issue', GetRietveldIssueNumber(), |
| 182 '--patchset', GetRietveldPatchsetNumber(), | 185 '--patchset', GetRietveldPatchsetNumber(), |
| 183 ]) | 186 ]) |
| 184 TryChange(args=args) | 187 TryChange(args=args) |
| OLD | NEW |