| From | Sent On | Attachments |
|---|---|---|
| Dan Prince | Feb 25, 2006 5:28 pm | .diff |
| Daniel Rall | Feb 27, 2006 10:03 am | |
| Dan Prince | Feb 27, 2006 9:10 pm | .diff |
| Subject: | [PATCH] svnant : list task | |
|---|---|---|
| From: | Dan Prince (da...@pestercat.com) | |
| Date: | Feb 25, 2006 5:28:50 pm | |
| List: | org.tigris.subclipse.dev | |
| Attachments: | ||
Attached is a patch containing an implementation for a 'list' task. The docs HTML file is also updated in the patch.
---- da...@pestercat.com
Index: doc/svn.html =================================================================== --- doc/svn.html (revision 2118) +++ doc/svn.html (working copy) @@ -123,35 +123,35 @@ <td><a href="#createRepository">createRepository</a></td> <td><a href="#import">import</a></td> <td><a href="#move">move</a></td> - <td><a href="#status">status</a></td> + <td><a href="#revert">revert</a></td> </tr> <tr> <td><a href="#cat">cat</a></td> <td><a href="#delete">delete</a></td> <td><a href="#keywordsset">keywordsset</a></td> - <td><a href="#propdel">propdel</a></td> - <td><a href="#switch">switch</a></td> + <td><a href="#mkdir">mkdir</a></td> + <td><a href="#status">status</a></td> </tr> <tr> <td><a href="#checkout">checkout</a></td> <td><a href="#diff">diff</a></td> <td><a href="#keywordsadd">keywordsadd</a></td> - <td><a href="#propget">propget</a></td> - <td><a href="#update">update</a></td> + <td><a href="#propdel">propdel</a></td> + <td><a href="#switch">switch</a></td> </tr> <tr> <td><a href="#commit">commit</a></td> <td><a href="#export">export</a></td> <td><a href="#keywordsremove">keywordsremove</a></td> - <td><a href="#propset">propset</a></td> + <td><a href="#propget">propget</a></td> + <td><a href="#update">update</a></td> <td></td> </tr> <tr> <td><a href="#copy">copy</a></td> <td><a href="#ignore">ignore</a></td> - <td><a href="#mkdir">mkdir</a></td> - <td><a href="#revert">revert</a></td> - <td></td> + <td><a href="#list">list</a></td> + <td><a href="#propset">propset</a></td> </tr> </table> <p> </p> @@ -680,6 +680,39 @@ files. Other present keywords are not modified.<BR> The attributes are the same than for keywordsset command.</p>
+<H3><a name="list">list</a></H3>
+<p>Lists the contents of a path within the repository.</p>
+<table>
+ <tr>
+ <td>Attribute</td>
+ <td>Description</td>
+ <td>Required</td>
+ </tr>
+ <tr>
+ <td>delimeter</td>
+ <td>The delimeter that will be used between items</td>
+ <td>No <BR>(defaults to a single space)</td>
+ </tr>
+ <tr>
+ <td>destFile</td>
+ <td>Name of the destination file</td>
+ <td>No <BR>(default is the name of the file on the url)</td>
+ </tr>
+ <tr>
+ <td>url</td>
+ <td>Url of the file in repository</td>
+ <td>Yes</td>
+ </tr>
+ <tr>
+ <td>revision</td>
+ <td>revision to get.<BR>Possible values are :<BR>- a date with the
+ following format : MM/DD/YYYY HH:MM AM_PM<BR>- a revision number<BR>-
+ HEAD, BASE, COMMITED or PREV<BR>Default is "HEAD"
+ </td>
+ <td>No</td>
+ </tr>
+</table>
+
<H3><a name="mkdir">mkdir</a></H3>
<p>Create a new directory under revision control.<BR>
If target is a working copy path the directory is scheduled for addition in the
Index: src/main/org/tigris/subversion/svnant/List.java
===================================================================
--- src/main/org/tigris/subversion/svnant/List.java (revision 0)
+++ src/main/org/tigris/subversion/svnant/List.java (revision 0)
@@ -0,0 +1,173 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apa...@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.tigris.subversion.svnant;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.ParseException;
+
+import org.apache.tools.ant.BuildException;
+import org.tigris.subversion.svnclientadapter.ISVNDirEntry;
+import org.tigris.subversion.svnclientadapter.ISVNClientAdapter;
+import org.tigris.subversion.svnclientadapter.SVNRevision;
+import org.tigris.subversion.svnclientadapter.SVNUrl;
+
+/**
+ * svn List.
+ * List directory entries of an SVN URL and store the results into a file.
+ * @author Dan Prince
+ * <a href="mailto:da...@pestercat.com">da...@pestercat.com</a>
+ */
+public class List extends SvnCommand {
+
+ /** url */
+ private SVNUrl url = null;
+
+ /** recurse */
+ private boolean recurse = false;
+
+ /** delimeter */
+ private String delimeter = " ";
+
+ /** destination file. */
+ private File destFile = null;
+
+ /** revision */
+ private SVNRevision revision = SVNRevision.HEAD;
+
+ public void execute(ISVNClientAdapter svnClient) throws BuildException {
+ validateAttributes();
+
+ log("Svn : List");
+ FileOutputStream os = null;
+ try {
+ os = new FileOutputStream(destFile);
+ ISVNDirEntry[] dirEntries = svnClient.getList(url, revision,
recurse);
+ String buff = null;
+ for (int i = 0; i < dirEntries.length; i++) {
+ // paths separated by the delimeter
+ buff = dirEntries[i].getPath() + delimeter;
+ os.write(buff.getBytes());
+ }
+ } catch (Exception e) {
+ throw new BuildException("Can't get the content of the specified file", e);
+ } finally {
+ if (os != null) {
+ try {
+ os.close();
+ } catch (IOException e) {}
+ }
+ }
+ }
+
+ /**
+ * Ensure we have a consistent and legal set of attributes
+ */
+ protected void validateAttributes() throws BuildException {
+ if (url == null)
+ throw new BuildException("you must set url attr");
+ if (destFile == null)
+ destFile = new File(getProject().getBaseDir(),
+ url.getLastPathSegment());
+ if (revision == null)
+ throw new BuildException("Invalid revision. Revision should be a number, a
date in MM/DD/YYYY HH:MM AM_PM format or HEAD, BASE, COMMITED or PREV");
+ }
+
+ /**
+ * Sets the URL; required.
+ * @param url The url to set
+ */
+ public void setUrl(SVNUrl url) {
+ this.url = url;
+ }
+
+ /**
+ * Optional. Defaults to false.
+ * @param recurse The recurse to set.
+ */
+ public void setRecurse (boolean recurse) {
+ this.recurse = recurse;
+ }
+
+ /**
+ * Sets the destination file
+ */
+ public void setDestFile(File destFile) {
+ this.destFile = destFile;
+ }
+
+ /**
+ * Sets the delimeter used between results
+ */
+ public void setDelimeter(String delimeter) {
+ this.delimeter = delimeter;
+ }
+
+ /**
+ * Sets the revision
+ *
+ * @param revision
+ */
+ public void setRevision(String revision) {
+ try {
+ this.revision = SVNRevision.getRevision(revision);
+ } catch (ParseException e) {
+ this.revision = null;
+ }
+ }
+
+}
Index: src/main/org/tigris/subversion/svnant/SvnTask.java
===================================================================
--- src/main/org/tigris/subversion/svnant/SvnTask.java (revision 2118)
+++ src/main/org/tigris/subversion/svnant/SvnTask.java (working copy)
@@ -180,6 +180,10 @@
commands.add(a);
}
+ public void addList(org.tigris.subversion.svnant.List a) { + commands.add(a); + } + public void addPropdel(Propdel a) { commands.add(a); }






.diff