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

Unified Diff: checkout.py

Issue 18664004: Create a temporary dir for patch to do its work. (Closed) Base URL: http://src.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Pass named arg to tempfile (patch by ilevy) Created 7 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: checkout.py
diff --git a/checkout.py b/checkout.py
index 49799d03df4ed29103fb56894c183b79802b97d9..d1a694b453e9debc6d53683829023b2b7da8d3db 100644
--- a/checkout.py
+++ b/checkout.py
@@ -204,13 +204,19 @@ class RawCheckout(CheckoutBase):
cmd = ['patch', '-u', '--binary', '-p%s' % p.patchlevel]
if verbose:
cmd.append('--verbose')
- stdout.append(
- subprocess2.check_output(
- cmd,
- stdin=p.get(False),
- stderr=subprocess2.STDOUT,
- cwd=self.project_path,
- timeout=GLOBAL_TIMEOUT))
+ env = os.environ.copy()
+ env['TMPDIR'] = tempfile.mkdtemp(prefix='crpatch')
+ try:
+ stdout.append(
+ subprocess2.check_output(
+ cmd,
+ stdin=p.get(False),
+ stderr=subprocess2.STDOUT,
+ cwd=self.project_path,
+ timeout=GLOBAL_TIMEOUT,
+ env=env))
+ finally:
+ shutil.rmtree(env['TMPDIR'])
elif p.is_new and not os.path.exists(filepath):
# There is only a header. Just create the file.
open(filepath, 'w').close()
@@ -400,12 +406,19 @@ class SvnCheckout(CheckoutBase, SvnMixIn):
'--force',
'--no-backup-if-mismatch',
]
- stdout.append(
- subprocess2.check_output(
- cmd,
- stdin=p.get(False),
- cwd=self.project_path,
- timeout=GLOBAL_TIMEOUT))
+ env = os.environ.copy()
+ env['TMPDIR'] = tempfile.mkdtemp(prefix='crpatch')
+ try:
+ stdout.append(
+ subprocess2.check_output(
+ cmd,
+ stdin=p.get(False),
+ cwd=self.project_path,
+ timeout=GLOBAL_TIMEOUT,
+ env=env))
+ finally:
+ shutil.rmtree(env['TMPDIR'])
+
elif p.is_new and not os.path.exists(filepath):
# There is only a header. Just create the file if it doesn't
# exist.
« 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