Example #1
0
 protected void relocate(List targets) throws SVNException {
   if (targets.size() < 2) {
     SVNErrorManager.error(
         SVNErrorMessage.create(SVNErrorCode.CL_INSUFFICIENT_ARGS), SVNLogType.CLIENT);
   }
   SVNPath from = new SVNPath((String) targets.get(0));
   SVNPath to = new SVNPath((String) targets.get(1));
   if (from.isURL() != to.isURL() || !from.isURL()) {
     SVNErrorMessage err =
         SVNErrorMessage.create(
             SVNErrorCode.INCORRECT_PARAMS,
             "''{0}'' to ''{1}'' is not a valid relocation",
             new Object[] {from.getTarget(), to.getTarget()});
     SVNErrorManager.error(err, SVNLogType.CLIENT);
   }
   SVNUpdateClient client = getSVNEnvironment().getClientManager().getUpdateClient();
   if (targets.size() == 2) {
     SVNPath target = new SVNPath("");
     client.doRelocate(
         target.getFile(),
         from.getURL(),
         to.getURL(),
         getSVNEnvironment().getDepth().isRecursive());
   } else {
     for (int i = 2; i < targets.size(); i++) {
       SVNPath target = new SVNPath((String) targets.get(i));
       client.doRelocate(
           target.getFile(),
           from.getURL(),
           to.getURL(),
           getSVNEnvironment().getDepth().isRecursive());
     }
   }
 }
Example #2
0
  public void run() throws SVNException {
    List targets = getSVNEnvironment().combineTargets(new ArrayList(), true);
    if (getSVNEnvironment().isRelocate()) {
      if (getSVNEnvironment().getDepth() != SVNDepth.UNKNOWN) {
        SVNErrorMessage err =
            SVNErrorMessage.create(
                SVNErrorCode.CL_MUTUALLY_EXCLUSIVE_ARGS,
                "--relocate and --depth are mutually exclusive");
        SVNErrorManager.error(err, SVNLogType.CLIENT);
      }
      relocate(targets);
      return;
    }
    if (targets.isEmpty()) {
      SVNErrorManager.error(
          SVNErrorMessage.create(SVNErrorCode.CL_INSUFFICIENT_ARGS), SVNLogType.CLIENT);
    }
    if (targets.size() > 2) {
      SVNErrorManager.error(
          SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR), SVNLogType.CLIENT);
    }
    SVNPath switchURL = new SVNPath((String) targets.get(0), true);
    if (!switchURL.isURL()) {
      SVNErrorManager.error(
          SVNErrorMessage.create(
              SVNErrorCode.BAD_URL, "''{0}'' doesn not appear to be a URL", switchURL.getTarget()),
          SVNLogType.CLIENT);
    }
    SVNPath target;
    if (targets.size() == 1) {
      target = new SVNPath("");
    } else {
      target = new SVNPath((String) targets.get(1));
    }
    if (!getSVNEnvironment().isVersioned(target.getTarget())) {
      SVNErrorMessage err =
          SVNErrorMessage.create(
              SVNErrorCode.ENTRY_NOT_FOUND,
              "''{0}'' does not appear to be a working copy path",
              target.getTarget());
      SVNErrorManager.error(err, SVNLogType.CLIENT);
    }
    SVNUpdateClient client = getSVNEnvironment().getClientManager().getUpdateClient();
    if (!getSVNEnvironment().isQuiet()) {
      client.setEventHandler(new SVNNotifyPrinter(getSVNEnvironment(), false, false, false));
    }

    SVNDepth depth = getSVNEnvironment().getDepth();
    boolean depthIsSticky = false;
    if (getSVNEnvironment().getSetDepth() != SVNDepth.UNKNOWN) {
      depth = getSVNEnvironment().getSetDepth();
      depthIsSticky = true;
    }

    client.doSwitch(
        target.getFile(),
        switchURL.getURL(),
        switchURL.getPegRevision(),
        getSVNEnvironment().getStartRevision(),
        depth,
        getSVNEnvironment().isForce(),
        depthIsSticky);
  }