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

Unified Diff: gcl.py

Issue 8758004: Handle exceptions thrown when shelling out the editor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: . Created 9 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gcl.py
diff --git a/gcl.py b/gcl.py
index 2a52df5fb999f32d2c54407bdfdc619076230a9d..f6de1f7e92510e7e109c6a87d66db5dea5c22f9e 100755
--- a/gcl.py
+++ b/gcl.py
@@ -1000,19 +1000,25 @@ def CMDcommit(change_info, args):
handle, commit_filename = tempfile.mkstemp(text=True)
os.write(handle, commit_message)
os.close(handle)
-
- handle, targets_filename = tempfile.mkstemp(text=True)
- os.write(handle, "\n".join(change_info.GetFileNames()))
- os.close(handle)
-
- commit_cmd += ['--file=' + commit_filename]
- commit_cmd += ['--targets=' + targets_filename]
- # Change the current working directory before calling commit.
- previous_cwd = os.getcwd()
- os.chdir(change_info.GetLocalRoot())
- output = RunShell(commit_cmd, True)
- os.remove(commit_filename)
- os.remove(targets_filename)
+ try:
+ handle, targets_filename = tempfile.mkstemp(text=True)
+ os.write(handle, "\n".join(change_info.GetFileNames()))
+ os.close(handle)
+ try:
+ commit_cmd += ['--file=' + commit_filename]
+ commit_cmd += ['--targets=' + targets_filename]
+ # Change the current working directory before calling commit.
+ previous_cwd = os.getcwd()
+ os.chdir(change_info.GetLocalRoot())
+ output = ''
+ try:
+ output = RunShell(commit_cmd, True)
+ except subprocess2.CalledProcessError, e:
+ ErrorExit('Commit failed.\n%s' % e)
+ finally:
+ os.remove(commit_filename)
+ finally:
+ os.remove(targets_filename)
if output.find("Committed revision") != -1:
change_info.Delete()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698