ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r728003 - in /ant/core/trunk/src: main/org/apache/tools/ant/taskdefs/Sync.java main/org/apache/tools/ant/types/AbstractFileSet.java tests/antunit/taskdefs/sync-test.xml
Date Fri, 19 Dec 2008 11:09:03 GMT
Author: bodewig
Date: Fri Dec 19 03:09:02 2008
New Revision: 728003

URL: http://svn.apache.org/viewvc?rev=728003&view=rev
Log:
now that slowScan is fixed, I realized that Sync cannot use it.  Full implementation of PR
43159.

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Sync.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/AbstractFileSet.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=728003&r1=728002&r2=728003&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 03:09:02 2008
@@ -20,6 +20,7 @@
 
 import java.io.File;
 
+import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
@@ -189,10 +190,8 @@
 
         DirectoryScanner ds = null;
         if (syncTarget != null) {
-            FileSet fs = new FileSet();
+            FileSet fs = syncTarget.toFileSet(false);
             fs.setDir(toDir);
-            fs.setCaseSensitive(syncTarget.isCaseSensitive());
-            fs.setFollowSymlinks(syncTarget.isFollowSymlinks());
 
             // preserveInTarget would find all files we want to keep,
             // but we need to find all that we want to delete - so the
@@ -245,7 +244,10 @@
 
         Boolean ped = getExplicitPreserveEmptyDirs();
         if (ped != null && ped.booleanValue() != myCopy.getIncludeEmptyDirs()) {
-            String[] preservedDirs = ds.getExcludedDirectories();
+            FileSet fs = syncTarget.toFileSet(true);
+            fs.setDir(toDir);
+            String[] preservedDirs =
+                fs.getDirectoryScanner(getProject()).getIncludedDirectories();
             for (int i = preservedDirs.length - 1; i >= 0; --i) {
                 preservedDirectories.add(new File(toDir, preservedDirs[i]));
             }
@@ -552,6 +554,25 @@
         public Boolean getPreserveEmptyDirs() {
             return preserveEmptyDirs;
         }
+
+        private FileSet toFileSet(boolean withPatterns) {
+            FileSet fs = new FileSet();
+            fs.setCaseSensitive(isCaseSensitive());
+            fs.setFollowSymlinks(isFollowSymlinks());
+            fs.setMaxLevelsOfSymlinks(getMaxLevelsOfSymlinks());
+            fs.setProject(getProject());
+
+            if (withPatterns) {
+                PatternSet ps = mergePatterns(getProject());
+                fs.appendIncludes(ps.getIncludePatterns(getProject()));
+                fs.appendExcludes(ps.getExcludePatterns(getProject()));
+                for (Enumeration e = selectorElements(); e.hasMoreElements(); ) {
+                    fs.appendSelector((FileSelector) e.nextElement());
+                }
+                fs.setDefaultexcludes(getDefaultexcludes());
+            }
+            return fs;
+        }
     }
 
     /**

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/AbstractFileSet.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/AbstractFileSet.java?rev=728003&r1=728002&r2=728003&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/AbstractFileSet.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/AbstractFileSet.java Fri Dec 19 03:09:02
2008
@@ -424,6 +424,16 @@
     }
 
     /**
+     * The maximum number of times a symbolic link may be followed
+     * during a scan.
+     *
+     * @since Ant 1.8.0
+     */
+    public int getMaxLevelsOfSymlinks() {
+        return maxLevelsOfSymlinks;
+    }
+
+    /**
      * Sets whether an error is thrown if a directory does not exist.
      *
      * @param errorOnMissingDir true if missing directories cause errors,

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=728003&r1=728002&r2=728003&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 03:09:02 2008
@@ -20,7 +20,9 @@
 
   <target name="setUp">
     <mkdir dir="${input}/a"/>
+    <mkdir dir="${input}/d"/>
     <mkdir dir="${output}/a"/>
+    <mkdir dir="${output}/d"/>
     <mkdir dir="${output}/b/c"/>
     <touch file="${input}/a/foo.txt"/>
     <touch file="${output}/a/bar.txt"/>
@@ -40,6 +42,7 @@
     <au:assertFileExists file="${output}/a/foo.txt"/>
     <au:assertFileExists file="${output}/b/baz.txt"/>
     <au:assertFileExists file="${output}/b/c"/>
+    <au:assertFileExists file="${output}/d"/>
   </target>
 
   <target name="testDefaultDoesntPreserveEmptyDirs" depends="setUp">
@@ -55,6 +58,7 @@
     <au:assertFileExists file="${output}/a/foo.txt"/>
     <au:assertFileExists file="${output}/b/baz.txt"/>
     <au:assertFileDoesntExist file="${output}/b/c"/>
+    <au:assertFileDoesntExist file="${output}/d"/>
   </target>
 
   <target name="testPreserveEmptyOverridesDefault" depends="setUp">
@@ -70,6 +74,7 @@
     <au:assertFileExists file="${output}/a/foo.txt"/>
     <au:assertFileExists file="${output}/b/baz.txt"/>
     <au:assertFileExists file="${output}/b/c"/>
+    <au:assertFileDoesntExist file="${output}/d"/>
   </target>
 
   <target name="testPreserveEmptyOverrulesIncludeEmpty" depends="setUp">
@@ -85,6 +90,7 @@
     <au:assertFileExists file="${output}/a/foo.txt"/>
     <au:assertFileExists file="${output}/b/baz.txt"/>
     <au:assertFileDoesntExist file="${output}/b/c"/>
+    <au:assertFileExists file="${output}/d"/>
   </target>
 
   <target name="testPreserveEmptyAndIncludeEmptyFalse" depends="setUp">
@@ -100,6 +106,7 @@
     <au:assertFileExists file="${output}/a/foo.txt"/>
     <au:assertFileExists file="${output}/b/baz.txt"/>
     <au:assertFileDoesntExist file="${output}/b/c"/>
+    <au:assertFileDoesntExist file="${output}/d"/>
   </target>
 
   <target name="testPreserveEmptyAndIncludeEmptyTrue" depends="setUp">
@@ -115,6 +122,7 @@
     <au:assertFileExists file="${output}/a/foo.txt"/>
     <au:assertFileExists file="${output}/b/baz.txt"/>
     <au:assertFileExists file="${output}/b/c"/>
+    <au:assertFileExists file="${output}/d"/>
   </target>
 
   <target name="testPreserveEmptyDirsWithNonRecursiveExclude" depends="setUp">
@@ -131,6 +139,7 @@
     <au:assertFileExists file="${output}/b"/>
     <au:assertFileDoesntExist file="${output}/b/baz.txt"/>
     <au:assertFileDoesntExist file="${output}/b/c"/>
+    <au:assertFileDoesntExist file="${output}/d"/>
   </target>
 
 </project>



Mime
View raw message