<Svn>
Description
This task provides an interface to Subversion revision control system that is a compelling replacement for CVS in the open source community.
With the help of the underlying svnClientAdapter, <svn> task uses JavaHL (a native JNI interface to the subversion api) if itcan find the corresponding library (e.g. svnjavahl.dll on windows).Otherwise it uses svn command line interface.
Setup
As with most Ant extensions, SvnAnt's task and type names must bemappedto their implementing classes before being used in an Ant buildfile. An example of how to use the antlib bundled inSvnAnt's JAR file to perform that registration follows:
Parameters
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 instead of JNI JavaHL binding. | No (Defaults to true) |
svnkit | Set to “false” to use command line client interface instead of SVNKit binding. | No (Defaults to false) |
dateFormatter | formatter definition used to format/parse dates (e.g. when revision is specified as date). | No (Defaults to "MM/DD/YYYY HH:MM AM_PM") |
dateTimeZone | time zone used to format/parse dates (e.g. when revision is specified as date). | No (Defaults to local) |
failonerror | Controls whether an error stops the build or is merely reported to the screen. | No (Defaults to "true") |
Svn commands specified as nested elements
add | createRepository | import | move | revert |
cat | delete | info | mkdir | status |
checkout | diff | keywordsset | propdel | switch |
commit | export | keywordsadd | propget | update |
copy | ignore | keywordsremove | propset | wcVersion |
cleanup |
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 |
force | Set to "true" to check the contents of a directory that is already under source control for new directories/files (applies only when dir attribute is set). Default is "false" | 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 placed in the ant project's basedir) |
url | Url of the file in repository | Yes |
revision | revision to get. Possible values are : - a date with the format as specified in dateFormatter attribute - 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 format as specified in dateFormatter attribute - a revision number - HEAD, BASE, COMMITED or PREV Default is "HEAD" | No |
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, rememberinghistory.
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 | One of the two |
srcUrl | source url | |
testPath | destination path | One of the two |
destUrl | destination url | |
message | commit message | when destUrl is set |
revision | revision to copy from (when srcUrl is set) Possible values are : - a date with the format as specified in dateFormatter attribute - 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 fordeletion upon the next commit. Files, and directories that havenot 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 overridethis 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) ortwo 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 revisionrevision
if it is given, otherwise at HEAD, intodestPath
. - Exports a clean directory tree from the working copy specified by
srcPath
intodestPath
. 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 format as specified in dateFormatter attribute - a revision number - HEAD, BASE, COMMITED or PREV | No (defaults to HEAD) |
ignore
Add a given file or a pattern to the ignored files list (modifiessvn: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 :
<ignoredir="workingcopy/ignoreTest/dir1"pattern="*.ignore"recurse="true"/>
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 path
intourl
directly. 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
Gets the information from the repository for a file, directory or url and setsthe values to ant properties.
Attribute | Description | Required |
target | Directory or file to gather the information about. | Yes |
propPrefix | Prefix to use for the properties. Default is "svn.info.". | False |
verbose | Turns on verbosity for this task. Default is "false". | False |
?
The task sets the following properties (prefix applied accordingly):
Property | Description |
path | Always |
name | For files only |
url | Always |
repouuid | Always |
rev | Always |
nodekind | Always |
schedule | Always |
author | Always |
lastRev | Always |
lastDate | Always |
lastTextUpdate | For files only |
lastPropUpdate | For files only |
checksum | For files only |
keywordsset
Keywordsset controls which keywords will be substituted on thegiven 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 givenfiles. Present keywords are not modified.
The attributes are the same than for keywordsset command.
keywordsremove
Keywordsadd remove some keywords to be substituted on the givenfiles. 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 theworking copy. If target is an url the directory is created inthe 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 orURLs:
WC -> WC: move andschedule for addition (with history)
URL ->URL: complete server-side rename.
Attribute | Description | Required |
srcPath | source path | One of the two |
srcUrl | source url | |
destPath | destination path | One of the two |
destUrl | destination url | |
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 | One of the two |
url | url of the file or directory in repository on which to get the property | |
name | name of the property to get | Yes |
property | the name of the property to set with the value of the svn property | One of the two |
file | file that will contain the value of the property |
Example :
<propgetpath="workingcopy/propTest/file.png"name="svn:mime-type"property="propTest.mimeType"/>
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 | One of the two |
file | the file that will be used as a value | |
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 format as specified in dateFormatter attribute - 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 |
lastChangedDateProperty | Name of the property to set to the last changed date of the item (or “” if unversioned). The date is formatted according to task's "dateFormatter" | 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
- normal : no modifications
- conflicted
- modified
?
?
Example :
<statuspath="workingcopy/statusTest/added.txt"textStatusProperty="testStatus.textStatus"propStatusProperty="testStatus.propStatus"lastChangedRevisionProperty="testStatus.lastCommitRevision"revisionProperty="testStatus.revision"lastCommitAuthorProperty="testStatus.lastCommitAuthor"
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 aworking 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 format as specified in dateFormatter attribute - 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 norevision 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 format as specified in dateFormatter attribute - a revision number - HEAD, BASE, COMMITED or PREV | No |
- fileset
Filesets are used to select sets of files to update.
wcVersion
Retrieves a state of the working copy. Similar to the svn's utility svnversion, just providing more.
Crawls the working copy and retrieves the maximum revision number, revision range if workingCopy is mixed etc.
Attribute | Description | Required |
path | a path to the working copy | Yes |
prefix | a string which will be prefixed to output properties set/filled by this command | No |
processUnversioned | flag whether presence of unversioned resoures should be treated as changes | No (defaults to false) |
The command fill set the following properties: (with optional prefix applied)
Property name | Description |
repository.url | URL of the repository of the working copy root |
repository.path | path in the repository |
revision.max | the highest revision number in the working copy |
revision.max-with-flags | the highest revision number in the working copy plus flags (M - modified, X - mixed) |
revision.range | the revision range (in mixed wc), similar to svnversion format. (e.g. 1000:1010MX) |
committed.max | the highest 'last committed revision' |
committed.max-with-flags | the highest 'last committed revision' plus flags (M, X) |
modified | set to "true" if working copy is modified, property not set otherwise |
mixed | set to "true" if working copy is mixed, property not set otherwise |
An example of the properties that would be set in a sample working copy (with modifications):
(with prefix="svn.")
svn.repository.url -> https://server/repos/branches/1.2.xsvn.repository.path -> /repos/branches/1.2.xsvn.revision.max -> 676svn.revision.max-with-flags -> 676Msvn.revision.range -> 676Msvn.committed.max -> 651svn.committed.max-with-flags -> 651Msvn.modified -> trueExample output in case of mixed and modified working copy:(without prefix set)
repository.url -> https://server/repos/branches/1.2.xrepository.path -> /repos/branches/1.2.xrevision.max -> 676revision.max-with-flags -> 676MXrevision.range -> 673:676Msvn.committed.max -> 651svn.committed.max-with-flags -> 651Mmodified -> truemixed -> true
?
cleanup
cleanup your working copy
Attribute | Description | Required |
dir | directory to cleanup | Yes |
?
Examples
?
<checkouturl="${urlRepos}"destPath="workingcopy"/>
</svn>
checkouts a working copy from repository
?
?
?
<delete>
<filesetdir="workingcopy/deleteTest">
<includename="**/*.del"/> </fileset>
</delete>
<commitmessage="commitdeleted files" dir="workingcopy/deleteTest"/>
</svn>
deletes some files from repository (and commit changes)
?
?
<adddir="workingcopy/propTest"/>
<commitmessage="propTestadded" 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>
add my_repos/propTest to repository and set two properties on file.png
subversion command line interface is used (javahl="false").