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 # Msysgit requires the usage of 'env' to be present. The only way to | |
| 715 # accomplish that is by reading the environment variable for mingw\bin. | |
| 716 cmd = [editor, filename] | |
| 717 if sys.platform == 'win32': | |
|
M-A Ruel
2011/03/12 18:27:28
same
Mohamed Mansour
2011/03/12 18:36:57
Done.
| |
| 718 msysgit_found = os.environ['PATH'].find('mingw\\bin') != -1 | |
| 719 if msysgit_found: | |
| 720 cmd.insert(0, 'env') | |
| 714 try: | 721 try: |
| 715 subprocess.check_call(['env', editor, filename], shell=True) | 722 subprocess.check_call(cmd) |
| 716 fileobj = open(filename) | 723 fileobj = open(filename) |
| 717 result = fileobj.read() | 724 result = fileobj.read() |
| 718 fileobj.close() | 725 fileobj.close() |
| 719 finally: | 726 finally: |
| 720 os.remove(filename) | 727 os.remove(filename) |
| 721 | 728 |
| 722 if not result: | 729 if not result: |
| 723 return | 730 return |
| 724 | 731 |
| 725 stripcomment_re = re.compile(r'^#.*$', re.MULTILINE) | 732 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 ' | 1415 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
| 1409 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 1416 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 1410 | 1417 |
| 1411 # Not a known command. Default to help. | 1418 # Not a known command. Default to help. |
| 1412 GenUsage(parser, 'help') | 1419 GenUsage(parser, 'help') |
| 1413 return CMDhelp(parser, argv) | 1420 return CMDhelp(parser, argv) |
| 1414 | 1421 |
| 1415 | 1422 |
| 1416 if __name__ == '__main__': | 1423 if __name__ == '__main__': |
| 1417 sys.exit(main(sys.argv[1:])) | 1424 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |