Re: svnant info task - another contribution
From: <kevin.slater_at_pfpc.com>
Date: 2005-12-09 15:58:19 CET
Oh, that's good stuff! When can we get this rolled into svnant?
...Kevin
Kevin Slater
Thursday, December 08, 2005 11:23 AM
Hi all,
I need a <svn><info/></svn> task in svnant. There isn't one yet so I
There are three changed files:
* the new Info.java (attached)
The diffs for SvnTask are simply
+ public void addInfo(Info a) {
Regards,
-- Richard Beton BSc (Hons) Consultant Email: richard.beton@roke.co.uk Telephone: +44 (0)1794 833458 Roke Manor Research Ltd, A SIEMENS Company. Old Salisbury Lane, Romsey, Hampshire S051 0ZN http://www.roke.co.uk/ -- Visit our website at www.roke.co.uk Roke Manor Research Ltd, Roke Manor, Romsey, Hampshire SO51 0ZN, UK. The information contained in this e-mail and any attachments is proprietary to Roke Manor Research Ltd and must not be passed to any third party without permission. This communication is for information only and shall not create or change any contractual relationship. /* ==================================================================== * 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 apache@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.net.MalformedURLException; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.tigris.subversion.svnclientadapter.ISVNClientAdapter; import org.tigris.subversion.svnclientadapter.ISVNInfo; import org.tigris.subversion.svnclientadapter.SVNClientException; import org.tigris.subversion.svnclientadapter.SVNScheduleKind; import org.tigris.subversion.svnclientadapter.SVNUrl; /** * Display information about a local or remote item. * * @author Rick Beton */ public class Info extends SvnCommand { private String target = null; private String dateFormat = "yyyy-MM-dd HH:mm:ss Z"; private String pathProperty = null; private String uuidProperty = null; private String nodeKindProperty = null; private String scheduleProperty = null; private String propsLastUpdateProperty = null; private String revisionProperty = null; private String lastChangedRevisionProperty = null; private String lastChangedDateProperty = null; private String lastCommitAuthorProperty = null; private String urlProperty = null; /* * (non-Javadoc) * * @see org.tigris.subversion.svnant.SvnCommand#execute(org.tigris.subversion.svnclientadapter.ISVNClientAdapter) */ public void execute(ISVNClientAdapter svnClient) throws BuildException { validateAttributes(); log("Svn : Info"); if (target == null) { target = "."; } final Project project = getProject(); try { if (target.matches("^[a-z]+://")) { try { final ISVNInfo info = svnClient.getInfo(new SVNUrl(target)); extractInformation(project, info); } catch (MalformedURLException e) { throw new BuildException( "svn info target is a malformed url: " + target, e); } } else { final ISVNInfo info = svnClient.getInfo(new File(target)); extractInformation(project, info); } } catch (SVNClientException e) { throw new BuildException("Can't get svn info for " + target, e); } } /** * @param project * @param info */ private void extractInformation(Project project, final ISVNInfo info) { final DateFormat df = new SimpleDateFormat(dateFormat); final String file = info.getFile().toString(); final String uuid = info.getUuid(); final SVNUrl statusUrl = info.getUrl(); final String url = (statusUrl != null) ? statusUrl.toString() : ""; final String revision = info.getRevision().toString(); final String nodeKind = info.getNodeKind().toString(); final SVNScheduleKind scheduleKind = info.getSchedule(); final String schedule = (scheduleKind != null) ? scheduleKind .toString() : ""; final String lastDatePropsUpdate = extractDate(info .getLastDatePropsUpdate(), df); final String lastDateTextUpdate = extractDate(info .getLastDateTextUpdate(), df); final String lastChangedDate = extractDate(info.getLastChangedDate(), df); String lastChangedRevision = info.getLastChangedRevision().toString(); String lastCommitAuthor = info.getLastCommitAuthor(); if (lastCommitAuthor == null) { lastCommitAuthor = ""; } log("Path: " + file, Project.MSG_VERBOSE); log("URL: " + info.getUrl(), Project.MSG_VERBOSE); log("Repository UUID: " + uuid, Project.MSG_VERBOSE); log("Revision: " + revision, Project.MSG_VERBOSE); log("Node Kind: " + nodeKind, Project.MSG_VERBOSE); log("Schedule: " + schedule, Project.MSG_VERBOSE); log("Last Changed Author: " + lastCommitAuthor, Project.MSG_VERBOSE); log("Last Changed Rev: " + lastChangedRevision, Project.MSG_VERBOSE); log("Last Changed Date: " + lastChangedDate, Project.MSG_VERBOSE); log("Properties Last Updated: " + lastDatePropsUpdate, Project.MSG_VERBOSE); log("Text Last Updated: " + lastDateTextUpdate, Project.MSG_VERBOSE); if (pathProperty != null) { project.setProperty(pathProperty, file); } if (urlProperty != null) { project.setProperty(urlProperty, url); } if (uuidProperty != null) { project.setProperty(uuidProperty, uuid); } if (revisionProperty != null) { project.setProperty(revisionProperty, revision); } if (nodeKindProperty != null) { project.setProperty(nodeKindProperty, nodeKind); } if (scheduleProperty != null) { project.setProperty(scheduleProperty, schedule); } if (propsLastUpdateProperty != null) { project.setProperty(propsLastUpdateProperty, lastDatePropsUpdate); } if (lastChangedRevisionProperty != null) { project.setProperty(lastChangedRevisionProperty, lastChangedRevision); } if (lastChangedDateProperty != null) { project.setProperty(lastChangedDateProperty, lastChangedDate); } if (lastCommitAuthorProperty != null) { project.setProperty(lastCommitAuthorProperty, lastCommitAuthor); } } private String extractDate(Date date, DateFormat format) { if (date == null) { return ""; } return format.format(date); } /** * Ensure we have a consistent and legal set of attributes */ protected void validateAttributes() throws BuildException { } /** * @param target * The path to set. */ public void setTarget(String target) { this.target = target; } /** * @param textStatusProperty * The textStatusProperty to set. */ public void setUuidProperty(String textStatusProperty) { this.uuidProperty = textStatusProperty; } /** * @param propsLastUpdateProperty * The propsLastUpdateProperty to set. */ public void setPropsLastUpdateProperty(String propsLastUpdateProperty) { this.propsLastUpdateProperty = propsLastUpdateProperty; } /** * @param revisionProperty * The revisionProperty to set. */ public void setRevisionProperty(String revisionProperty) { this.revisionProperty = revisionProperty; } /** * @param lastChangedRevisionProperty * The lastChangedRevisionProperty to set. */ public void setLastChangedRevisionProperty( String lastChangedRevisionProperty) { this.lastChangedRevisionProperty = lastChangedRevisionProperty; } /** * @param lastChangedDateProperty * The lastChangedDateProperty to set. */ public void setLastChangedDateProperty(String lastChangedDateProperty) { this.lastChangedDateProperty = lastChangedDateProperty; } /** * @param lastCommitAuthorProperty. * The lastCommitAuthor to set. */ public void setLastCommitAuthorProperty(String lastCommitAuthorProperty) { this.lastCommitAuthorProperty = lastCommitAuthorProperty; } /** * @param urlProperty * The url to set. */ public void setUrlProperty(String urlProperty) { this.urlProperty = urlProperty; } /** * @param scheduleProperty * The scheduleProperty to set. */ public void setScheduleProperty(String scheduleProperty) { this.scheduleProperty = scheduleProperty; } } Svn by Cédric Chabanois Description This task provide an interface to Subversion:1 revision control system that is a compelling replacement for CVS in the open source community. Svn uses javahl (a java interface for the subversion api) if it can find the corresponding library (svnjavahl.dll on windows). Otherwise it uses svn command line interface. Parameters Attribute Description Required username username that will be used for all nested svn commands. No password password that will be used for all nested svn commands. No javahl Set to “false” to use command line client interface to svn (experimental). Defaults to true No Svn commands specified as nested elements add:1 createRepository import:1 mkdir revert cat:1 delete info:1 move status:1 checkout diff:1 keywordsset propdel switch commit export keywordsadd propget update copy:1 ignore keywordsremove propset add You can add files and directories to svn repository with nested <add> elements. Attribute Description Required file file to add to the repository No dir directory to add to the repository No recurse Set to "false" to operate on a single directory only (applies only when dir attribute is set). Default is "true" No Parameters specified as nested elements : fileset Filesets are used to select sets of files to add to the repository. Note that directories needed to add selected files will be added to the repository even if they are not selected by the fileset. cat Get the content of a file on repository. Attribute Description Required destFile Name of the destination file No (default is the name of the file on the url) url Url of the file in repository Yes revision revision to get. Possible values are : - a date with the following format : MM/DD/YYYY HH:MM AM_PM - a revision number - HEAD, BASE, COMMITED or PREV Default is "HEAD" No checkout Check out a working copy from a repository. Attribute Description Required url url to checkout from Yes recurse Set to "false" to operate on single directory only. Default is "true" No destPath destination directory Yes revision revision to checkout. Possible values are : - a date with the following format : MM/DD/YYYY HH:MM AM_PM - a revision number - HEAD, BASE, COMMITED or PREV Default is "HEAD" No Parameters specified as nested elements : fileset Filesets are used to select sets of files to add to the repository. Note that directories needed to add selected files will be added to the repository even if they are not selected by the fileset. commit Send changes from your working copy to the repository. Attribute Description Required file file to commit No recurse Set to "false" to operate on single directory only. Default is "true" Apply only when dir attribute is set. No dir directory to commit No message commit message Yes Parameters specified as nested elements : fileset Filesets are used to select sets of files to commit. copy Duplicate something in working copy or repository, remembering history. source and destination can each be either a working copy (WC) path or URL: WC->WC: copy and schedule for addition (with history) WC->URL: immediately commit a copy of WC to URL URL->WC: check out URL into WC, schedule for addition URL->URL: complete server-side copy; used to branch & tag Attribute Description Required srcPath source path srcUrl source url One of the two testPath destination path destUrl destination url One of the two message commit message when destUrl is set revision revision to copy from (when srcUrl is set) Possible values are : - a date with the following format : MM/DD/YYYY HH:MM AM_PM - a revision number - HEAD, BASE, COMMITED or PREV Default is "HEAD" no createRepository Create a new, empty repository at path. Attribute Description Required path Path where to create the new repository Yes Example: <svnjavahl="false"> <createRepositorypath="repository"/> </svn> delete If run on a working copy target, the item is scheduled for deletion upon the next commit. Files, and directories that have not been committed, are immediately removed from the working copy. The command will not remove targets that are, or contain, unversioned or modified items; use the force attribute to override this behaviour. If run on an url, the item is deleted from the repository via an immediate commit. Attribute Description Required file file to delete No url url to delete No dir directory to delete No message commit message when url attribute is set force default is "false" No Parameters specified as nested elements : fileset Filesets are used to select sets of files to delete.. diff Display the differences between two paths (oldPath and newPath) or two urls (oldUrl and newUrl). Attribute Description Required oldPath If oldUrl is not set, defaults to the path '.' No oldUrl No oldTargetRevision defaults to BASE or, if oldUrl is set, to HEAD No newPath defaults to oldPath if oldUrl is not set No newUrl No newTargetRevision defaults to the current working version or, if newUrl is set, to HEAD No outFile Default is 'patch' No recurse Set to "false" to operate on single directory only. Default is "true" No Example : diff between BASE and current working version <svnjavahl="${javahl}"> <diffoldPath="workingcopy/diffTest/file.txt"outFile="workingcopy/diffTest/patch.txt"/> </svn> export Exports a clean directory tree from the repository specified by srcurl, at revision revision if it is given, otherwise at HEAD, into destPath. Exports a clean directory tree from the working copy specified by srcPath into destPath. all local changes will be preserved, but files not under revision control will not be copied. Attribute Description Required srcUrl source url to export from One of the two srcPath source path to export from destPath destination path Yes revision revision of the source url to export from. Defaults is "HEAD" Possible values are : - a date with the following format : MM/DD/YYYY HH:MM AM_PM - a revision number - HEAD, BASE, COMMITED or PREV No ignore Add a given file or a pattern to the ignored files list (modifies svn:ignore property) Attribute Description Required file file to ignore One of the two dir directory on which we will update svn:ignore property pattern pattern to add to svn:ignore on the directory Only when dir is set Yes recurse Set to "true" to add the pattern recursively to directories. Default is "false" Only when dir is set No Example : <svnjavahl="${javahl}"> <ignoredir="workingcopy/ignoreTest/dir1"pattern="*.ignore"recurse="true"/> </svn> import Commit an unversioned file or tree into the repository. Recursively commit a copy of path to url. If newEntry is not set, copy top-level contents of pathintourldirectly. Otherwise, create newEntry underneath url and begin copy there. Attribute Description Required path source path to export from Yes url source url to import to Yes newEntry No message commit message Yes recurse Set to "false" to operate on single directory only. Default is "true" False info Get information about a local or remote item. Attribute Description Required target path of the file or directory, or url of remote resource No pathProperty Name of the property to set to the path of the item No urlProperty Name of the property to set to the URL of the item No uuidProperty Name of the property to set to the repository UUID No nodeKindProperty Name of the property to set to the target's node kind No revisionProperty Name of the property to set to the revision of the target No scheduleProperty Name of the property to set to the schedule of the target No lastChangedRevisionProperty Name of the property to set to the last changed revision of the target No lastChangedDateProperty Name of the property to set to the last changed date of the target No propsLastUpdateProperty Name of the property to set to the last changed date of the target's properties No lastCommitAuthorProperty Name of the property to set to the last commit author of the target No If the target is unversioned, the properties are set to a blank string (""). Example : <svn> <info target="."revisionProperty="testStatus.revision"propStatusProperty="testStatus.propStatus"lastChangedRevisionProperty="testStatus.lastCommitRevision"lastCommitAuthorProperty="testStatus.lastCommitAuthor"> </svn> keywordsset Keywordsset controls which keywords will be substituted on the given files. Valid keywords are: URL, HeadURL : The URL for the head version of the object. Author, LastChangedBy : The last person to modify the file. Date, LastChangedDate : The date/time the object was last modified. Rev, LastChangedRevision : The last revision the object changed. Id : A compressed summary of the previous Attribute Description Required file File for which keywords will be substituted Either file, dir or filesets dir All files in this directory will have their keywords substituted (recursively) Either file, dir or filesets keywords The keywords to substitute on the given files No HeadURL/URL Author, LastChangedBy Date, LastChangedDate Rev, LastChangedRevision Id Set to “true“ the keyword to substitute it on the given file. No Parameters specified as nested elements : fileset Filesets are used to select sets of files on which to apply keywords substitution. keywordsadd Keywordsadd add some keywords to be substituted on the given files. Present keywords are not modified. The attributes are the same than for keywordsset command. keywordsremove Keywordsadd remove some keywords to be substituted on the given files. Other present keywords are not modified. The attributes are the same than for keywordsset command. mkdir Create a new directory under revision control. If target is a working copy path the directory is scheduled for addition in the working copy. If target is an url the directory is created in the repository via an immediate commit. In both cases all the intermediate directories must already exist. Attribute Description Required path path to create One of the two url url to create message commit message Yes move Move/rename something in working copy or repository. cource and destination can both be working copy (WC) paths or URLs: WC -> WC: move and schedule for addition (with history) URL -> URL: complete server-side rename. Attribute Description Required srcPath source path srcUrl source url One of the two destPath destination path destUrl destination url One of the two message commit message Yes propdel Remove a property from files or dirs. Attribute Description Required path path of the file or directory on which to delete the property Yes name name of the property to delete Yes recurse if set, property will be removed recursively No propget Get a property from a file or a directory. Attribute Description Required path path of the file or directory on which to get the property Yes name name of the property to get Yes property the name of the property to set with the value of the svn property file file that will contain the value of the property One of the two Example : <svnjavahl="${javahl}"> <propgetpath="workingcopy/propTest/file.png"name="svn:mime-type"property="propTest.mimeType"/> </svn> propset Set a property on files or dirs. Attribute Description Required path path of the file or directory on which to set the property Yes name name of the property to set Yes value the value of the property file the file that will be used as a value One of the two recurse if set, property will be set recursively No Note:svn recognizes the following special versioned properties but will store any arbitrary properties set: svn:ignore : A newline separated list of file patterns to ignore. svn:keywords : Keywords to be expanded. Valid keywords are: URL, HeadURL : The URL for the head version of the object. Author, LastChangedBy : The last person to modify the file. Date, LastChangedDate : The date/time the object was last modified. Rev, LastChangedRevision : The last revision the object changed. Id : A compressed summary of the previous 4 keywords. svn:executable : If present, make the file executable. This property cannot be set on a directory. A non-recursive attempt will fail, and a recursive attempt will set the property only on the file children of the directory svn:eol-style : One of 'native', 'LF', 'CR', 'CRLF'. svn:mime-type : The mimetype of the file. Used to determine whether to merge the file, and how to serve it from Apache. A mimetype beginning with 'text/' (or an absent mimetype) is treated as text. Anything else is treated as binary. svn:externals : A newline separated list of module specifiers, each of which consists of a relative directory path, optional revision flags, and an URL. For example foo http://example.com/repos/zig foo/bar -r 1234 http://example.com/repos/zag revert Restore pristine working copy file (undo most local edits). Attribute Description Required file file to revert No dir directory to revert No recurse Set to "false" to operate on a single directory only (applies only when dir attribute is set). Default is "false" No revision revision. Defaults is "HEAD" Possible values are : - a date with the following format : MM/DD/YYYY HH:MM AM_PM - a revision number - HEAD, BASE, COMMITED or PREV No Parameters specified as nested elements : fileset Filesets are used to select sets of files to revert. status Get the status of working copy files and directories. Attribute Description Required path path of the file or directory Yes textStatusProperty Name of the property to set to the status of the item No propStatusProperty Name of the property to set to the status of the item properties No revisionProperty Name of the property to set to the revision of the item (or “” if unversioned) No lastChangedRevisionProperty Name of the property to set to the last changed revision of the item (or “” if unversioned) No lastCommitAuthorProperty Name of the property to set to the last commit author (or “” if unversioned) No urlProperty Name of the property to set to the url of the item No The value of TextStatusProperty can be : non-svn normal : no modifications added missing : item is missing (removed by non-svn command) incomplete deleted replaced modified merged conflicted obstructed ignored external unversioned The value of propStatusProperty can be : normal : no modifications conflicted modified Example : <svn> <statuspath="workingcopy/statusTest/added.txt"textStatusProperty="testStatus.textStatus"propStatusProperty="testStatus.propStatus"lastChangedRevisionProperty="testStatus.lastCommitRevision"revisionProperty="testStatus.revision"lastCommitAuthorProperty="testStatus.lastCommitAuthor"> </svn> switch Update the working copy to mirror a new URL within the repository. This behaviour is similar to 'svn update', and is the way to move a working copy to a branch or tag within the same repository. Attribute Description Required path The working copy to switch to the given url Yes url The url to switch to Yes recurse Set to "false" to operate on a single directory only. Default is "true" No revision revision. Defaults is "HEAD" Possible values are : - a date with the following format : MM/DD/YYYY HH:MM AM_PM - a revision number - HEAD, BASE, COMMITED or PREV No Example: <svn> <switchpath="workingcopy/switchTest"url="${urlRepos}/switchTestBranch"/> </svn> update Bring changes from the repository into the working copy. If no revision given, bring working copy up-to-date with HEAD rev. Else synchronize working copy to revision. Attribute Description Required file file to update No dir directory to update No recurse Set to "false" to operate on a single directory only (applies only when dir attribute is set). Default is "true" No revision revision. Defaults is "HEAD" Possible values are : - a date with the following format : MM/DD/YYYY HH:MM AM_PM - a revision number - HEAD, BASE, COMMITED or PREV No Parameters specified as nested elements : fileset Filesets are used to select sets of files to update. Examples Checkout a working copy from repository: <svnjavahl="${javahl}"> <checkouturl="${urlRepos}"destPath="workingcopy"/> </svn> Delete some files from repository (and commit changes) <svn> <delete> <filesetdir="workingcopy/deleteTest"> <includename="**/*.del"/> </fileset> </delete> <commitmessage="commit deleted files"dir="workingcopy/deleteTest"/> </svn> Add my_repos/propTest to repository and set two properties on file.png Subversion command line interface is used (javahl="false"). <svn> <adddir="workingcopy/propTest"/> <commitmessage="propTest added"dir="workingcopy/propTest"/> <propsetpath="workingcopy/propTest/file.png"name="svn:mime-type"value="image/png"/> <propsetpath="workingcopy/propTest/file.png"name="myPicture"file="workingcopy/propTest/icon.gif"/> </svn> --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@subclipse.tigris.org For additional commands, e-mail: users-help@subclipse.tigris.org The contents of this email are the property of the sender. If it was not addressed to you, you have no legal right to read it. If you think you received it in error, please notify the sender. Do not forward or copy without permission of the sender.Received on Sat Dec 10 01:58:19 2005 |
This is an archived mail posted to the Subclipse Users mailing list.
This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.