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 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 644 | 644 |
| 645 def UserEditedLog(starting_text): | 645 def UserEditedLog(starting_text): |
| 646 """Given some starting text, let the user edit it and return the result.""" | 646 """Given some starting text, let the user edit it and return the result.""" |
| 647 editor = os.getenv('EDITOR', 'vi') | 647 editor = os.getenv('EDITOR', 'vi') |
| 648 | 648 |
| 649 (file_handle, filename) = tempfile.mkstemp() | 649 (file_handle, filename) = tempfile.mkstemp() |
| 650 fileobj = os.fdopen(file_handle, 'w') | 650 fileobj = os.fdopen(file_handle, 'w') |
| 651 fileobj.write(starting_text) | 651 fileobj.write(starting_text) |
| 652 fileobj.close() | 652 fileobj.close() |
| 653 | 653 |
| 654 ret = subprocess.call(editor + ' ' + filename, shell=True) | 654 ret = subprocess.call(['env', editor, filename], shell=True) |
|
M-A Ruel
2011/03/12 00:35:31
Same comment as for http://codereview.chromium.org
| |
| 655 if ret != 0: | 655 if ret != 0: |
| 656 os.remove(filename) | 656 os.remove(filename) |
| 657 return | 657 return |
| 658 | 658 |
| 659 fileobj = open(filename) | 659 fileobj = open(filename) |
| 660 text = fileobj.read() | 660 text = fileobj.read() |
| 661 fileobj.close() | 661 fileobj.close() |
| 662 os.remove(filename) | 662 os.remove(filename) |
| 663 stripcomment_re = re.compile(r'^#.*$', re.MULTILINE) | 663 stripcomment_re = re.compile(r'^#.*$', re.MULTILINE) |
| 664 return stripcomment_re.sub('', text).strip() | 664 return stripcomment_re.sub('', text).strip() |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1314 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 1314 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
| 1315 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 1315 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 1316 | 1316 |
| 1317 # Not a known command. Default to help. | 1317 # Not a known command. Default to help. |
| 1318 GenUsage(parser, 'help') | 1318 GenUsage(parser, 'help') |
| 1319 return CMDhelp(parser, argv) | 1319 return CMDhelp(parser, argv) |
| 1320 | 1320 |
| 1321 | 1321 |
| 1322 if __name__ == '__main__': | 1322 if __name__ == '__main__': |
| 1323 sys.exit(main(sys.argv[1:])) | 1323 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |