Beispiel #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());
     }
   }
 }
Beispiel #2
0
  public void run() throws SVNException {
    List targets = getSVNEnvironment().combineTargets(null, true);
    if (targets.size() < 2) {
      SVNErrorManager.error(
          SVNErrorMessage.create(SVNErrorCode.CL_INSUFFICIENT_ARGS), SVNLogType.CLIENT);
    }
    SVNPath dst = new SVNPath((String) targets.remove(targets.size() - 1));
    if (!dst.isURL()) {
      if (getSVNEnvironment().getMessage() != null
          || getSVNEnvironment().getFileData() != null
          || getSVNEnvironment().getRevisionProperties() != null) {
        SVNErrorManager.error(
            SVNErrorMessage.create(
                SVNErrorCode.CL_UNNECESSARY_LOG_MESSAGE,
                "Local, non-commit operations do not take a log message or revision properties"),
            SVNLogType.CLIENT);
      }
    }

    Collection sources = new ArrayList();
    boolean sourceIsURL = false;
    for (int i = 0; i < targets.size(); i++) {
      String targetName = (String) targets.get(i);
      SVNPath source = new SVNPath(targetName, true);
      if (i == 0) {
        sourceIsURL = source.isURL();
      }
      if (source.isURL()) {
        sources.add(
            new SVNCopySource(
                source.getPegRevision(), getSVNEnvironment().getStartRevision(), source.getURL()));
      } else {
        sources.add(
            new SVNCopySource(
                source.getPegRevision(), getSVNEnvironment().getStartRevision(), source.getFile()));
      }
    }

    SVNCopyClient client = getSVNEnvironment().getClientManager().getCopyClient();
    if (!sourceIsURL && !dst.isURL()) {
      if (!getSVNEnvironment().isQuiet()) {
        client.setEventHandler(new SVNNotifyPrinter(getSVNEnvironment()));
      }
    } else if (!sourceIsURL && dst.isURL()) {
      // skip
    } else if (sourceIsURL && !dst.isURL()) {
      if (!getSVNEnvironment().isQuiet()) {
        client.setEventHandler(new SVNNotifyPrinter(getSVNEnvironment(), true, false, false));
      }
    }
    client.setCommitHandler(getSVNEnvironment());
    SVNCopySource[] copySources =
        (SVNCopySource[]) sources.toArray(new SVNCopySource[sources.size()]);
    if (dst.isURL()) {
      SVNCommitInfo info =
          client.doCopy(
              copySources,
              dst.getURL(),
              false,
              getSVNEnvironment().isParents(),
              false,
              getSVNEnvironment().getMessage(),
              getSVNEnvironment().getRevisionProperties());

      if (!getSVNEnvironment().isQuiet()) {
        getSVNEnvironment().printCommitInfo(info);
      }
    } else {
      client.doCopy(copySources, dst.getFile(), false, getSVNEnvironment().isParents(), false);
    }
  }
Beispiel #3
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);
  }
  public void run() throws SVNException {
    List targets = getSVNEnvironment().combineTargets(new ArrayList(), true);
    if (targets.isEmpty()) {
      SVNErrorManager.error(
          SVNErrorMessage.create(SVNErrorCode.CL_INSUFFICIENT_ARGS), SVNLogType.CLIENT);
    }
    String lastTarget = (String) targets.get(targets.size() - 1);
    if (SVNCommandUtil.isURL(lastTarget)) {
      if (targets.size() == 1) {
        SVNPath target = new SVNPath(lastTarget, true);
        lastTarget = target.getURL().getPath();
        lastTarget = SVNPathUtil.tail(lastTarget);
      } else {
        lastTarget = "";
      }
      targets.add(lastTarget);
    } else if (targets.size() == 1) {
      SVNErrorManager.error(
          SVNErrorMessage.create(SVNErrorCode.CL_INSUFFICIENT_ARGS), SVNLogType.CLIENT);
    }
    SVNUpdateClient client = getSVNEnvironment().getClientManager().getUpdateClient();
    if (!getSVNEnvironment().isQuiet()) {
      client.setEventHandler(new SVNNotifyPrinter(getSVNEnvironment(), true, false, false));
    }

    SVNRevision revision = getSVNEnvironment().getStartRevision();
    for (int i = 0; i < targets.size() - 1; i++) {
      String targetName = (String) targets.get(i);
      SVNPath target = new SVNPath(targetName, true);
      if (!target.isURL()) {
        SVNErrorManager.error(
            SVNErrorMessage.create(
                SVNErrorCode.BAD_URL, "''{0}'' doesn not appear to be a URL", targetName),
            SVNLogType.CLIENT);
      }
      String targetDir;
      SVNPath dstTarget;
      if (targets.size() == 2) {
        // url + path
        targetDir = lastTarget;
        dstTarget = new SVNPath(targetDir);
      } else {
        // all urls + base dst.
        targetDir = target.getURL().getPath();
        targetDir = SVNPathUtil.tail(targetDir);
        targetDir = SVNPathUtil.append(lastTarget, targetDir);
        dstTarget = new SVNPath(targetDir);
      }
      SVNRevision pegRevision = target.getPegRevision();
      if (revision == SVNRevision.UNDEFINED) {
        revision = pegRevision != SVNRevision.UNDEFINED ? pegRevision : SVNRevision.HEAD;
      }
      client.doCheckout(
          target.getURL(),
          dstTarget.getFile(),
          pegRevision,
          revision,
          getSVNEnvironment().getDepth(),
          getSVNEnvironment().isForce());
    }
  }