读书人

SVN ANT下令

发布时间: 2012-11-06 14:07:00 作者: rapoo

SVN ANT命令
<Svn>By Cédric Chabanois et al.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:

ParametersAttributeDescriptionRequiredusernameusername that will be used for all nested svn commands.Nopasswordpassword that will be used for all nested svn commands.NojavahlSet to “false” to use command line client interface instead of JNI JavaHL binding.No (Defaults to true)svnkitSet to “false” to use command line client interface instead of SVNKit binding.No (Defaults to false)dateFormatterformatter definition used to format/parse dates (e.g. when revision is specified as date).No (Defaults to "MM/DD/YYYY HH:MM AM_PM")dateTimeZonetime zone used to format/parse dates (e.g. when revision is specified as date).No (Defaults to local)failonerrorControls whether an error stops the build or is merely reported to the screen.No (Defaults to "true")Svn commands specified as nested elementsadd createRepositoryimportmoverevertcatdeleteinfomkdirstatuscheckoutdiffkeywordssetpropdelswitchcommitexportkeywordsaddpropgetupdatecopyignorekeywordsremovepropsetwcVersioncleanup add

You can add files and directories to svn repository with nested <add> elements.

AttributeDescriptionRequiredfilefile to add to the repositoryNodirdirectory to add to the repositoryNorecurseSet to "false" to operate on a single directory only(applies only when dir attribute is set). Default is"true"NoforceSet to "true" to check the contents of a directory thatis 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.
Notethat directories needed to add selected files will be added to therepository even if they are not selected by the fileset.

?

cat

Get the content of a file on repository.

AttributeDescriptionRequireddestFileName of the destination fileNo
(default is the name of the file on the url placed in the ant project's basedir)urlUrl of the file in repositoryYesrevisionrevision to get.
Possible values are :
- a date with theformat as specified in dateFormatter attribute
- a revision number
-HEAD, BASE, COMMITED or PREV
Default is "HEAD"Nocheckout

Check out a working copy from a repository.

AttributeDescriptionRequiredurlurl to checkout fromYesrecurseSet to "false" to operate on single directory only.Default is "true"NodestPathdestination directoryYesrevisionrevision to checkout.
Possible values are :
- a date withthe format as specified in dateFormatter attribute
- a revisionnumber
- HEAD, BASE, COMMITED or PREV
Default is "HEAD"Nocommit

Send changes from your working copy to the repository.

AttributeDescriptionRequiredfilefile to commitNorecurseSet to "false" to operate on single directory only.Default is "true"
Apply only when dir attribute isset.Nodirdirectory to commitNomessagecommit messageYes

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 URLURL->WC: check out URL into WC, schedule for additionURL->URL: complete server-side copy; used to branch & tag

?


AttributeDescriptionRequiredsrcPathsource pathOne of the twosrcUrlsource urltestPathdestination pathOne of the twodestUrldestination urlmessagecommit messagewhen destUrl is setrevisionrevision to copy from (when srcUrl is set)
Possible valuesare :
- a date with the format as specified in dateFormatter attribute
- a revision number
- HEAD, BASE, COMMITED orPREV
Default is "HEAD"nocreateRepository

Create a new, empty repository at path.

AttributeDescriptionRequiredpathPath where to create the new repositoryYesdelete

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.

AttributeDescriptionRequiredfilefile to deleteNourlurl to deleteNodirdirectory to deleteNomessagecommit messagewhen url attribute is setforcedefault 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).

AttributeDescriptionRequiredoldPathIf oldUrl is not set, defaults to the path '.'NooldUrl NooldTargetRevisiondefaults to BASE or, if oldUrl is set, to HEADNonewPathdefaults to oldPath if oldUrl is not setNonewUrl NonewTargetRevisiondefaults to the current working version or, if newUrl is set, to HEADNooutFileDefault is 'patch'NorecurseSet to "false" to operate on single directory only.Default is "true"Noexport

?

    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 bysrcPath into destPath. all local changes will be preserved, but files not under revision control will not be copied.

?


AttributeDescriptionRequiredsrcUrlsource url to export fromOne of the twosrcPathsource path to export fromdestPathdestination pathYesrevisionrevision of the source url to export from. Defaults is"HEAD"
Possible values are :
- a date with theformat as specified in dateFormatter attribute
- a revision number
-HEAD, BASE, COMMITED or PREVNo (defaults to HEAD)ignore

Add a given file or a pattern to the ignored files list (modifiessvn:ignore property)

AttributeDescriptionRequiredfilefile to ignoreOne of the twodirdirectory on which we will update svn:ignore propertypatternpattern to add to svn:ignore on the directory
Only when diris setYesrecurseSet to "true" to add the pattern recursively todirectories. Default is "false"
Only when dir is setNoimport

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.

AttributeDescriptionRequiredpathsource path to export fromYesurlsource url to import toYesnewEntry Nomessagecommit messageYesrecurseSet to "false" to operate on single directory only.Default is "true"Falseinfo

Gets the information from the repository for a file, directory or url and setsthe values to ant properties.

AttributeDescriptionRequiredtargetDirectory or file to gather the information about.YespropPrefixPrefix to use for the properties. Default is "svn.info.".FalseverboseTurns on verbosity for this task. Default is "false".False

?

The task sets the following properties (prefix applied accordingly):

PropertyDescriptionpathAlwaysnameFor files onlyurlAlwaysrepouuidAlwaysrevAlwaysnodekindAlwaysscheduleAlwaysauthorAlwayslastRevAlwayslastDateAlwayslastTextUpdateFor files onlylastPropUpdateFor files onlychecksumFor files onlykeywordsset

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 objectchanged.Id : A compressed summary of the previous

?


AttributeDescriptionRequiredfileFile for which keywords will be substitutedEither file, dir or filesetsdirAll files in this directory will have their keywords substituted (recursively)Either file, dir or filesetskeywordsThe keywords to substitute on the given filesNoHeadURL/URL
Author, LastChangedBy
Date,LastChangedDate
Rev, LastChangedRevision
IdSet to “true“ the keyword to substitute it on thegiven 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.

AttributeDescriptionRequiredpathpath to createOne of the twourlurl to createmessagecommit messageYesmove

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.

AttributeDescriptionRequiredsrcPathsource pathOne of the twosrcUrlsource urldestPathdestination pathOne of the twodestUrldestination urlmessagecommit messageYespropdel

Remove a property from files or dirs.

AttributeDescriptionRequiredpathpath of the file or directory on which to delete the propertyYesnamename of the property to deleteYesrecurseif set, property will be removed recursivelyNopropget

Get a property from a file or a directory.

AttributeDescriptionRequiredpathpath of the file or directory on which to get the propertyOne of the twourlurl of the file or directory in repository on which to get the propertynamename of the property to getYespropertythe name of the property to set with the value of the svn propertyOne of the twofilefile that will contain the value of the propertypropset

Set a property on files or dirs.

AttributeDescriptionRequiredpathpath of the file or directory on which to set the propertyYesnamename of the property to setYesvaluethe value of the propertyOne of the twofilethe file that will be used as a valuerecurseif set, property will be set recursivelyNo

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 setthe 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, andhow to serve it from Apache.
A mimetype beginning with 'text/' (or an absent mimetype) is treated as text. Anything else istreated as binary. svn:externals : A newline separated list of modulespecifiers, 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).

AttributeDescriptionRequiredfilefile to revertNodirdirectory to revertNorecurseSet to "false" to operate on a single directory only(applies only when dir attribute is set). Default is"false"Norevisionrevision. Defaults is "HEAD"
Possible values are:
- a date with the format as specified in dateFormatter attribute
-a revision number
- HEAD, BASE, COMMITED or PREVNo

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.

AttributeDescriptionRequiredpathpath of the file or directoryYestextStatusPropertyName of the property to set to the status of the itemNopropStatusPropertyName of the property to set to the status of the itempropertiesNorevisionPropertyName of the property to set to the revision of the item (or “”if unversioned)NolastChangedRevisionPropertyName of the property to set to the last changed revision of theitem (or “” if unversioned)NolastChangedDatePropertyName of the property to set to the last changed date of theitem (or “” if unversioned). The date is formatted according to task's "dateFormatter"NolastCommitAuthorPropertyName of the property to set to the last commit author (or “”if unversioned)NourlPropertyName of the property to set to the url of the itemNo

The value of TextStatusProperty can be :

non-svnnormal : no modificationsaddedmissing : item is missing (removed by non-svn command)incompletedeletedreplacedmodifiedmergedconflictedobstructedignoredexternalunversionedThe value of propStatusProperty can be :normal : nomodificationsconflictedmodified

?

?

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.

AttributeDescriptionRequiredpathThe working copy to switch to the given urlYesurlThe url to switch toYesrecurseSet to "false" to operate on a single directory only.Default is "true"Norevisionrevision. Defaults is "HEAD"
Possible values are:
- a date with the format as specified in dateFormatter attribute
-a revision number
- HEAD, BASE, COMMITED or PREVNo

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.

AttributeDescriptionRequiredfilefile to updateNodirdirectory to updateNorecurseSet to "false" to operate on a single directory only(applies only when dir attribute is set). Default is"true"Norevisionrevision. Defaults is "HEAD"
Possible values are:
- a date with the format as specified in dateFormatter attribute
-a revision number
- HEAD, BASE, COMMITED or PREVNoParameters specified as nested elements :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.

AttributeDescriptionRequiredpatha path to the working copyYesprefixa string which will be prefixed to output properties set/filled by this commandNoprocessUnversionedflag whether presence of unversioned resoures should be treated as changesNo (defaults to false)

The command fill set the following properties: (with optional prefix applied)

Property nameDescriptionrepository.urlURL of the repository of the working copy rootrepository.pathpath in the repositoryrevision.maxthe highest revision number in the working copyrevision.max-with-flagsthe highest revision number in the working copy plus flags (M - modified, X - mixed)revision.rangethe revision range (in mixed wc), similar to svnversion format. (e.g. 1000:1010MX)committed.maxthe highest 'last committed revision'committed.max-with-flagsthe highest 'last committed revision' plus flags (M, X)modifiedset to "true" if working copy is modified, property not set otherwisemixedset 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 -> true
Example 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

AttributeDescriptionRequireddirdirectory to cleanupYes

?

Examples

?

<svnjavahl="${javahl}">
<checkouturl="${urlRepos}"destPath="workingcopy"/>
</svn>

checkouts a working copy from repository

?

?

?

<svn>
<delete>
<filesetdir="workingcopy/deleteTest">
<includename="**/*.del"/> </fileset>
</delete>
<commitmessage="commitdeleted files" dir="workingcopy/deleteTest"/>
</svn>

deletes some files from repository (and commit changes)

?

?

<svn>
<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").

读书人网 >CVS SVN

热点推荐