[prev in list] [next in list] [prev in thread] [next in thread] 

List:       subclipse-dev
Subject:    [Subclipse-dev]
From:       "Oleg Byelkin" <oleg.byelkin () gmail ! com>
Date:       2008-10-26 14:47:15
Message-ID: e157e5540810260747i24ece67ct1ead96f29043122f () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi all
I wish to donate to svn community patch to svnant 1.2.0 RC1 that includes:

   1. Verbose attribute to svn command (idea stolen from
   http://codefeed.com/blog/?p=82) <http://codefeed.com/blog/?p=82>
   2. cleanup command
   3. Patch to add command that respect recurce parameter for svnFileSet
   4. Patch for svnConflicted selector (doesn't work with svnkit 1.2.0).

Please see my example for points 1. and 2.
<svn username="${svn.username}" password="${svn.password}" verbose="true">
 <cleanup path="${svn_folder}" failonerror="false"/>
 <checkout url="${svn.url}" destpath="${svn_folder}" />
</svn>

Regarding 3. such script add new (unversioned) files and folders to svn. IMO
it has bug because it add only top most folder without content (i.e. if we
try to add structure as folder/subfolder/file only empty folder will be
added). My patch check value of recurse attribute of add command (which is
true by default). If recurse="true", then add folder with all it's content
(i.e. in my example folder/subfolder/file). So the patch change backward
compatibility. Hope it OK.
<svn>
<add>
<svnFileSet dir="${svn_folder}">
 <svnUnversioned/>
</svnFileSet>
</add>
</svn>

Regarding 4. the svnConflicted selector with svnkit 1.2.0 return true for
all files. Root of evil is statement (status_.getConflictNew()!=null) which
is always not null and has value of parent folder (not sure that my change
is correct, please test it).

Thank you,

Oleg Byelkin

[Attachment #5 (text/html)]

Hi all<div><br></div><div>I wish to donate to svn community patch to&nbsp;svnant \
1.2.0 RC1&nbsp;that includes:</div><div><ol><li>Verbose attribute to svn command \
(idea stolen from&nbsp;<a \
href="http://codefeed.com/blog/?p=82">http://codefeed.com/blog/?p=82)</a></li> \
<li>cleanup command</li><li>Patch to add command that respect recurce parameter for \
svnFileSet</li> <li>Patch for&nbsp;svnConflicted selector (doesn&#39;t work with \
svnkit 1.2.0).</li></ol><div>Please see my example for&nbsp;points 1. and \
2.</div><div>&lt;svn username=&quot;${svn.username}&quot; \
password=&quot;${svn.password}&quot; <span style="font-weight:bold"><span \
style="text-decoration:underline">verbose=&quot;true&quot;</span></span>&gt;<br>

</div><div><div><span style="white-space:pre">	</span><span \
style="font-weight:bold"><span style="text-decoration:underline">&lt;cleanup \
path=&quot;${svn_folder}&quot; failonerror=&quot;false&quot;/&gt;</span></span></div>

<div><span style="white-space:pre">	</span>&lt;checkout url=&quot;${svn.url}&quot; \
destpath=&quot;${svn_folder}&quot; \
/&gt;</div><div>&lt;/svn&gt;</div><div><br></div><div>Regarding 3. such script add \
new (unversioned) files and folders to svn. IMO it has bug because it add only top \
most folder without content (i.e. if we try to add structure \
as&nbsp;folder/subfolder/file only empty folder will be added). My patch check value \
of&nbsp;recurse attribute of add command (which is true by default). \
If&nbsp;recurse=&quot;true&quot;, then add folder with all it&#39;s content (i.e. in \
my example folder/subfolder/file). So the patch change backward compatibility. Hope \
it OK.</div> <div>
&lt;svn&gt;<br></div><div><div><span \
style="white-space:pre">	</span>&lt;add&gt;</div><div><span \
style="white-space:pre">		</span>&lt;svnFileSet \
dir=&quot;${svn_folder}&quot;&gt;</div> <div><span \
style="white-space:pre">			</span>&lt;svnUnversioned/&gt;</div><div><span \
style="white-space:pre">		</span>&lt;/svnFileSet&gt;</div><div><span \
style="white-space:pre">	</span>&lt;/add&gt;</div> \
<div>&lt;/svn&gt;</div><div><br></div><div>Regarding 4. the svnConflicted selector \
with svnkit 1.2.0 return true for all files. Root of evil is statement \
(status_.getConflictNew()!=null) which is always not null and has value of parent \
folder (not sure that my change is correct, please test it).</div> \
<div><br></div><div>Thank you,</div><div><br></div><div>Oleg \
Byelkin</div></div></div></div>


["svnant-1.2.0-RC1_patch(verbose, cleanup and other).txt" (text/plain)]

Index: src/main/org/tigris/subversion/svnant/commands/Add.java
===================================================================
--- src/main/org/tigris/subversion/svnant/commands/Add.java	(revision 4046)
+++ src/main/org/tigris/subversion/svnant/commands/Add.java	(working copy)
@@ -67,7 +67,7 @@
 
 /**
  * svn Add. Add a file, a directory or a set of files to repository
- * @author Cédric Chabanois 
+ * @author C�dric Chabanois 
  *         <a href="mailto:cchabanois@ifrance.com">cchabanois@ifrance.com</a>
  *
  */
@@ -269,7 +269,11 @@
 
         // first : we add directories to the repository
         for (int i = 0; i < dirs.length; i++) {
-            svnAddFileWithDirs(new File(baseDir, dirs[i]), baseDir);
+            File aDir = new File(baseDir, dirs[i]);
+			svnAddFileWithDirs(aDir, baseDir);
+			if (recurse){
+				visitChildrenDirs(aDir);
+			}
         }
 
         // then we add files
@@ -278,6 +282,21 @@
         }
     }
 
+	private void visitChildrenDirs(File dir) throws SvnAntException {
+        String[] children = dir.list();
+        for (int i=0; i<children.length; i++) {
+            File aFile = new File(dir, children[i]);
+            if (".svn".equals(aFile.getName())){
+            	continue;
+            }
+            svnAddFileWithDirs(aFile, dir);
+            if (aFile.isDirectory()){
+            	visitChildrenDirs(aFile);
+            }
+        }
+		
+	}
+
 	/**
 	 * set file to add to repository
 	 * @param file
Index: src/main/org/tigris/subversion/svnant/commands/Cleanup.java
===================================================================
--- src/main/org/tigris/subversion/svnant/commands/Cleanup.java	(revision 0)
+++ src/main/org/tigris/subversion/svnant/commands/Cleanup.java	(revision 0)
@@ -0,0 +1,55 @@
+package org.tigris.subversion.svnant.commands;
+
+import java.io.File;
+
+import org.tigris.subversion.svnant.SvnAntException;
+import org.tigris.subversion.svnant.SvnAntValidationException;
+import org.tigris.subversion.svnclientadapter.SVNClientException;
+
+public class Cleanup extends SvnCommand {
+
+    /** directory to cleanup */
+    private File path = null;
+    
+    private boolean failonerror = true;
+    
+	@Override
+	public void execute() throws SvnAntException {
+        if (path != null) {
+        	if (path.exists()){
+	        	try {
+					svnClient.cleanup(path);
+				} catch (SVNClientException e) {
+					if (failonerror){
+	                throw new SvnAntException(
+	                        "Can't cleanup directory " + path.getAbsolutePath(),
+	                        e);
+					}
+				}
+        	}
+        }
+
+	}
+
+	/**
+	 * Sets the destination directory; required 
+	 * @param destPath destination directory for cleanup.
+	 */
+	public void setPath(File path) {
+		this.path = path;
+	}
+
+	@Override
+	protected void validateAttributes() throws SvnAntValidationException {
+        if (path == null) 
+            throw new SvnAntValidationException("path must be set");
+	}
+
+	/**
+	 * @param failonerror the failonerror to set
+	 */
+	public void setFailonerror(boolean failonerror) {
+		this.failonerror = failonerror;
+	}
+
+}
Index: src/main/org/tigris/subversion/svnant/SvnTask.java
===================================================================
--- src/main/org/tigris/subversion/svnant/SvnTask.java	(revision 4046)
+++ src/main/org/tigris/subversion/svnant/SvnTask.java	(working copy)
@@ -55,16 +55,21 @@
 package org.tigris.subversion.svnant;
 
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 import java.util.TimeZone;
+import java.util.Vector;
 
 import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildListener;
+import org.apache.tools.ant.BuildLogger;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.ProjectComponent;
 import org.apache.tools.ant.Task;
 import org.tigris.subversion.svnant.commands.Add;
 import org.tigris.subversion.svnant.commands.Cat;
 import org.tigris.subversion.svnant.commands.Checkout;
+import org.tigris.subversion.svnant.commands.Cleanup;
 import org.tigris.subversion.svnant.commands.Commit;
 import org.tigris.subversion.svnant.commands.Copy;
 import org.tigris.subversion.svnant.commands.CreateRepository;
@@ -100,12 +105,16 @@
 
 /**
  * Svn Task
- * @author Cédric Chabanois 
+ * @author C�dric Chabanois 
  *         <a href="mailto:cchabanois@ifrance.com">cchabanois@ifrance.com</a>
  *
  */
 public class SvnTask extends Task implements ISvnAntProjectComponent {
 
+	// see also org.apache.tools.ant.taskdefs.Echo
+	private static final int CONST_LOG_LEVEL_WARNING = 1;
+	private static final int CONST_LOG_LEVEL_VERBOSE = 3;
+	
 	private static boolean javahlAvailableInitialized = false;
     private static boolean javahlAvailable;
     private static boolean svnKitAvailableInitialized = false;
@@ -123,6 +132,7 @@
 
     private List commands = new ArrayList();
     private List notifyListeners = new ArrayList();
+	private boolean verbose = false;
     
 	/* (non-Javadoc)
 	 * @see org.tigris.subversion.svnant.ISvnAntProjectComponent#getJavahl()
@@ -221,6 +231,14 @@
 		this.failonerror = failonerror;
 	}
 
+    /**
+     * Sets whether or not we output the properties we set
+     * @param verbose
+     */
+    public void setVerbose(boolean verbose) {
+        this.verbose = verbose;
+    }
+
 	public void addCheckout(Checkout a) {
         addCommand(a);
     }
@@ -229,6 +247,10 @@
         addCommand(a);
     }
 
+    public void addCleanup(Cleanup a) {
+    	addCommand(a);
+    }
+    
     public void addCommit(Commit a) {
         addCommand(a);
     }
@@ -418,6 +440,9 @@
 
         ISVNClientAdapter svnClient = getClientAdapter(this);        
 
+        if (verbose){
+            setLogLevel(CONST_LOG_LEVEL_VERBOSE);
+        }
         if (username != null)
             svnClient.setUsername(username);
 
@@ -435,9 +460,24 @@
             command.executeCommand(svnClient);
             svnClient.removeNotifyListener(feedback);
         }
+        if (verbose){
+        	setLogLevel(CONST_LOG_LEVEL_WARNING);
+        }
         
     }
 
+	private void setLogLevel(int logLevel) {
+		Vector listeners = this.getProject().getBuildListeners();
+		for (Iterator i = listeners.iterator(); i.hasNext(); ) {
+		    BuildListener listener = (BuildListener) i.next();
+
+		    if (listener instanceof BuildLogger) {
+		        BuildLogger logger = (BuildLogger) listener;
+		        logger.setMessageOutputLevel(logLevel);
+		    }
+		}
+	}
+
 	/**
 	 * This method returns a SVN client adapter, based on the property set when the file selector
 	 * was declared. More specifically, the 'javahl' and 'svnkit' flags are verified, as well as the
@@ -469,4 +509,5 @@
 		return svnClient;
 	}
 
+	
 }
Index: src/main/org/tigris/subversion/svnant/selectors/Conflicted.java
===================================================================
--- src/main/org/tigris/subversion/svnant/selectors/Conflicted.java	(revision 4046)
+++ src/main/org/tigris/subversion/svnant/selectors/Conflicted.java	(working copy)
@@ -67,7 +67,11 @@
 public class Conflicted extends StatusBasedSelector {
 
 	public boolean isSelected(ISVNStatus status_) {
-		return ( null != status_.getConflictWorking() );
+		if (status_.getConflictNew() == null){
+			// backward compatible
+			return false;
+		}
+		return ( !status_.getConflictWorking().isDirectory() );
 	}
 	
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subclipse.tigris.org
For additional commands, e-mail: dev-help@subclipse.tigris.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic