Author: reto
Date: Fri Jan 28 08:35:35 2011
New Revision: 1064480

URL: http://svn.apache.org/viewvc?rev=1064480&view=rev
Log:
CLEREZZA-412: changed to depth fisrt approach, removed unused test skeletons

Removed:
    
incubator/clerezza/issues/CLEREZZA-412/renamer/src/test/scala/org/apache/clerezza/renamer/AppTest.scala
    
incubator/clerezza/issues/CLEREZZA-412/renamer/src/test/scala/org/apache/clerezza/renamer/MySpec.scala
Modified:
    
incubator/clerezza/issues/CLEREZZA-412/renamer/src/main/scala/org/apache/clerezza/renamer/App.scala

Modified: 
incubator/clerezza/issues/CLEREZZA-412/renamer/src/main/scala/org/apache/clerezza/renamer/App.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-412/renamer/src/main/scala/org/apache/clerezza/renamer/App.scala?rev=1064480&r1=1064479&r2=1064480&view=diff
==============================================================================
--- 
incubator/clerezza/issues/CLEREZZA-412/renamer/src/main/scala/org/apache/clerezza/renamer/App.scala
 (original)
+++ 
incubator/clerezza/issues/CLEREZZA-412/renamer/src/main/scala/org/apache/clerezza/renamer/App.scala
 Fri Jan 28 08:35:35 2011
@@ -6,12 +6,11 @@ import scala.io._
 object App extends Application {
 
        def getAllDirs(dir: File): List[File] = {
-               dir ::
                ((for (file <- dir.listFiles;
                           if file.isDirectory;
                           if !file.getName.startsWith(".")) yield {
                                        getAllDirs(file)
-                               }).toList.flatten)
+                               }).toList.flatten) :+ dir
        }
 
        def findPoms(dir: File): List[File] = {
@@ -22,6 +21,10 @@ object App extends Application {
 
        val prefix = "org.apache.clerezza."
 
+       def commit(file: File) {
+               exec("svn", "commit", file.getAbsolutePath, "-m","CLEREZZA-412: 
commit by rename utility")
+       }
+
        def processPom(file: File) {
                val stringContent = Source.fromFile(file).mkString
                stringContent.replace("<artifactId>"+prefix,"<artifactId>")
@@ -29,6 +32,7 @@ object App extends Application {
                val fw = new FileWriter(file)
                fw.write(stringContent)
                fw.close()
+               commit(file)
        }
 
        def exec(command : String*) = {
@@ -52,14 +56,15 @@ object App extends Application {
 
 
        def processDirectory(dir: File) {
+               val parent = dir.getParentFile
                val replacementDir = {
-                       val parent = dir.getParentFile
                        val name = dir.getName
                        assert(name.startsWith(prefix))
                        val newName = name.substring(prefix.length)
                        new File(parent, newName)
                }
                exec("svn", "mv", dir.getAbsolutePath, 
replacementDir.getAbsolutePath)
+               commit(parent)
        }
 
 
@@ -69,14 +74,8 @@ object App extends Application {
                processPom(p)
        }
 
-       var doAnotherProcessingRound = true
-       while(doAnotherProcessingRound) {
-               doAnotherProcessingRound = false
-               for (d <- getAllDirs(root);
-                               if (d.getName.startsWith(prefix));
-                               if 
(!d.getParentFile.getAbsolutePath.contains("/"+prefix))) {
-                       processDirectory(d)
-                       doAnotherProcessingRound = true
-               }
+       for (d <- getAllDirs(root);
+                       if (d.getName.startsWith(prefix))) {
+               processDirectory(d)
        }
 }


Reply via email to