This patch re-enables the behaviour I checked in earlier, but properly supports exclude paths. I wrote a number of exclude path tests in DirectoryScannerTest.cs to exercise a number of pieces of exclude behaviour, as well as running a test-build with this patch. Everything works well.

The big problem with my earlier patch was that I wasn't adding the regex to the regexPatterns collection if we were ignoring it. I moved this line above the test for recursiveness and the problems went away.

If people could give this a shot, that would be great. Thanks! :)

Matt.

Index: DirectoryScanner.cs
===================================================================
RCS file: /cvsroot/nant/nant/src/NAnt.Core/DirectoryScanner.cs,v
retrieving revision 1.10
diff -u -b -r1.10 DirectoryScanner.cs
--- DirectoryScanner.cs 11 Mar 2003 14:20:53 -0000      1.10
+++ DirectoryScanner.cs 11 Mar 2003 17:48:31 -0000
@@ -171,7 +171,7 @@
             // convert given NAnt patterns to regex patterns with absolute paths
             // side effect: searchDirectories will be populated
             convertPatterns(_includes, _includePatterns, true);
-            convertPatterns(_excludes, _excludePatterns, true);
+            convertPatterns(_excludes, _excludePatterns, false);
             
             for (int index = 0; index < _searchDirectories.Count; index++) {
                 ScanDirectory(_searchDirectories[index], 
(bool)_searchDirIsRecursive[index]);
@@ -184,17 +184,19 @@
         /// </summary>
         /// <param name="nantPatterns">In. NAnt patterns. Absolute or relative 
paths.</param>
         /// <param name="regexPatterns">Out. Regex patterns. Absolute canonical 
paths.</param>
-        /// <param name="isInclude">In.</param>
+        /// <param name="addSearchDirectories">In. Whether to allow a pattern to add 
search directories.</param>
         /// <history>
         ///     <change date="20020221" author="Ari Hännikäinen">Created</change>
         /// </history>
-        public void convertPatterns(StringCollection nantPatterns, StringCollection 
regexPatterns, bool isInclude) {
+        public void convertPatterns(StringCollection nantPatterns, StringCollection 
regexPatterns, bool addSearchDirectories) {
             string searchDirectory;
             string regexPattern;
             bool isRecursive;
             foreach (string nantPattern in nantPatterns) {
                 parseSearchDirectoryAndPattern(nantPattern, out searchDirectory, out 
isRecursive, out regexPattern);
-                if (!isInclude)
+                if (!regexPatterns.Contains(regexPattern))
+                    regexPatterns.Add(regexPattern);
+                if (!addSearchDirectories)
                     continue;
                 int index = _searchDirectories.IndexOf(searchDirectory);
                 // If the directory was found before, but wasn't recursive and is 
now, mark it as so
@@ -208,8 +210,6 @@
                     _searchDirectories.Add(searchDirectory);
                     _searchDirIsRecursive.Add(isRecursive);
                 }
-                if (!regexPatterns.Contains(regexPattern))
-                    regexPatterns.Add(regexPattern);
             }
         }
 

Reply via email to