Author: peterreilly
Date: Thu Sep 14 13:18:04 2006
New Revision: 443456

URL: http://svn.apache.org/viewvc?view=rev&rev=443456
Log:
Bugzilla 39549: available should not search parent directories

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/docs/manual/CoreTasks/available.html
    ant/core/trunk/src/etc/testcases/taskdefs/available.xml
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Available.java

Modified: ant/core/trunk/WHATSNEW
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?view=diff&rev=443456&r1=443455&r2=443456
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Thu Sep 14 13:18:04 2006
@@ -36,6 +36,9 @@
 * documented minimal version of jsch now 0.1.29.
   Bugzilla report 40333.
 
+* <available> searched parent directories for files.
+  Bugzilla report 37148.
+
 Other changes:
 --------------
 

Modified: ant/core/trunk/docs/manual/CoreTasks/available.html
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/available.html?view=diff&rev=443456&r1=443455&r2=443456
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/available.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/available.html Thu Sep 14 13:18:04 2006
@@ -96,10 +96,10 @@
     <td valign="top">This contains the behaviour of the "file" type.
       If true, the available task will, when
       searching for a file, search not only the directories specified but
-      will also search the parent and grandparent directories of those
+      will also search the parent directories of those
       specified.
       If false, only the directories specified will be searched.
-      Defaults to "true".
+      Defaults to "false".
       <em>Since Ant 1.7</em>
     </td>
     <td align="center" valign="top">No</td>

Modified: ant/core/trunk/src/etc/testcases/taskdefs/available.xml
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/available.xml?view=diff&rev=443456&r1=443455&r2=443456
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/available.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/available.xml Thu Sep 14 13:18:04 
2006
@@ -177,13 +177,15 @@
               value="greatgrandparent/grandparent/parent/dir"/>
   </target>
   <target name="search-parents" depends="prep.parents">
-    <echo>testing greatgrandparent - should not see</echo>
+    <echo>testing greatgrandparent - should see</echo>
 
     <fail>
       <condition>
-        <available file="a.txt">
-          <filepath path="${available.test.dir}"/>
-        </available>
+        <not>
+          <available file="a.txt" searchparents="yes">
+            <filepath path="${available.test.dir}"/>
+          </available>
+        </not>
       </condition>
     </fail>
 
@@ -191,7 +193,7 @@
     <fail>
       <condition>
         <not>
-          <available file="b.txt">
+          <available file="b.txt" searchparents="yes">
             <filepath path="${available.test.dir}"/>
           </available>
         </not>
@@ -202,7 +204,7 @@
     <fail>
       <condition>
         <not>
-          <available file="c.txt">
+          <available file="c.txt" searchparents="yes">
             <filepath path="${available.test.dir}"/>
           </available>
         </not>
@@ -213,7 +215,7 @@
     <fail>
       <condition>
         <not>
-          <available file="d.txt">
+          <available file="d.txt" searchparents="yes">
             <filepath path="${available.test.dir}"/>
           </available>
         </not>
@@ -226,7 +228,7 @@
     <echo>testing grandparent - should not see</echo>
     <fail>
       <condition>
-        <available file="b.txt" searchParents="no">
+        <available file="b.txt">
           <filepath path="${available.test.dir}"/>
         </available>
       </condition>
@@ -235,7 +237,7 @@
     <echo>testing parent - should not see</echo>
     <fail>
       <condition>
-        <available file="c.txt" searchParents="false">
+        <available file="c.txt">
           <filepath path="${available.test.dir}"/>
         </available>
       </condition>
@@ -245,7 +247,7 @@
     <fail>
       <condition>
         <not>
-          <available file="d.txt" searchParents="false">
+          <available file="d.txt">
             <filepath path="${available.test.dir}"/>
           </available>
         </not>

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Available.java
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Available.java?view=diff&rev=443456&r1=443455&r2=443456
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Available.java 
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Available.java Thu 
Sep 14 13:18:04 2006
@@ -53,14 +53,14 @@
     private String value = "true";
     private boolean isTask = false;
     private boolean ignoreSystemclasses = false;
-    private boolean searchParents   = true;
+    private boolean searchParents   = false;
 
     /**
      * Set the searchParents attribute.
      * This controls the behaviour of the the "file" type.
      * If true, the path, parent path and grandparent path are
      * searched for the file. If false, only the path is seached.
-     * The default value is true.
+     * The default value is false.
      * @param searchParents the value to set.
      */
     public void setSearchParents(boolean  searchParents) {
@@ -366,21 +366,12 @@
                     }
                 }
                 // **   simple name specified   == parent dir + name
-                if (parent != null && parent.exists() && searchParents) {
+                while (searchParents && parent != null && parent.exists()) {
                     if (checkFile(new File(parent, filename),
                                   filename + " in " + parent)) {
                         return true;
                     }
-                }
-                // **   simple name specified   == parent of parent dir + name
-                if (parent != null && searchParents) {
-                    File grandParent = parent.getParentFile();
-                    if (grandParent != null && grandParent.exists()) {
-                        if (checkFile(new File(grandParent, filename),
-                                      filename + " in " + grandParent)) {
-                            return true;
-                        }
-                    }
+                    parent = parent.getParentFile();
                 }
             }
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to