Implement proper svn copy when a file is copied, moved or renamed
[email protected]
BUG=
TEST=A basic unit test verifies history is kept
Review URL: http://codereview.chromium.org/10310034
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@135651 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/checkout.py b/checkout.py
index 6fb32d5..fa732e8 100644
--- a/checkout.py
+++ b/checkout.py
@@ -313,8 +313,12 @@
if os.path.isfile(filepath):
raise PatchApplicationFailed(
p.filename, 'File exist but was about to be overwriten')
- shutil.copy2(
- os.path.join(self.project_path, p.source_filename), filepath)
+ self._check_output_svn(
+ [
+ 'copy',
+ os.path.join(self.project_path, p.source_filename),
+ filepath
+ ])
if p.diff_hunks:
cmd = ['patch', '-p%s' % p.patchlevel, '--forward', '--force']
stdout += subprocess2.check_output(
@@ -323,7 +327,9 @@
# There is only a header. Just create the file if it doesn't
# exist.
open(filepath, 'w').close()
- if p.is_new:
+ if p.is_new and not p.source_filename:
+ # Do not run it if p.source_filename is defined, since svn copy was
+ # using above.
stdout += self._check_output_svn(
['add', p.filename, '--force'], credentials=False)
for prop in p.svn_properties: