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 | |
714 try: | 713 try: |
715 subprocess.check_call(['env', editor, filename], shell=True) | 714 subprocess.check_call(['env', editor, filename]) |
716 fileobj = open(filename) | 715 fileobj = open(filename) |
717 result = fileobj.read() | 716 result = fileobj.read() |
718 fileobj.close() | 717 fileobj.close() |
719 finally: | 718 finally: |
720 os.remove(filename) | 719 os.remove(filename) |
721 | 720 |
722 if not result: | 721 if not result: |
723 return | 722 return |
724 | 723 |
725 stripcomment_re = re.compile(r'^#.*$', re.MULTILINE) | 724 stripcomment_re = re.compile(r'^#.*$', re.MULTILINE) |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1397 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 1396 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
1398 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 1397 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
1399 | 1398 |
1400 # Not a known command. Default to help. | 1399 # Not a known command. Default to help. |
1401 GenUsage(parser, 'help') | 1400 GenUsage(parser, 'help') |
1402 return CMDhelp(parser, argv) | 1401 return CMDhelp(parser, argv) |
1403 | 1402 |
1404 | 1403 |
1405 if __name__ == '__main__': | 1404 if __name__ == '__main__': |
1406 sys.exit(main(sys.argv[1:])) | 1405 sys.exit(main(sys.argv[1:])) |
OLD | NEW |