Class SVNCopyClient
- java.lang.Object
-
- org.tmatesoft.svn.core.wc.SVNBasicClient
-
- org.tmatesoft.svn.core.wc.SVNCopyClient
-
public class SVNCopyClient extends SVNBasicClient
The SVNCopyClient provides methods to perform any kinds of copying and moving that SVN supports - operating on both Working Copies (WC) and URLs.Copy operations allow a user to copy versioned files and directories with all their previous history in several ways.
Supported copy operations are:
- Working Copy to Working Copy (WC-to-WC) copying - this operation copies the source Working Copy item to the destination one and schedules the source copy for addition with history.
- Working Copy to URL (WC-to-URL) copying - this operation commits to the repository (exactly to that repository location that is specified by URL) a copy of the Working Copy item.
- URL to Working Copy (URL-to-WC) copying - this operation will copy the source item from the repository to the Working Copy item and schedule the source copy for addition with history.
- URL to URL (URL-to-URL) copying - this is a fully repository-side operation, it commits a copy of the source item to a specified repository location (within the same repository, of course).
Besides just copying SVNCopyClient also is able to move a versioned item - that is first making a copy of the source item and then scheduling the source item for deletion when operating on a Working Copy, or right committing the deletion of the source item when operating immediately on the repository.
Supported move operations are:
- Working Copy to Working Copy (WC-to-WC) moving - this operation copies the source Working Copy item to the destination one and schedules the source item for deletion.
- URL to URL (URL-to-URL) moving - this is a fully repository-side operation, it commits a copy of the source item to a specified repository location and deletes the source item.
Overloaded doCopy() methods of SVNCopyClient are similar to
'svn copy'and'svn move'commands of the SVN command line client.- Since:
- 1.2
- Version:
- 1.3
- Author:
- TMate Software Ltd.
- See Also:
- Examples
-
-
Constructor Summary
Constructors Constructor Description SVNCopyClient(ISVNAuthenticationManager authManager, ISVNOptions options)Constructs and initializes an SVNCopyClient object with the specified run-time configuration and authentication drivers.SVNCopyClient(ISVNRepositoryPool repositoryPool, ISVNOptions options)Constructs and initializes an SVNCopyClient object with the specified run-time configuration and repository pool object.SVNCopyClient(SvnOperationFactory of)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddoCopy(java.io.File nestedWC)Converts a disjoint working copy to a copied one.voiddoCopy(SVNCopySource[] sources, java.io.File dst, boolean isMove, boolean makeParents, boolean failWhenDstExists)Copies each source insourcestodst.voiddoCopy(SVNCopySource[] sources, java.io.File dst, boolean isMove, boolean makeParents, boolean failWhenDstExists, boolean allowMixedRevisions, boolean metadataOnly)Copies each source insourcestodst.voiddoCopy(SVNCopySource[] sources, java.io.File dst, boolean isMove, boolean makeParents, boolean failWhenDstExists, boolean pinExternals, java.util.Map<SvnTarget,java.util.List<org.tmatesoft.svn.core.internal.wc.SVNExternal>> externalsToPin)SVNCommitInfodoCopy(SVNCopySource[] sources, SVNURL dst, boolean isMove, boolean makeParents, boolean failWhenDstExists, java.lang.String commitMessage, SVNProperties revisionProperties)Copies each source insourcestodst.SVNCommitInfodoCopy(SVNCopySource[] sources, SVNURL dst, boolean isMove, boolean makeParents, boolean failWhenDstExists, java.lang.String commitMessage, SVNProperties revisionProperties, boolean pinExternals, java.util.Map<SvnTarget,java.util.List<org.tmatesoft.svn.core.internal.wc.SVNExternal>> externalsToPin)ISVNCommitHandlergetCommitHandler()Returns the specified commit handler (if set) being in use or a default one (DefaultSVNCommitHandler) if no special implementations of ISVNCommitHandler were previousely provided.ISVNCommitParametersgetCommitParameters()Returns commit parameters.ISVNExternalsHandlergetExternalsHandler()Returns an externals handler used by this update client.protected voidinitDefaults()voidsetCommitHandler(ISVNCommitHandler handler)Sets an implementation of ISVNCommitHandler to the commit handler that will be used during commit operations to handle commit log messages.voidsetCommitParameters(ISVNCommitParameters parameters)Sets commit parameters to use.voidsetDisableLocalModificationCopying(boolean disable)voidsetExternalsHandler(ISVNExternalsHandler externalsHandler)Sets an externals handler to be used by this client object.-
Methods inherited from class org.tmatesoft.svn.core.wc.SVNBasicClient
dontWC17Support, getDebugLog, getOperationsFactory, getOptions, getPathListHandler, getReposRoot, getReposRoot, isIgnoreExternals, isLeaveConflictsUnresolved, isWC17Supported, setDebugLog, setEventHandler, setEventPathPrefix, setIgnoreExternals, setLeaveConflictsUnresolved, setOptions, setPathListHandler
-
-
-
-
Constructor Detail
-
SVNCopyClient
public SVNCopyClient(ISVNAuthenticationManager authManager, ISVNOptions options)
Constructs and initializes an SVNCopyClient object with the specified run-time configuration and authentication drivers.If
optionsis null, then this SVNCopyClient will be using a default run-time configuration driver which takes client-side settings from the default SVN's run-time configuration area but is not able to change those settings (read more onISVNOptionsandSVNWCUtil).If
authManageris null, then this SVNCopyClient will be using a default authentication and network layers driver (seeSVNWCUtil.createDefaultAuthenticationManager()) which uses server-side settings and auth storage from the default SVN's run-time configuration area (or system properties if that area is not found).- Parameters:
authManager- an authentication and network layers driveroptions- a run-time configuration options driver
-
SVNCopyClient
public SVNCopyClient(ISVNRepositoryPool repositoryPool, ISVNOptions options)
Constructs and initializes an SVNCopyClient object with the specified run-time configuration and repository pool object. Ifoptionsis null, then this SVNCopyClient will be using a default run-time configuration driver which takes client-side settings from the default SVN's run-time configuration area but is not able to change those settings (read more onISVNOptionsandSVNWCUtil). IfrepositoryPoolis null, thenSVNRepositoryFactorywill be used to createrepository access objects.- Parameters:
repositoryPool- a repository pool objectoptions- a run-time configuration options driver
-
SVNCopyClient
public SVNCopyClient(SvnOperationFactory of)
-
-
Method Detail
-
initDefaults
protected void initDefaults()
- Overrides:
initDefaultsin classSVNBasicClient
-
setCommitHandler
public void setCommitHandler(ISVNCommitHandler handler)
Sets an implementation of ISVNCommitHandler to the commit handler that will be used during commit operations to handle commit log messages. The handler will receive a clien's log message and items (represented as SVNCommitItem objects) that will be committed. Depending on implementor's aims the initial log message can be modified (or something else) and returned back.If using SVNCopyClient without specifying any commit handler then a default one will be used -
DefaultSVNCommitHandler.- Parameters:
handler- an implementor's handler that will be used to handle commit log messages- See Also:
getCommitHandler(),SVNCommitItem
-
getCommitHandler
public ISVNCommitHandler getCommitHandler()
Returns the specified commit handler (if set) being in use or a default one (DefaultSVNCommitHandler) if no special implementations of ISVNCommitHandler were previousely provided.- Returns:
- the commit handler being in use or a default one
- See Also:
setCommitHandler(ISVNCommitHandler),DefaultSVNCommitHandler
-
setCommitParameters
public void setCommitParameters(ISVNCommitParameters parameters)
Sets commit parameters to use.When no parameters are set
defaultones are used.- Parameters:
parameters- commit parameters- See Also:
getCommitParameters()
-
getCommitParameters
public ISVNCommitParameters getCommitParameters()
Returns commit parameters.If no user parameters were previously specified, once creates and returns
defaultones.- Returns:
- commit parameters
- See Also:
setCommitParameters(ISVNCommitParameters)
-
setExternalsHandler
public void setExternalsHandler(ISVNExternalsHandler externalsHandler)
Sets an externals handler to be used by this client object.- Parameters:
externalsHandler- user's implementation ofISVNExternalsHandler- Since:
- 1.2
- See Also:
getExternalsHandler()
-
setDisableLocalModificationCopying
public void setDisableLocalModificationCopying(boolean disable)
-
getExternalsHandler
public ISVNExternalsHandler getExternalsHandler()
Returns an externals handler used by this update client. If no user's handler is provided thenISVNExternalsHandler.DEFAULTis returned and used by this client object by default. For more information what externals handlers are for, please, refer toISVNExternalsHandleranddoCopy(SVNCopySource[], SVNURL, boolean, boolean, boolean, String, SVNProperties).- Returns:
- externals handler being in use
- Since:
- 1.2
- See Also:
setExternalsHandler(ISVNExternalsHandler)
-
doCopy
public void doCopy(SVNCopySource[] sources, java.io.File dst, boolean isMove, boolean makeParents, boolean failWhenDstExists) throws SVNException
Copies each source insourcestodst. If multiplesourcesare given,dstmust be a directory, andsourceswill be copied as children ofdst. Eachsrcinsourcesmust be files or directories under version control, or URLs of a versioned item in the repository. Ifsourceshas multiple items, they must be all repository URLs or all working copy paths. The parent ofdstmust already exist. Ifsourceshas only one item, attempts to copy it todst. IffailWhenDstExistsis false anddstalready exists, attempts to copy the item as a child ofdst. IffailWhenDstExistsis true anddstalready exists, throws anSVNExceptionwith theSVNErrorCode.ENTRY_EXISTSerror code. Ifsourceshas multiple items, andfailWhenDstExistsis false, allsourcesare copied as children ofdst. If any child ofdstalready exists with the same name any item insources, throws anSVNExceptionwith theSVNErrorCode.ENTRY_EXISTSerror code. Ifsourceshas multiple items, andfailWhenDstExistsis true, throws anSVNExceptionwith theSVNErrorCode.CLIENT_MULTIPLE_SOURCES_DISALLOWED. This method is just a variant of a local add operation, wheresourcesare scheduled for addition as copies. No changes will happen to the repository until a commit occurs. This scheduling can be removed withSVNWCClient.doRevert(File[], SVNDepth, Collection). IfmakeParents is true, creates any non-existent parent directories also. If the caller'sISVNEventHandleris non-null, invokes it for each item added at the new location. Note: this routine requires repository access only when sources are urls.- Parameters:
sources- array of copy sourcesdst- destination working copy pathisMove- if true, then it will be a move operation (delete, then add with history)makeParents- if true, creates non-existent parent directories as wellfailWhenDstExists- controls whether to fail or not ifdstalready exists- Throws:
SVNException- Since:
- 1.2, SVN 1.5
-
doCopy
public void doCopy(SVNCopySource[] sources, java.io.File dst, boolean isMove, boolean makeParents, boolean failWhenDstExists, boolean pinExternals, java.util.Map<SvnTarget,java.util.List<org.tmatesoft.svn.core.internal.wc.SVNExternal>> externalsToPin) throws SVNException
- Throws:
SVNException
-
doCopy
public void doCopy(SVNCopySource[] sources, java.io.File dst, boolean isMove, boolean makeParents, boolean failWhenDstExists, boolean allowMixedRevisions, boolean metadataOnly) throws SVNException
Copies each source insourcestodst. If multiplesourcesare given,dstmust be a directory, andsourceswill be copied as children ofdst. Eachsrcinsourcesmust be files or directories under version control, or URLs of a versioned item in the repository. Ifsourceshas multiple items, they must be all repository URLs or all working copy paths. The parent ofdstmust already exist. Ifsourceshas only one item, attempts to copy it todst. IffailWhenDstExistsis false anddstalready exists, attempts to copy the item as a child ofdst. IffailWhenDstExistsis true anddstalready exists, throws anSVNExceptionwith theSVNErrorCode.ENTRY_EXISTSerror code. Ifsourceshas multiple items, andfailWhenDstExistsis false, allsourcesare copied as children ofdst. If any child ofdstalready exists with the same name any item insources, throws anSVNExceptionwith theSVNErrorCode.ENTRY_EXISTSerror code. Ifsourceshas multiple items, andfailWhenDstExistsis true, throws anSVNExceptionwith theSVNErrorCode.CLIENT_MULTIPLE_SOURCES_DISALLOWED. This method is just a variant of a local add operation, wheresourcesare scheduled for addition as copies. No changes will happen to the repository until a commit occurs. This scheduling can be removed withSVNWCClient.doRevert(File[], SVNDepth, Collection). IfmakeParents is true, creates any non-existent parent directories also. If the caller'sISVNEventHandleris non-null, invokes it for each item added at the new location. Note: this routine requires repository access only when sources are urls.- Parameters:
sources- array of copy sourcesdst- destination working copy pathisMove- if true, then it will be a move operation (delete, then add with history)makeParents- if true, creates non-existent parent directories as wellfailWhenDstExists- controls whether to fail or not ifdstalready existsallowMixedRevisions- allow to move directories with nodes with mixed revisions in itmetadataOnly- don't copy physical files- Throws:
SVNException- Since:
- 1.8, SVN 1.8
-
doCopy
public SVNCommitInfo doCopy(SVNCopySource[] sources, SVNURL dst, boolean isMove, boolean makeParents, boolean failWhenDstExists, java.lang.String commitMessage, SVNProperties revisionProperties) throws SVNException
Copies each source insourcestodst. If multiplesourcesare given,dstmust be a directory, andsourceswill be copied as children ofdst. Eachsrcinsourcesmust be files or directories under version control, or URLs of a versioned item in the repository. Ifsourceshas multiple items, they must be all repository URLs or all working copy paths. The parent ofdstmust already exist. Ifsourceshas only one item, attempts to copy it todst. IffailWhenDstExistsis false anddstalready exists, attempts to copy the item as a child ofdst. IffailWhenDstExistsis true anddstalready exists, throws anSVNExceptionwith theSVNErrorCode.FS_ALREADY_EXISTSerror code. Ifsourceshas multiple items, andfailWhenDstExistsis false, allsourcesare copied as children ofdst. If any child ofdstalready exists with the same name any item insources, throws anSVNExceptionwith theSVNErrorCode.FS_ALREADY_EXISTSerror code. Ifsourceshas multiple items, andfailWhenDstExistsis true, throws anSVNExceptionwith theSVNErrorCode.CLIENT_MULTIPLE_SOURCES_DISALLOWED.Authentication manager(whether provided directly through the appropriate constructor or in anISVNRepositoryPoolinstance) andcommit handlerare used to immediately attempt to commit the copy action in the repository. IfmakeParents is true, creates any non-existent parent directories also. If non-null,revisionPropertiesis an object holding additional, custom revision properties (StringtoSVNPropertyValuemappings) to be set on the new revision. This table cannot contain any standard Subversion properties. If the caller'sISVNEventHandleris non-null, invokes it for each item added at the new location. When performing a wc-to-url copy (tagging|branching from a working copy) it's possible to fix revisions of external working copies (if any) which are located within the working copy being copied. For example, imagine you have a working copy and on one of its subdirecotries you set an "svn:externals" property which does not contain a revision number. Suppose you have made a tag from your working copy and in some period of time a user checks out that tag. It could have happened that the external project has evolved since the tag creation moment and the tag version is nomore compatible with it. So, the user has a broken project since it will not compile because of the API incompatibility between the two versions of the external project: the HEAD one and the one existed in the moment of the tag creation. That is why it appears useful to fix externals revisions during a wc-to-url copy. To enable externals revision fixing a user should implementISVNExternalsHandler. The user's implementationISVNExternalsHandler.handleExternal(File, SVNURL, SVNRevision, SVNRevision, String, SVNRevision)method will be called on every external that will be met in the working copy. If the user's implementation returns non-null external revision, it's compared with the revisions fetched from the external definition. If they are different, the user's revision will be written in the external definition of the tag. Otherwise if the returned revision is equal to the revision from the external definition or if the user's implementation returns null for that external, it will be skipped (i.e. left as is, unprocessed). Note: this routine requires repository access.- Parameters:
sources- array of copy sourcesdst- destination urlisMove- if true, then it will be a move operation (delete, then add with history)makeParents- if true, creates non-existent parent directories as wellfailWhenDstExists- controls whether to fail or not ifdstalready existscommitMessage- commit log messagerevisionProperties- custom revision properties- Returns:
- information about the new committed revision
- Throws:
SVNException- Since:
- 1.2, SVN 1.5
-
doCopy
public SVNCommitInfo doCopy(SVNCopySource[] sources, SVNURL dst, boolean isMove, boolean makeParents, boolean failWhenDstExists, java.lang.String commitMessage, SVNProperties revisionProperties, boolean pinExternals, java.util.Map<SvnTarget,java.util.List<org.tmatesoft.svn.core.internal.wc.SVNExternal>> externalsToPin) throws SVNException
- Throws:
SVNException
-
doCopy
public void doCopy(java.io.File nestedWC) throws SVNExceptionConverts a disjoint working copy to a copied one. Note: this routine does not require repository access. However if it's performed on an old format working copy where repository root urls were not written, the routine will connect to the repository to fetch the repository root url.- Parameters:
nestedWC- the root of the working copy located in another working copy (disjoint wc)- Throws:
SVNException- in the following cases:-
exception with
SVNErrorCode.UNSUPPORTED_FEATUREerror code - ifnestedWCis either not a directory, or has no parent at all; if the current local filesystem parent ofnestedWCis actually a child of it in the repository exception withSVNErrorCode.ENTRY_EXISTSerror code - ifnestedWCis not a disjoint working copy, i.e. there is already a versioned item under the parent path ofnestedWC; ifnestedWCis not in the repository yet (has got a schedule for addition flag) exception withSVNErrorCode.WC_INVALID_SCHEDULEerror code - ifnestedWCis not from the same repository as the parent directory; if the parent ofnestedWCis scheduled for deletion; ifnestedWCis scheduled for deletion- Since:
- 1.2.0
-
-