From 68f2746262982eabbfb31ccb2fae85e0462c4e07 Mon Sep 17 00:00:00 2001 From: "thomasvl@chromium.org" Date: Mon, 14 Mar 2011 14:54:27 +0000 Subject: [PATCH] Better revert BUG=none TEST=none Review URL: http://codereview.chromium.org/6690012 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@78029 0039d316-1c4b-4281-b951-d872f2087c98 --- git_cl/git_cl.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/git_cl/git_cl.py b/git_cl/git_cl.py index b0525b4f1d..8300cc3840 100644 --- a/git_cl/git_cl.py +++ b/git_cl/git_cl.py @@ -711,20 +711,18 @@ def UserEditedLog(starting_text): fileobj.close() # Open up the default editor in the system to get the CL description. - result = None - try: - subprocess.check_call(['env', editor, filename], shell=True) - fileobj = open(filename) - result = fileobj.read() - fileobj.close() - finally: + ret = subprocess.call(editor + ' ' + filename, shell=True) + if ret != 0: os.remove(filename) - - if not result: return + fileobj = open(filename) + text = fileobj.read() + fileobj.close() + + os.remove(filename) stripcomment_re = re.compile(r'^#.*$', re.MULTILINE) - return stripcomment_re.sub('', result).strip() + return stripcomment_re.sub('', text).strip() def ConvertToInteger(inputval):