Title: [92655] trunk/Tools
Revision
92655
Author
[email protected]
Date
2011-08-08 17:11:31 -0700 (Mon, 08 Aug 2011)

Log Message

scm.delete should delete empty parent directories as well
https://bugs.webkit.org/show_bug.cgi?id=65878

Reviewed by Eric Seidel.

This behavior makes SVN match GIT (which has no concept of empty
directories).  This bug comes up a lot when optimizing baselines, which
often create empty directories when we're able to optimize everything
out of a given folder.

* Scripts/webkitpy/common/checkout/scm/scm_unittest.py:
* Scripts/webkitpy/common/checkout/scm/svn.py:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (92654 => 92655)


--- trunk/Tools/ChangeLog	2011-08-09 00:05:10 UTC (rev 92654)
+++ trunk/Tools/ChangeLog	2011-08-09 00:11:31 UTC (rev 92655)
@@ -1,3 +1,18 @@
+2011-08-08  Adam Barth  <[email protected]>
+
+        scm.delete should delete empty parent directories as well
+        https://bugs.webkit.org/show_bug.cgi?id=65878
+
+        Reviewed by Eric Seidel.
+
+        This behavior makes SVN match GIT (which has no concept of empty
+        directories).  This bug comes up a lot when optimizing baselines, which
+        often create empty directories when we're able to optimize everything
+        out of a given folder.
+
+        * Scripts/webkitpy/common/checkout/scm/scm_unittest.py:
+        * Scripts/webkitpy/common/checkout/scm/svn.py:
+
 2011-08-08  Lucas Forschler  <[email protected]>
 
         Add triggers for Lion WK2 test bots.

Modified: trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py (92654 => 92655)


--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py	2011-08-09 00:05:10 UTC (rev 92654)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/scm_unittest.py	2011-08-09 00:11:31 UTC (rev 92655)
@@ -511,6 +511,25 @@
         self.scm.add("added_dir/added_file")
         self.assertTrue("added_dir/added_file" in self.scm.added_files())
 
+    def _shared_test_delete_recursively(self):
+        os.mkdir("added_dir")
+        write_into_file_at_path("added_dir/added_file", "new stuff")
+        self.scm.add("added_dir/added_file")
+        self.assertTrue("added_dir/added_file" in self.scm.added_files())
+        self.scm.delete("added_dir/added_file")
+        self.assertFalse("added_dir" in self.scm.added_files())
+
+    def _shared_test_delete_recursively_or_not(self):
+        os.mkdir("added_dir")
+        write_into_file_at_path("added_dir/added_file", "new stuff")
+        write_into_file_at_path("added_dir/another_added_file", "more new stuff")
+        self.scm.add("added_dir/added_file")
+        self.scm.add("added_dir/another_added_file")
+        self.assertTrue("added_dir/added_file" in self.scm.added_files())
+        self.assertTrue("added_dir/another_added_file" in self.scm.added_files())
+        self.scm.delete("added_dir/added_file")
+        self.assertTrue("added_dir/another_added_file" in self.scm.added_files())
+
     def _shared_test_exists(self, scm, commit_function):
         os.chdir(scm.checkout_root)
         self.assertFalse(scm.exists('foo.txt'))
@@ -842,6 +861,12 @@
         self.scm.delete("test_file")
         self.assertTrue("test_file" in self.scm.deleted_files())
 
+    def test_delete_recursively(self):
+        self._shared_test_delete_recursively()
+
+    def test_delete_recursively_or_not(self):
+        self._shared_test_delete_recursively_or_not()
+
     def test_head_svn_revision(self):
         self._shared_test_head_svn_revision()
 
@@ -1459,6 +1484,12 @@
         self.scm.delete('test_file_commit1')
         self.assertTrue("test_file_commit1" in self.scm.deleted_files())
 
+    def test_delete_recursively(self):
+        self._shared_test_delete_recursively()
+
+    def test_delete_recursively_or_not(self):
+        self._shared_test_delete_recursively_or_not()
+
     def test_head_svn_revision(self):
         self._shared_test_head_svn_revision()
 

Modified: trunk/Tools/Scripts/webkitpy/common/checkout/scm/svn.py (92654 => 92655)


--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/svn.py	2011-08-09 00:05:10 UTC (rev 92654)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/svn.py	2011-08-09 00:11:31 UTC (rev 92655)
@@ -68,6 +68,8 @@
     svn_server_host = "svn.webkit.org"
     svn_server_realm = "<http://svn.webkit.org:80> Mac OS Forge"
 
+    _svn_metadata_files = frozenset(['.svn', '_svn'])
+
     def __init__(self, cwd, patch_directories, executive=None):
         SCM.__init__(self, cwd, executive)
         self._bogus_dir = None
@@ -171,9 +173,22 @@
         self._add_parent_directories(os.path.dirname(os.path.abspath(path)))
         return self.run(["svn", "add", path], return_exit_code=return_exit_code)
 
+    def _delete_parent_directories(self, path):
+        if not self.in_working_directory(path):
+            return
+        if set(os.listdir(path)) - self._svn_metadata_files:
+            return  # Directory has non-trivial files in it.
+        self.delete(path)
+        dirname = os.path.dirname(path)
+        if dirname != path:
+            self._delete_parent_directories(dirname)
+
     def delete(self, path):
-        parent, base = os.path.split(os.path.abspath(path))
-        return self.run(["svn", "delete", "--force", base], cwd=parent)
+        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):
         return not self.run(["svn", "info", path], return_exit_code=True, decode_output=False)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to