Diff
Modified: trunk/Tools/ChangeLog (118556 => 118557)
--- trunk/Tools/ChangeLog 2012-05-25 20:28:39 UTC (rev 118556)
+++ trunk/Tools/ChangeLog 2012-05-25 20:48:00 UTC (rev 118557)
@@ -1,3 +1,37 @@
+2012-05-25 Dirk Pranke <[email protected]>
+
+ webkitpy: change scm.add(), scm.delete() to accept multiple paths
+ https://bugs.webkit.org/show_bug.cgi?id=87528
+
+ Reviewed by Ojan Vafai.
+
+ launching git or svn for individual files can be slow; this
+ change will hand multiple paths at once to git and svn so they
+ can be added in a batch.
+
+ * Scripts/webkitpy/common/checkout/scm/git.py:
+ (Git.add_list):
+ (Git.delete_list):
+ * Scripts/webkitpy/common/checkout/scm/scm.py:
+ (SCM.add):
+ (SCM):
+ (SCM.add_list):
+ (SCM.delete):
+ (SCM.delete_list):
+ * Scripts/webkitpy/common/checkout/scm/scm_mock.py:
+ (MockSCM.add):
+ (MockSCM):
+ (MockSCM.add_list):
+ (MockSCM.delete):
+ (MockSCM.delete_list):
+ * Scripts/webkitpy/common/checkout/scm/scm_unittest.py:
+ (_shared_test_exists):
+ (_shared_test_added_files):
+ (_test_delete_list):
+ * Scripts/webkitpy/common/checkout/scm/svn.py:
+ (SVN.add_list):
+ (SVN.delete_list):
+
2012-05-25 Thiago Marcos P. Santos <[email protected]>
[NRWT] Add unit testing for perf tests on locked shards
Modified: trunk/Tools/Scripts/webkitpy/common/checkout/scm/git.py (118556 => 118557)
--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/git.py 2012-05-25 20:28:39 UTC (rev 118556)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/git.py 2012-05-25 20:48:00 UTC (rev 118557)
@@ -160,11 +160,11 @@
def _status_regexp(self, expected_types):
return '^(?P<status>[%s])\t(?P<filename>.+)$' % expected_types
- def add(self, path, return_exit_code=False):
- return self.run(["git", "add", path], return_exit_code=return_exit_code)
+ def add_list(self, paths, return_exit_code=False):
+ return self.run(["git", "add"] + paths, return_exit_code=return_exit_code)
- def delete(self, path):
- return self.run(["git", "rm", "-f", path])
+ def delete_list(self, paths):
+ return self.run(["git", "rm", "-f"] + paths)
def exists(self, path):
return_code = self.run(["git", "show", "HEAD:%s" % path], return_exit_code=True, decode_output=False)
Modified: trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm.py (118556 => 118557)
--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm.py 2012-05-25 20:28:39 UTC (rev 118556)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm.py 2012-05-25 20:48:00 UTC (rev 118557)
@@ -154,9 +154,15 @@
self._subclass_must_implement()
def add(self, path, return_exit_code=False):
+ self.add_list([path], return_exit_code)
+
+ def add_list(self, paths, return_exit_code=False):
self._subclass_must_implement()
def delete(self, path):
+ self.delete_list([path])
+
+ def delete_list(self, paths):
self._subclass_must_implement()
def exists(self, path):
Modified: trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_mock.py (118556 => 118557)
--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_mock.py 2012-05-25 20:28:39 UTC (rev 118556)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_mock.py 2012-05-25 20:48:00 UTC (rev 118557)
@@ -38,7 +38,10 @@
self._executive = executive or MockExecutive()
def add(self, destination_path, return_exit_code=False):
- self.added_paths.add(destination_path)
+ self.add_list([destination_path], return_exit_code)
+
+ def add_list(self, destination_paths, return_exit_code=False):
+ self.added_paths.update(set(destination_paths))
if return_exit_code:
return 0
@@ -111,7 +114,11 @@
return "49824"
def delete(self, path):
+ return self.delete_list([path])
+
+ def delete_list(self, paths):
if not self._filesystem:
return
- if self._filesystem.exists(path):
- self._filesystem.remove(path)
+ for path in paths:
+ if self._filesystem.exists(path):
+ self._filesystem.remove(path)
Modified: trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py (118556 => 118557)
--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py 2012-05-25 20:28:39 UTC (rev 118556)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py 2012-05-25 20:48:00 UTC (rev 118557)
@@ -315,6 +315,10 @@
write_into_file_at_path("added_file", "new stuff")
self.scm.add("added_file")
+ write_into_file_at_path("added_file3", "more new stuff")
+ write_into_file_at_path("added_file4", "more new stuff")
+ self.scm.add_list(["added_file3", "added_file4"])
+
os.mkdir("added_dir")
write_into_file_at_path("added_dir/added_file2", "new stuff")
self.scm.add("added_dir")
@@ -323,12 +327,14 @@
added_files = self.scm.added_files()
if "added_dir" in added_files:
added_files.remove("added_dir")
- self.assertEqual(added_files, ["added_dir/added_file2", "added_file"])
+ self.assertEqual(added_files, ["added_dir/added_file2", "added_file", "added_file3", "added_file4"])
# Test also to make sure clean_working_directory removes added files
self.scm.clean_working_directory()
self.assertEqual(self.scm.added_files(), [])
self.assertFalse(os.path.exists("added_file"))
+ self.assertFalse(os.path.exists("added_file3"))
+ self.assertFalse(os.path.exists("added_file4"))
self.assertFalse(os.path.exists("added_dir"))
def _shared_test_changed_files_for_revision(self):
@@ -820,6 +826,12 @@
self.scm.delete("test_file")
self.assertTrue("test_file" in self.scm.deleted_files())
+ def test_delete_list(self):
+ os.chdir(self.svn_checkout_path)
+ self.scm.delete_list(["test_file", "test_file2"])
+ self.assertTrue("test_file" in self.scm.deleted_files())
+ self.assertTrue("test_file2" in self.scm.deleted_files())
+
def test_delete_recursively(self):
self._shared_test_delete_recursively()
@@ -1172,7 +1184,7 @@
def _two_local_commits(self):
self._one_local_commit()
- self._second_local_commt()
+ self._second_local_commit()
def _three_local_commits(self):
self._local_commit('test_file_commit0', 'more test content', 'another test commit')
@@ -1517,6 +1529,12 @@
self.scm.delete('test_file_commit1')
self.assertTrue("test_file_commit1" in self.scm.deleted_files())
+ def test_delete_list(self):
+ self._two_local_commits()
+ self.scm.delete_list(["test_file_commit1", "test_file_commit2"])
+ self.assertTrue("test_file_commit1" in self.scm.deleted_files())
+ self.assertTrue("test_file_commit2" in self.scm.deleted_files())
+
def test_delete_recursively(self):
self._shared_test_delete_recursively()
Modified: trunk/Tools/Scripts/webkitpy/common/checkout/scm/svn.py (118556 => 118557)
--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/svn.py 2012-05-25 20:28:39 UTC (rev 118556)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/svn.py 2012-05-25 20:48:00 UTC (rev 118557)
@@ -178,9 +178,10 @@
self._add_parent_directories(dirname)
self.add(path)
- def add(self, path, return_exit_code=False):
- self._add_parent_directories(os.path.dirname(os.path.abspath(path)))
- return self._run_svn(["add", path], return_exit_code=return_exit_code)
+ def add_list(self, paths, return_exit_code=False):
+ 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)
def _delete_parent_directories(self, path):
if not self.in_working_directory(path):
@@ -192,11 +193,12 @@
if dirname != path:
self._delete_parent_directories(dirname)
- def delete(self, path):
- abs_path = os.path.abspath(path)
- parent, base = os.path.split(abs_path)
- result = self._run_svn(["delete", "--force", base], cwd=parent)
- self._delete_parent_directories(os.path.dirname(abs_path))
+ def delete_list(self, paths):
+ for path in paths:
+ abs_path = os.path.abspath(path)
+ parent, base = os.path.split(abs_path)
+ result = self._run_svn(["delete", "--force", base], cwd=parent)
+ self._delete_parent_directories(os.path.dirname(abs_path))
return result
def exists(self, path):