diff --git a/checkout.py b/checkout.py index 6fb32d510..fa732e8c7 100644 --- a/checkout.py +++ b/checkout.py @@ -313,8 +313,12 @@ class SvnCheckout(CheckoutBase, SvnMixIn): 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 @@ class SvnCheckout(CheckoutBase, SvnMixIn): # 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: diff --git a/tests/checkout_test.py b/tests/checkout_test.py index 8128e0269..26cb4453d 100755 --- a/tests/checkout_test.py +++ b/tests/checkout_test.py @@ -397,7 +397,36 @@ class SvnCheckout(SvnBaseTest): self._test_prepare(self._get_co(None)) def testMove(self): - self._check_move(self._get_co(None)) + co = self._get_co(None) + self._check_move(co) + out = subprocess2.check_output( + ['svn', 'status'], cwd=co.project_path) + expected = ( + 'A + chromeos/views/webui_menu_widget.h\n' + 'D chromeos/views/DOMui_menu_widget.h\n') + self.assertEquals(expected, out) + # Make sure ancestry is what is expected; + env = os.environ.copy() + env['LANGUAGE'] = 'en_US.UTF-8' + out = subprocess2.check_output( + ['svn', 'info', 'chromeos/views/webui_menu_widget.h'], + cwd=co.project_path, + env=env) + values = dict(l.split(': ', 1) for l in out.splitlines() if l) + expected = { + 'Checksum': '65837bb3da662c8fa88a4a50940ea7c6', + 'Copied From Rev': '2', + 'Copied From URL': + '%strunk/chromeos/views/DOMui_menu_widget.h' % self.svn_base, + 'Name': 'webui_menu_widget.h', + 'Node Kind': 'file', + 'Path': 'chromeos/views/webui_menu_widget.h', + 'Repository Root': '%s' % self.svn_base.rstrip('/'), + 'Revision': '2', + 'Schedule': 'add', + 'URL': '%strunk/chromeos/views/webui_menu_widget.h' % self.svn_base, + } + self.assertEquals(expected, values) class GitSvnCheckout(SvnBaseTest):