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 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 703 | 703 |
| 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 result = None | 713 # Open up the default editor in the system to get the CL description. |
| 714 cmd = [editor, filename] | |
| 715 if sys.platform == 'win32' and 'mingw\\bin' in os.environ['PATH']: | |
| 716 # Msysgit requires the usage of 'env' to be present. The only way to | |
| 717 # accomplish that is by reading the environment variable for mingw\bin. | |
| 718 cmd.insert(0, 'env') | |
| 714 try: | 719 try: |
| 715 subprocess.check_call(['env', editor, filename], shell=True) | 720 subprocess.check_call(cmd) |
|
TVL
2011/03/14 13:31:54
this has broken macosx and probably link when folk
TVL
2011/03/14 13:42:16
Sorry, it's not env as much as shell=True.
Mohamed Mansour
2011/03/14 14:01:33
Hi TVL, would changing cmd = [editor, filename] to
| |
| 716 fileobj = open(filename) | 721 fileobj = open(filename) |
| 717 result = fileobj.read() | 722 result = fileobj.read() |
| 718 fileobj.close() | 723 fileobj.close() |
| 719 finally: | 724 finally: |
| 720 os.remove(filename) | 725 os.remove(filename) |
| 721 | 726 |
| 722 if not result: | 727 if not result: |
| 723 return | 728 return |
| 724 | 729 |
| 725 stripcomment_re = re.compile(r'^#.*$', re.MULTILINE) | 730 stripcomment_re = re.compile(r'^#.*$', re.MULTILINE) |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1408 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 1413 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
| 1409 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 1414 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 1410 | 1415 |
| 1411 # Not a known command. Default to help. | 1416 # Not a known command. Default to help. |
| 1412 GenUsage(parser, 'help') | 1417 GenUsage(parser, 'help') |
| 1413 return CMDhelp(parser, argv) | 1418 return CMDhelp(parser, argv) |
| 1414 | 1419 |
| 1415 | 1420 |
| 1416 if __name__ == '__main__': | 1421 if __name__ == '__main__': |
| 1417 sys.exit(main(sys.argv[1:])) | 1422 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |