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 StringIO | 10 import StringIO |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 704 def UserEditedLog(starting_text): | 704 def UserEditedLog(starting_text): |
| 705 """Given some starting text, let the user edit it and return the result.""" | 705 """Given some starting text, let the user edit it and return the result.""" |
| 706 editor = os.getenv('EDITOR', 'vi') | 706 editor = os.getenv('EDITOR', 'vi') |
| 707 | 707 |
| 708 (file_handle, filename) = tempfile.mkstemp() | 708 (file_handle, filename) = tempfile.mkstemp() |
| 709 fileobj = os.fdopen(file_handle, 'w') | 709 fileobj = os.fdopen(file_handle, 'w') |
| 710 fileobj.write(starting_text) | 710 fileobj.write(starting_text) |
| 711 fileobj.close() | 711 fileobj.close() |
| 712 | 712 |
| 713 # Open up the default editor in the system to get the CL description. | 713 # Open up the default editor in the system to get the CL description. |
| 714 ret = subprocess.call(editor + ' ' + filename, shell=True) | 714 try: |
| 715 if ret != 0: | 715 cmd = '%s %s' % (GetEditor(), filename) |
|
TVL
2011/03/14 20:53:38
um, GetEditor() doesn't exist in here, and there i
Mohamed Mansour
2011/03/14 20:58:17
Done.
| |
| 716 if sys.platform == 'win32' and os.environ.get('TERM') == 'msys': | |
| 717 # Msysgit requires the usage of 'env' to be present. | |
| 718 cmd = 'env ' + cmd | |
| 719 # shell=True to allow the shell to handle all forms of quotes in $EDITOR. | |
| 720 subprocess.check_call(cmd, shell=True) | |
| 721 fileobj = open(filename) | |
| 722 text = fileobj.read() | |
| 723 fileobj.close() | |
| 724 finally: | |
| 716 os.remove(filename) | 725 os.remove(filename) |
| 717 return | |
| 718 fileobj = open(filename) | |
| 719 text = fileobj.read() | |
| 720 fileobj.close() | |
| 721 | 726 |
| 722 os.remove(filename) | 727 if not result: |
| 728 return 0 | |
| 723 | 729 |
| 724 stripcomment_re = re.compile(r'^#.*$', re.MULTILINE) | 730 stripcomment_re = re.compile(r'^#.*$', re.MULTILINE) |
| 725 return stripcomment_re.sub('', text).strip() | 731 return stripcomment_re.sub('', text).strip() |
| 726 | 732 |
| 727 | 733 |
| 728 def ConvertToInteger(inputval): | 734 def ConvertToInteger(inputval): |
| 729 """Convert a string to integer, but returns either an int or None.""" | 735 """Convert a string to integer, but returns either an int or None.""" |
| 730 try: | 736 try: |
| 731 return int(inputval) | 737 return int(inputval) |
| 732 except (TypeError, ValueError): | 738 except (TypeError, ValueError): |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1408 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 1414 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
| 1409 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 1415 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 1410 | 1416 |
| 1411 # Not a known command. Default to help. | 1417 # Not a known command. Default to help. |
| 1412 GenUsage(parser, 'help') | 1418 GenUsage(parser, 'help') |
| 1413 return CMDhelp(parser, argv) | 1419 return CMDhelp(parser, argv) |
| 1414 | 1420 |
| 1415 | 1421 |
| 1416 if __name__ == '__main__': | 1422 if __name__ == '__main__': |
| 1417 sys.exit(main(sys.argv[1:])) | 1423 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |