Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # git-cl -- a git-command for integrating reviews on Rietveld | 2 # git-cl -- a git-command for integrating reviews on Rietveld |
| 3 # Copyright (C) 2008 Evan Martin <martine@danga.com> | 3 # Copyright (C) 2008 Evan Martin <martine@danga.com> |
| 4 | 4 |
| 5 import errno | 5 import errno |
| 6 import logging | 6 import logging |
| 7 import optparse | 7 import optparse |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 import subprocess | 10 import subprocess |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 989 output = RunGit(['svn', 'dcommit', '--no-rebase']) | 989 output = RunGit(['svn', 'dcommit', '--no-rebase']) |
| 990 finally: | 990 finally: |
| 991 # And then swap back to the original branch and clean up. | 991 # And then swap back to the original branch and clean up. |
| 992 RunGit(['checkout', '-q', cl.GetBranch()]) | 992 RunGit(['checkout', '-q', cl.GetBranch()]) |
| 993 RunGit(['branch', '-D', MERGE_BRANCH]) | 993 RunGit(['branch', '-D', MERGE_BRANCH]) |
| 994 | 994 |
| 995 if cl.GetIssue(): | 995 if cl.GetIssue(): |
| 996 if cmd == 'dcommit' and 'Committed r' in output: | 996 if cmd == 'dcommit' and 'Committed r' in output: |
| 997 revision = re.match('.*?\nCommitted r(\\d+)', output, re.DOTALL).group(1) | 997 revision = re.match('.*?\nCommitted r(\\d+)', output, re.DOTALL).group(1) |
| 998 elif cmd == 'push' and retcode == 0: | 998 elif cmd == 'push' and retcode == 0: |
| 999 revision = output.splitlines()[1].split('\t')[2].split('..')[1] | 999 m = (re.match(r'.*?([a-f0-9]{7})\.\.([a-f0-9]{7})$', l) |
|
evanm
2011/01/12 00:21:06
Can you use longer variable names? ("match" inste
| |
| 1000 for l in output.splitlines(False)) | |
| 1001 m = filter(None, m) | |
| 1002 if not len(m) == 1: | |
|
evanm
2011/01/12 00:21:06
Didn't realize this was valid Python (rather than
| |
| 1003 DieWithError("Couldn't parse ouput to extract the committed hash:\n%s" % | |
| 1004 output) | |
| 1005 revision = m[0].group(2) | |
| 1000 else: | 1006 else: |
| 1001 return 1 | 1007 return 1 |
| 1002 viewvc_url = settings.GetViewVCUrl() | 1008 viewvc_url = settings.GetViewVCUrl() |
| 1003 if viewvc_url and revision: | 1009 if viewvc_url and revision: |
| 1004 cl.description += ('\n\nCommitted: ' + viewvc_url + revision) | 1010 cl.description += ('\n\nCommitted: ' + viewvc_url + revision) |
| 1005 print ('Closing issue ' | 1011 print ('Closing issue ' |
| 1006 '(you may be prompted for your codereview password)...') | 1012 '(you may be prompted for your codereview password)...') |
| 1007 cl.CloseIssue() | 1013 cl.CloseIssue() |
| 1008 cl.SetIssue(0) | 1014 cl.SetIssue(0) |
| 1009 return 0 | 1015 return 0 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1245 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 1251 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
| 1246 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 1252 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 1247 | 1253 |
| 1248 # Not a known command. Default to help. | 1254 # Not a known command. Default to help. |
| 1249 GenUsage(parser, 'help') | 1255 GenUsage(parser, 'help') |
| 1250 return CMDhelp(parser, argv) | 1256 return CMDhelp(parser, argv) |
| 1251 | 1257 |
| 1252 | 1258 |
| 1253 if __name__ == '__main__': | 1259 if __name__ == '__main__': |
| 1254 sys.exit(main(sys.argv[1:])) | 1260 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |