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.
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 addYou can add files and directories to svn repository with nested <add>
elements.
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"NoParameters specified as nested elements :
fileset?
catGet the content of a file on repository.
AttributeDescriptionRequireddestFileName of the destination fileNoCheck 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.Send changes from your working copy to the repository.
AttributeDescriptionRequiredfilefile to commitNorecurseSet to "false" to operate on single directory only.Default is "true"Parameters specified as nested elements :
fileset?
copyDuplicate something in working copy or repository, rememberinghistory.
source and destination can each be either a working copy (WC) path or URL:
?
Create a new, empty repository at path.
AttributeDescriptionRequiredpathPath where to create the new repositoryYesdeleteIf 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.
Parameters specified as nested elements :
fileset?
diffDisplay 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?
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.?
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 directoryCommit 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.
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 onlykeywordssetKeywordsset 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?
Parameters specified as nested elements :
fileset?
keywordsaddKeywordsadd add some keywords to be substituted on the givenfiles. Present keywords are not modified.
The attributes are the same than for keywordsset command.
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.
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.
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.
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 recursivelyNopropgetGet 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 propertypropsetSet 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 recursivelyNoNote: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.?
revertRestore pristine working copy file (undo most local edits).
AttributeDescriptionRequiredfilefile to revertNodirdirectory to revertNorecurseSet to "false" to operate on a single directory only(applies only whendir
attribute is set). Default is"false"Norevisionrevision. Defaults is "HEAD"Parameters specified as nested elements :
fileset?
statusGet 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 itemNoThe 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?
?
switchUpdate 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"Example:<svn><switchpath="workingcopy/switchTest"url="${urlRepos}/switchTestBranch"/></svn>
updateBring 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.
dir
attribute is set). Default is"true"Norevisionrevision. Defaults is "HEAD"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.
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 otherwiseAn 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
?
cleanupcleanup your working copy
AttributeDescriptionRequireddirdirectory to cleanupYes?
Examples?
<svnjavahl="${javahl}">checkouts a working copy from repository
?
?
?
<svn>deletes some files from repository (and commit changes)
?
?
<svn>add my_repos/propTest to repository and set two properties on file.png
subversion command line interface is used (javahl="false").