Fixed RepositoryTool patching of files in uncreated directories

Review Request #10247 — Created Oct. 19, 2018 and submitted — Latest diff uploaded

Information

ReviewBot
master
8d24901...

Reviewers

When a RepositoryTool is applying the review's patches to the cloned
repository, it simply writes using open(p, 'wb'). This does not create
directories that the patch implies.

This leads to the write failing with:
IOError: [Errno 2] No such file or directory: u'dir/file'

This patch creates directories for each file if the path does not exist
already.

Replciated the error by posting a review for a file in a new directory,
applied patch, and RepositoryTool successfully runs on patched files.