Package org.tmatesoft.svn.core.wc2

## Class SvnCopy

- java.lang.Object
- - org.tmatesoft.svn.core.wc2.SvnOperation<java.lang.Void>
  - - org.tmatesoft.svn.core.wc2.SvnCopy

- All Implemented Interfaces:
    `ISvnOperationOptionsProvider`

      public class SvnCopy
      extends SvnOperation<java.lang.Void>

  Represents copy operation. Copies each source in `sources` to operation's `target` representing working copy path, or converts a disjoint working copy to a copied one, or does virtual copy (see below).
  - If `disjoint` and `virtual` are `false`:

    If multiple `sources` are given, `target` must be a directory, and `sources` will be copied as children of directory.

    Each `src` in `sources` must be files or directories under version control, or URLs of a versioned item in the repository. If `sources` has multiple items, they must be all repository URLs or all working copy paths.

    The parent of `target` must already exist.

    If `sources` has only one item, attempts to copy it to `target`. If `failWhenDstExists` is `false` and `target` already exists, attempts to copy the item as a child of `target`. If `failWhenDstExists` is `true` and `target` already exists, throws an `SVNException` with the `SVNErrorCode.FS_ALREADY_EXISTS` error code.

    If `sources` has multiple items, and `failWhenDstExists` is `false`, all `sources` are copied as children of `target`. If any child of `target` already exists with the same name any item in `sources`, throws an `SVNException` with the `SVNErrorCode.FS_ALREADY_EXISTS` error code.

    If `sources` has multiple items, and `failWhenDstExists` is `true`, throws an `SVNException` with the `SVNErrorCode.CLIENT_MULTIPLE_SOURCES_DISALLOWED`.

    If the caller's `ISVNEventHandler` is non-`null`, invokes it for each item added at the new location.

    This method is just a variant of a local add operation, where `sources` are scheduled for addition as copies. No changes will happen to the repository until a commit occurs. This scheduling can be removed with `SvnRevert`.

    Note: this routine requires repository access only when sources are URLs.
  - If `disjoint` is `true`:

    `Targets` represent the roots of the working copies located in another working copies.

    This copy operation uses only `sources` as operation's parameters.

    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 urls. `SvnOperation.run()` throws `SVNException` in the following cases:
    exception with `SVNErrorCode.UNSUPPORTED_FEATURE` error code - if `target` is either not a directory, or has no parent at all; if the current local filesystem parent of `target` is actually a child of it in the repository
    exception with `SVNErrorCode.ENTRY_EXISTS` error code - if `target` is not a disjoint working copy, i.e. there is already a versioned item under the parent path of `target`; if `target` is not in the repository yet (has got a schedule for addition flag)
    exception with `SVNErrorCode.WC_INVALID_SCHEDULE` error code - if `target` is not from the same repository as the parent directory; if the parent of `target` is scheduled for deletion; if `target` is scheduled for deletion
  - If `virtual` is `true`:

    Copies/moves administrative version control information of a source files to administrative information of a destination file. For example, if you have manually copied/moved a source files to a `target` one (manually means just in the filesystem, not using version control operations) and then would like to turn this copying/moving into a complete version control copy or move operation, use this method that will finish all the work for you - it will copy/move all the necessary administrative information (kept in the source .svn directory) to the `target` .svn directory.

    In that case when you have your files copied/moved in the filesystem, you can not perform standard (version control) copying/moving - since the `target` already exists and the source may be already deleted. Use this method to overcome that restriction.

    This operation uses `sources` and `move` parameters. If `move` is `true` then completes moving `src` to `target`, otherwise completes copying `src` to `dst` `SvnOperation.run()` throws `SVNException` if one of the following is true:
    - `move = true` and `src` still exists
    - `target` does not exist
    - `target` is a directory
    - `src` is a directory
    - `src` is not under version control
    - `target` is already under version control
    - if `src` is copied but not scheduled for addition, and SVNKit is not able to locate the copied directory root for `src`
  Version:
    1.7
  Author:
    TMate Software Ltd.
  See Also:
    `SvnCopySource`

- - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `SvnCopy​(SvnOperationFactory factory)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addCopySource​(SvnCopySource source)` | Adds copy source information to the operation
    `java.util.Map<SvnTarget,​java.util.List<org.tmatesoft.svn.core.internal.wc.SVNExternal>>` | `getExternalsToPin()` |
    `java.util.Collection<SvnCopySource>` | `getSources()` | Returns operation's all copy sources, object containing information about what to copy.
    `boolean` | `isAllowMixedRevisions()` | Gets whether the coping of directories with mixed revisions is allowed
    `boolean` | `isChangesWorkingCopy()` | Gets whether the operation changes working copy
    `boolean` | `isDisjoint()` | Returns whether copy is disjoint working copy.
    `boolean` | `isFailWhenDstExists()` | Gets whether to fail if `target` already exists.
    `boolean` | `isIgnoreExternals()` | Returns whether to ignore externals definitions.
    `boolean` | `isMakeParents()` | Gets whether to make parent folders if don't exist.
    `boolean` | `isMetadataOnly()` |
    `boolean` | `isMove()` | Gets whether to do copy as move operation (delete, then add with history).
    `boolean` | `isPinExternals()` |
    `boolean` | `isVirtual()` | Returns whether copy is virtual copy.
    `void` | `setAllowMixedRevisions​(boolean allowMixedRevisions)` | Sets whether the coping of directories with mixed revisions is allowed
    `void` | `setDisjoint​(boolean disjoint)` | Sets whether copy is disjoint working copy.
    `void` | `setExternalsToPin​(java.util.Map<SvnTarget,​java.util.List<org.tmatesoft.svn.core.internal.wc.SVNExternal>> externalsToPin)` |
    `void` | `setFailWhenDstExists​(boolean isFailWhenDstExist)` | Sets whether to fail if `target` already exists.
    `void` | `setIgnoreExternals​(boolean ignoreExternals)` | Sets whether to ignore externals definitions.
    `void` | `setMakeParents​(boolean isMakeParents)` | Sets whether to make parent folders if don't exist.
    `void` | `setMetadataOnly​(boolean metadataOnly)` |
    `void` | `setMove​(boolean isMove)` | Sets whether to do copy as move operation (delete, then add with history).
    `void` | `setPinExternals​(boolean pinExternals)` |
    `void` | `setVirtual​(boolean virtual)` | Sets whether copy is virtual copy.

    - ### Methods inherited from class org.tmatesoft.svn.core.wc2.SvnOperation

      `addTarget, cancel, ensureArgumentsAreValid, ensureEnoughTargets, ensureHomohenousTargets, getApplicableChangelists, getAuthenticationManager, getCanceller, getDepth, getEventHandler, getFirstTarget, getMaximumTargetsCount, getMinimumTargetsCount, getOperationalWorkingCopy, getOperationFactory, getOptions, getRepositoryPool, getRevision, getSqliteJournalMode, getTargets, hasFileTargets, hasLocalTargets, hasRemoteTargets, initDefaults, isCancelled, isSleepForTimestamp, isUseParentWcFormat, needsHomohenousTargets, run, setApplicalbeChangelists, setDepth, setRevision, setSingleTarget, setSleepForTimestamp, setSqliteJournalMode`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SvnCopy

          protected SvnCopy​(SvnOperationFactory factory)

  - ### Method Detail

    - #### getSources

          public java.util.Collection<SvnCopySource> getSources()

      Returns operation's all copy sources, object containing information about what to copy.
      Returns:
        the copy sources of the operation, unmodifiable

    - #### addCopySource

          public void addCopySource​(SvnCopySource source)

      Adds copy source information to the operation
      Parameters:
        `source` - copy source information

    - #### isMove

          public boolean isMove()

      Gets whether to do copy as move operation (delete, then add with history).
      Returns:
        `true` if move operation should be done, otherwise `false`

    - #### setMove

          public void setMove​(boolean isMove)

      Sets whether to do copy as move operation (delete, then add with history).
      Parameters:
        `isMove` - `true` if move operation should be done, otherwise `false`

    - #### isMakeParents

          public boolean isMakeParents()

      Gets whether to make parent folders if don't exist.
      Returns:
        `true` if non-existent parent directories should be created, otherwise `false`

    - #### setMakeParents

          public void setMakeParents​(boolean isMakeParents)

      Sets whether to make parent folders if don't exist.
      Parameters:
        `isMakeParents` - `true` if non-existent parent directories should be created, otherwise `false`

    - #### isFailWhenDstExists

          public boolean isFailWhenDstExists()

      Gets whether to fail if `target` already exists.
      Returns:
        `true` if fail when `target` already exists, otherwise `false`
      See Also:
        `SvnRemoteCopy`

    - #### setFailWhenDstExists

          public void setFailWhenDstExists​(boolean isFailWhenDstExist)

      Sets whether to fail if `target` already exists.
      Parameters:
        `isFailWhenDstExist` - `true` if fail when `target` already exists, otherwise `false`
      See Also:
        `SvnRemoteCopy`

    - #### isIgnoreExternals

          public boolean isIgnoreExternals()

      Returns whether to ignore externals definitions.
      Returns:
        `true` if externals definitions should be ignored, otherwise `false`

    - #### setIgnoreExternals

          public void setIgnoreExternals​(boolean ignoreExternals)

      Sets whether to ignore externals definitions.
      Parameters:
        `ignoreExternals` - `true` if externals definitions should be ignored, otherwise `false`

    - #### isVirtual

          public boolean isVirtual()

      Returns whether copy is virtual copy.
      Returns:
        `true` if it is virtual copy, otherwise `false`

    - #### setVirtual

          public void setVirtual​(boolean virtual)

      Sets whether copy is virtual copy.
      Parameters:
        `virtual` - `true` if it is virtual copy, otherwise `false`

    - #### isDisjoint

          public boolean isDisjoint()

      Returns whether copy is disjoint working copy.
      Returns:
        `true` if it is disjoint working copy, otherwise `false`

    - #### setDisjoint

          public void setDisjoint​(boolean disjoint)

      Sets whether copy is disjoint working copy.
      Parameters:
        `disjoint` - `true` if it is disjoint working copy, otherwise `false`

    - #### isChangesWorkingCopy

          public boolean isChangesWorkingCopy()

      Gets whether the operation changes working copy
      Overrides:
        `isChangesWorkingCopy` in class `SvnOperation<java.lang.Void>`
      Returns:
        `true` if the operation changes the working copy, otherwise `false`

    - #### isAllowMixedRevisions

          public boolean isAllowMixedRevisions()

      Gets whether the coping of directories with mixed revisions is allowed
      Returns:
        `true` if coping of directories with mixed revisions is allowed

    - #### setAllowMixedRevisions

          public void setAllowMixedRevisions​(boolean allowMixedRevisions)

      Sets whether the coping of directories with mixed revisions is allowed
      Parameters:
        `allowMixedRevisions` - `true` if coping of directories with mixed revisions is allowed

    - #### isMetadataOnly

          public boolean isMetadataOnly()

    - #### setMetadataOnly

          public void setMetadataOnly​(boolean metadataOnly)

    - #### isPinExternals

          public boolean isPinExternals()

    - #### setPinExternals

          public void setPinExternals​(boolean pinExternals)

    - #### getExternalsToPin

          public java.util.Map<SvnTarget,​java.util.List<org.tmatesoft.svn.core.internal.wc.SVNExternal>> getExternalsToPin()

    - #### setExternalsToPin

          public void setExternalsToPin​(java.util.Map<SvnTarget,​java.util.List<org.tmatesoft.svn.core.internal.wc.SVNExternal>> externalsToPin)