Commit 3da83178 authored by maruel@chromium.org's avatar maruel@chromium.org

Implement proper svn copy when a file is copied, moved or renamed

R=nsylvain@chromium.org
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
parent 046e175f
......@@ -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:
......
......@@ -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):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment