Commit ed00aed1 authored by dpranke@chromium.org's avatar dpranke@chromium.org

Fix webkitpy scm_unittests so that they pass again.

We don't run these by default, so they bitrotted at some point.

In particular, it looks like svn 1.7 changed behavior so that if
you call

svn add foo
svn add foo/bar

the second call errors out with bar already having been added;
in svn 1.6, this was just a warning.

This comes up in our code because when adding a file we recursively
add the parent directories to ensure the whole path is versioned; we
need to change this so that we do not implicitly recurse down when
adding a parent directory.

Less importantly, it looks like the semantics for git svn clone -T 
change in Git v2, so the branch names are slightly different and 
we need to account for the remote branch refs differently as a result.

R=eseidel@chromium.org
BUG=

Review URL: https://codereview.chromium.org/397383002

git-svn-id: svn://svn.chromium.org/blink/trunk@178482 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent eb900cda
......@@ -117,7 +117,7 @@ class Git(SCM):
def _status_regexp(self, expected_types):
return '^(?P<status>[%s])\t(?P<filename>.+)$' % expected_types
def add_list(self, paths, return_exit_code=False):
def add_list(self, paths, return_exit_code=False, recurse=True):
return self._run_git(["add"] + paths, return_exit_code=return_exit_code)
def delete_list(self, paths):
......
......@@ -86,10 +86,10 @@ class SCM:
def find_checkout_root(self, path):
SCM._subclass_must_implement()
def add(self, path, return_exit_code=False):
self.add_list([path], return_exit_code)
def add(self, path, return_exit_code=False, recurse=True):
self.add_list([path], return_exit_code, recurse)
def add_list(self, paths, return_exit_code=False):
def add_list(self, paths, return_exit_code=False, recurse=True):
self._subclass_must_implement()
def delete(self, path):
......
......@@ -380,6 +380,11 @@ class GitSVNTest(SCMTestBase):
# --quiet doesn't make git svn silent
self._run_silent(['git', 'svn', 'clone', '-T', 'trunk', self.svn_repo_url, self.git_checkout_path])
self._chdir(self.git_checkout_path)
self.git_v2 = self._run(['git', '--version']).startswith('git version 2')
if self.git_v2:
# The semantics of 'git svn clone -T' changed in v2 (apparently), so the branch names are different.
# This works around it, for compatibility w/ v1.
self._run_silent(['git', 'branch', 'trunk', 'origin/trunk'])
def _tear_down_gitsvn_checkout(self):
self._rmtree(self.git_checkout_path)
......@@ -486,7 +491,11 @@ class GitSVNTest(SCMTestBase):
self.assertEqual(self.scm._upstream_branch(), 'my-branch')
def test_remote_branch_ref(self):
self.assertEqual(self.scm._remote_branch_ref(), 'refs/remotes/trunk')
remote_branch_ref = self.scm._remote_branch_ref()
if self.git_v2:
self.assertEqual(remote_branch_ref, 'refs/remotes/origin/trunk')
else:
self.assertEqual(remote_branch_ref, 'refs/remotes/trunk')
def test_create_patch_local_plus_working_copy(self):
self._one_local_commit_plus_working_copy_changes()
......
......@@ -120,16 +120,21 @@ class SVN(SCM):
field_count = 6 if self._svn_version() > "1.6" else 5
return "^(?P<status>[%s]).{%s} (?P<filename>.+)$" % (expected_types, field_count)
def _add_parent_directories(self, path):
def _add_parent_directories(self, path, recurse):
"""Does 'svn add' to the path and its parents."""
if self.in_working_directory(path):
return
self.add(path)
self.add(path, recurse=recurse)
def add_list(self, paths, return_exit_code=False):
def add_list(self, paths, return_exit_code=False, recurse=True):
for path in paths:
self._add_parent_directories(os.path.dirname(os.path.abspath(path)))
return self._run_svn(["add"] + paths, return_exit_code=return_exit_code)
self._add_parent_directories(os.path.dirname(os.path.abspath(path)),
recurse=False)
if recurse:
cmd = ["add"] + paths
else:
cmd = ["add", "--depth", "empty"] + paths
return self._run_svn(cmd, return_exit_code=return_exit_code)
def _delete_parent_directories(self, path):
if not self.in_working_directory(path):
......
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