Chromium Code Reviews| Index: gclient_utils.py |
| diff --git a/gclient_utils.py b/gclient_utils.py |
| index ddcce9b17746568b242c6fead28287c1ea834c5f..2d846758263cb206906dac2fd76ebb1b1029de3b 100644 |
| --- a/gclient_utils.py |
| +++ b/gclient_utils.py |
| @@ -678,23 +678,29 @@ class ExecutionQueue(object): |
| work_queue.ready_cond.release() |
| -def GetEditor(git): |
| +def GetEditor(git, git_editor=None): |
| """Returns the most plausible editor to use.""" |
| + terminal = os.environ.get('TERM') |
| + terminal_is_dumb = not terminal or terminal == 'dumb' |
| if git: |
| - editor = os.environ.get('GIT_EDITOR') |
| + editor = os.environ.get('GIT_EDITOR') or git_editor |
| else: |
| editor = os.environ.get('SVN_EDITOR') |
| + if not editor and not (git and terminal_is_dumb): |
| + editor = os.environ.get('VISUAL') |
| if not editor: |
| editor = os.environ.get('EDITOR') |
| if not editor: |
| - if sys.platform.startswith('win'): |
| + if git and terminal_is_dumb: |
| + editor = None |
|
M-A Ruel
2013/05/02 14:13:48
You assume we're going to call git here?
jbroman
2013/05/02 14:27:30
I did this for completeness.
git-commit (et al) i
M-A Ruel
2013/05/02 14:35:17
I'd prefer to document it then. There's no referen
|
| + elif sys.platform.startswith('win'): |
| editor = 'notepad' |
| else: |
| editor = 'vim' |
| return editor |
| -def RunEditor(content, git): |
| +def RunEditor(content, git, git_editor=None): |
| """Opens up the default editor in the system to get the CL description.""" |
| file_handle, filename = tempfile.mkstemp(text=True) |
| # Make sure CRLF is handled properly by requiring none. |
| @@ -707,7 +713,10 @@ def RunEditor(content, git): |
| fileobj.close() |
| try: |
| - cmd = '%s %s' % (GetEditor(git), filename) |
| + editor = GetEditor(git, git_editor=git_editor) |
| + if not editor: |
| + return None |
| + cmd = '%s %s' % (editor, filename) |
| if sys.platform == 'win32' and os.environ.get('TERM') == 'msys': |
| # Msysgit requires the usage of 'env' to be present. |
| cmd = 'env ' + cmd |