Create a temporary dir for patch to do its work.

BUG=259665

Review URL: https://chromiumcodereview.appspot.com/18664004

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@211443 0039d316-1c4b-4281-b951-d872f2087c98
experimental/szager/collated-output
groby@chromium.org 12 years ago
parent 3ce4184f8c
commit 2327994797

@ -204,13 +204,19 @@ class RawCheckout(CheckoutBase):
cmd = ['patch', '-u', '--binary', '-p%s' % p.patchlevel] cmd = ['patch', '-u', '--binary', '-p%s' % p.patchlevel]
if verbose: if verbose:
cmd.append('--verbose') cmd.append('--verbose')
env = os.environ.copy()
env['TMPDIR'] = tempfile.mkdtemp(prefix='crpatch')
try:
stdout.append( stdout.append(
subprocess2.check_output( subprocess2.check_output(
cmd, cmd,
stdin=p.get(False), stdin=p.get(False),
stderr=subprocess2.STDOUT, stderr=subprocess2.STDOUT,
cwd=self.project_path, cwd=self.project_path,
timeout=GLOBAL_TIMEOUT)) timeout=GLOBAL_TIMEOUT,
env=env))
finally:
shutil.rmtree(env['TMPDIR'])
elif p.is_new and not os.path.exists(filepath): elif p.is_new and not os.path.exists(filepath):
# There is only a header. Just create the file. # There is only a header. Just create the file.
open(filepath, 'w').close() open(filepath, 'w').close()
@ -400,12 +406,19 @@ class SvnCheckout(CheckoutBase, SvnMixIn):
'--force', '--force',
'--no-backup-if-mismatch', '--no-backup-if-mismatch',
] ]
env = os.environ.copy()
env['TMPDIR'] = tempfile.mkdtemp(prefix='crpatch')
try:
stdout.append( stdout.append(
subprocess2.check_output( subprocess2.check_output(
cmd, cmd,
stdin=p.get(False), stdin=p.get(False),
cwd=self.project_path, cwd=self.project_path,
timeout=GLOBAL_TIMEOUT)) timeout=GLOBAL_TIMEOUT,
env=env))
finally:
shutil.rmtree(env['TMPDIR'])
elif p.is_new and not os.path.exists(filepath): elif p.is_new and not os.path.exists(filepath):
# There is only a header. Just create the file if it doesn't # There is only a header. Just create the file if it doesn't
# exist. # exist.

Loading…
Cancel
Save