Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Unified Diff: gclient_utils.py

Issue 6719004: refactor parsing of change descriptions, fix TBR= (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: rebase to head, fix bugs Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gcl.py ('k') | git_cl/git_cl.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient_utils.py
diff --git a/gclient_utils.py b/gclient_utils.py
index 97c8227c097370f2e933f759a5a268e752d72020..7af11636e23982bd83d1a5f3dc33373a605b3f91 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -12,6 +12,7 @@ import re
import stat
import subprocess
import sys
+import tempfile
import threading
import time
import xml.dom.minidom
@@ -710,3 +711,37 @@ class ExecutionQueue(object):
work_queue.ready_cond.notifyAll()
finally:
work_queue.ready_cond.release()
+
+
+def GetEditor():
+ editor = os.environ.get("SVN_EDITOR")
+ if not editor:
+ editor = os.environ.get("EDITOR")
+
+ if not editor:
+ if sys.platform.startswith("win"):
+ editor = "notepad"
+ else:
+ editor = "vi"
+
+ return editor
+
+
+def UserEdit(text):
+ """Open an editor, edit the text, and return the result."""
+ (file_handle, filename) = tempfile.mkstemp()
+ fileobj = os.fdopen(file_handle, 'w')
+ fileobj.write(text)
+ fileobj.close()
+
+ # Open up the default editor in the system to get the CL description.
+ try:
+ cmd = '%s %s' % (GetEditor(), filename)
+ if sys.platform == 'win32' and os.environ.get('TERM') == 'msys':
+ # Msysgit requires the usage of 'env' to be present.
+ cmd = 'env ' + cmd
+ # shell=True to allow the shell to handle all forms of quotes in $EDITOR.
+ subprocess.check_call(cmd, shell=True)
+ return FileRead(filename, 'r')
+ finally:
+ os.remove(filename)
« no previous file with comments | « gcl.py ('k') | git_cl/git_cl.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698