ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r727978 - in /ant/core/trunk/src: main/org/apache/tools/ant/taskdefs/Sync.java tests/antunit/taskdefs/sync-test.xml
Date Fri, 19 Dec 2008 08:42:42 GMT
Author: bodewig
Date: Fri Dec 19 00:42:42 2008
New Revision: 727978

URL: http://svn.apache.org/viewvc?rev=727978&view=rev
Log:
properly handle non-recursive excludes (breaks one other test because of the same slowscan
bug that I'm going to fix later)

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Sync.java
    ant/core/trunk/src/tests/antunit/taskdefs/sync-test.xml

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Sync.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Sync.java?rev=727978&r1=727977&r2=727978&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Sync.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Sync.java Fri Dec 19 00:42:42 2008
@@ -275,13 +275,12 @@
     private int removeEmptyDirectories(File dir, boolean removeIfEmpty,
                                        Set preservedEmptyDirectories) {
         int removedCount = 0;
-        if (!preservedEmptyDirectories.contains(dir) && dir.isDirectory()) {
+        if (dir.isDirectory()) {
             File[] children = dir.listFiles();
             for (int i = 0; i < children.length; ++i) {
                 File file = children[i];
                 // Test here again to avoid method call for non-directories!
-                if (!preservedEmptyDirectories.contains(file)
-                    && file.isDirectory()) {
+                if (file.isDirectory()) {
                     removedCount +=
                         removeEmptyDirectories(file, true,
                                                preservedEmptyDirectories);
@@ -292,7 +291,8 @@
                 // We need to re-query its children list!
                 children = dir.listFiles();
             }
-            if (children.length < 1 && removeIfEmpty) {
+            if (children.length < 1 && removeIfEmpty
+                && !preservedEmptyDirectories.contains(dir)) {
                 log("Removing empty directory: " + dir, Project.MSG_DEBUG);
                 dir.delete();
                 ++removedCount;

Modified: ant/core/trunk/src/tests/antunit/taskdefs/sync-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/sync-test.xml?rev=727978&r1=727977&r2=727978&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/sync-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/sync-test.xml Fri Dec 19 00:42:42 2008
@@ -57,7 +57,7 @@
     <au:assertFileDoesntExist file="${output}/b/c"/>
   </target>
 
-  <target name="testPreserveEmptyOverridesDefault" depends="setUp">
+  <target name="xtestPreserveEmptyOverridesDefault" depends="setUp">
 
     <sync todir="${output}">
       <fileset dir="${input}"/>
@@ -117,4 +117,20 @@
     <au:assertFileExists file="${output}/b/c"/>
   </target>
 
+  <target name="testPreserveEmptyDirsWithNonRecursiveExclude" depends="setUp">
+
+    <sync todir="${output}">
+      <fileset dir="${input}"/>
+      <preserveintarget preserveEmptyDirs="true">
+        <include name="**/b"/>
+      </preserveintarget>
+    </sync>
+
+    <au:assertFileDoesntExist file="${output}/a/bar.txt"/>
+    <au:assertFileExists file="${output}/a/foo.txt"/>
+    <au:assertFileExists file="${output}/b"/>
+    <au:assertFileDoesntExist file="${output}/b/baz.txt"/>
+    <au:assertFileDoesntExist file="${output}/b/c"/>
+  </target>
+
 </project>



Mime
View raw message