org.tmatesoft.svn.core.wc2

## Class SvnSwitch

- java.lang.Object
- - org.tmatesoft.svn.core.wc2.SvnOperation<V>
  - - org.tmatesoft.svn.core.wc2.AbstractSvnUpdate<java.lang.Long>
    - - org.tmatesoft.svn.core.wc2.SvnSwitch

- All Implemented Interfaces:
    ISvnOperationOptionsProvider

      public class SvnSwitch
      extends AbstractSvnUpdate<java.lang.Long>

  Represents switch operation. Switches working tree of `target` to `switchTarget`\ `switchTarget`'s `pegRevision` at `revision`.

  Summary of purpose: this is normally used to switch a working directory over to another line of development, such as a branch or a tag. Switching an existing working directory is more efficient than checking out `switchTarget` from scratch.

  If `depth` is `SVNDepth.INFINITY`, switches fully recursively. Else if it is `SVNDepth.IMMEDIATES`, switches `target` and its file children (if any), and switches subdirectories but does not update them. Else if `SVNDepth.FILES`, switches just file children, ignoring subdirectories completely. Else if `SVNDepth.EMPTY`, switches just `target` and touches nothing underneath it.

  If externals are ignored (`ignoreExternals` is `true`), doesn't process externals definitions as part of this operation.

  If `allowUnversionedObstructions` is `true` then the switch tolerates existing unversioned items that obstruct added paths. Only obstructions of the same type (file or directory) as the added item are tolerated. The text of obstructing files is left as-is, effectively treating it as a user modification after the switch. Working properties of obstructing items are set equal to the base properties. If `allowUnversionedObstructions` is `false` then the switch will abort if there are any unversioned obstructing items.

  If the caller's `ISVNEventHandler` is non-`null`, it is invoked for paths affected by the switch, and also for files restored from text-base. Also `ISVNCanceller.checkCancelled()` will be used at various places during the switch to check whether the caller wants to stop the switch.

  This operation requires repository access (in case the repository is not on the same machine, network connection is established).

  `SvnOperation.run()` method returns value of the revision value to which the working copy was actually switched.

  `SvnOperation.run()` method returns value of the revision to which the working copy was actually switched.
  exception with `SVNErrorCode.UNSUPPORTED_FEATURE` error code - if `target` is not in the repository yet
  exception with `SVNErrorCode.ENTRY_MISSING_URL` error code - if `switchTarget` directory has no URL
  exception with `SVNErrorCode.WC_INVALID_SWITCH` error code - if `switchTarget` is not the same repository as `target`'s repository
  exception with `SVNErrorCode.CLIENT_UNRELATED_RESOURCES` error code - if `ignoreAncestry` is `false` and `switchTarget` shares no common ancestry with `target`
  Version:
    1.7
  Author:
    TMate Software Ltd.

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `SvnSwitch(SvnOperationFactory factory)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `ensureArgumentsAreValid()`
    `SvnTarget` | `getSwitchTarget()` Returns the repository location as a target against which the item will be switched.
    `boolean` | `isChangesWorkingCopy()` Gets whether the operation changes working copy
    `boolean` | `isDepthIsSticky()` Returns whether depth is sticky.
    `boolean` | `isIgnoreAncestry()` Returns whether to ignore ancestry when calculating merges.
    `void` | `setDepthIsSticky(boolean depthIsSticky)` Sets whether depth is sticky.
    `void` | `setIgnoreAncestry(boolean ignoreAncestry)` Sets whether to ignore ancestry when calculating merges.
    `void` | `setSwitchTarget(SvnTarget switchTarget)` Sets the repository location as a target against which the item will be switched.

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

      `getExternalsHandler, isAllowUnversionedObstructions, isIgnoreExternals, isUpdateLocksOnDemand, setAllowUnversionedObstructions, setExternalsHandler, setIgnoreExternals, setUpdateLocksOnDemand`

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

      `addTarget, cancel, 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

    - #### SvnSwitch

          protected SvnSwitch(SvnOperationFactory factory)

  - ### Method Detail

    - #### isDepthIsSticky

          public boolean isDepthIsSticky()

      Returns whether depth is sticky. If `depthIsSticky` is set the operation will use `depth` as status scope, otherwise `SVNDepth.UNKNOWN` will be used.
      Returns:
        `true` if the depth is sticky, otherwise `false`

    - #### isIgnoreAncestry

          public boolean isIgnoreAncestry()

      Returns whether to ignore ancestry when calculating merges.
      Returns:
        `true` if ancestry should be ignored, otherwise `false`
      Since:
        1.7, Subversion 1.7

    - #### getSwitchTarget

          public SvnTarget getSwitchTarget()

      Returns the repository location as a target against which the item will be switched.
      Returns:
        switch target

    - #### setDepthIsSticky

          public void setDepthIsSticky(boolean depthIsSticky)

      Sets whether depth is sticky. If `depthIsSticky` is set the operation will use `depth` as status scope, otherwise `SVNDepth.UNKNOWN` will be used.
      Parameters:
        `depthIsSticky` - `true` if the depth is sticky, otherwise `false`

    - #### setIgnoreAncestry

          public void setIgnoreAncestry(boolean ignoreAncestry)

      Sets whether to ignore ancestry when calculating merges.
      Parameters:
        `ignoreAncestry` - `true` if ancestry should be ignored, otherwise `false`
      Since:
        1.7, Subversion 1.7

    - #### setSwitchTarget

          public void setSwitchTarget(SvnTarget switchTarget)

      Sets the repository location as a target against which the item will be switched.
      Parameters:
        `switchTarget` - switch target

    - #### ensureArgumentsAreValid

          protected void ensureArgumentsAreValid()
                                          throws SVNException

      Overrides:
        `ensureArgumentsAreValid` in class `SvnOperation<java.lang.Long>`
      Throws:
        `SVNException`

    - #### isChangesWorkingCopy

          public boolean isChangesWorkingCopy()

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