OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 # Copyright (C) 2008 Evan Martin <martine@danga.com> | 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> |
7 | 7 |
8 """A git-command for integrating reviews on Rietveld.""" | 8 """A git-command for integrating reviews on Rietveld.""" |
9 | 9 |
10 import errno | 10 import errno |
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 fileobj.write(starting_text) | 835 fileobj.write(starting_text) |
836 fileobj.close() | 836 fileobj.close() |
837 | 837 |
838 # Open up the default editor in the system to get the CL description. | 838 # Open up the default editor in the system to get the CL description. |
839 try: | 839 try: |
840 cmd = '%s %s' % (editor, filename) | 840 cmd = '%s %s' % (editor, filename) |
841 if sys.platform == 'win32' and os.environ.get('TERM') == 'msys': | 841 if sys.platform == 'win32' and os.environ.get('TERM') == 'msys': |
842 # Msysgit requires the usage of 'env' to be present. | 842 # Msysgit requires the usage of 'env' to be present. |
843 cmd = 'env ' + cmd | 843 cmd = 'env ' + cmd |
844 # shell=True to allow the shell to handle all forms of quotes in $EDITOR. | 844 # shell=True to allow the shell to handle all forms of quotes in $EDITOR. |
845 subprocess.check_call(cmd, shell=True) | 845 try: |
| 846 subprocess.check_call(cmd, shell=True) |
| 847 except subprocess.CalledProcessError, e: |
| 848 DieWithError('Editor returned %d' % e.returncode) |
846 fileobj = open(filename) | 849 fileobj = open(filename) |
847 text = fileobj.read() | 850 text = fileobj.read() |
848 fileobj.close() | 851 fileobj.close() |
849 finally: | 852 finally: |
850 os.remove(filename) | 853 os.remove(filename) |
851 | 854 |
852 if not text: | 855 if not text: |
853 return | 856 return |
854 | 857 |
855 stripcomment_re = re.compile(r'^#.*$', re.MULTILINE) | 858 stripcomment_re = re.compile(r'^#.*$', re.MULTILINE) |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1445 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 1448 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
1446 | 1449 |
1447 # Not a known command. Default to help. | 1450 # Not a known command. Default to help. |
1448 GenUsage(parser, 'help') | 1451 GenUsage(parser, 'help') |
1449 return CMDhelp(parser, argv) | 1452 return CMDhelp(parser, argv) |
1450 | 1453 |
1451 | 1454 |
1452 if __name__ == '__main__': | 1455 if __name__ == '__main__': |
1453 fix_encoding.fix_encoding() | 1456 fix_encoding.fix_encoding() |
1454 sys.exit(main(sys.argv[1:])) | 1457 sys.exit(main(sys.argv[1:])) |
OLD | NEW |