예제 #1
0
 /**
  * Creates a new Client that will handle CVS operations.
  *
  * @return a Client instance
  */
 private Client createClient() {
   Connection connection = setupConnection(CVSRoot.parse(cvsRoot));
   Client client = new Client(connection, CvsVersioningSystem.getInstance().getAdminHandler());
   client.setUncompressedFileHandler(CvsVersioningSystem.getInstance().getFileHandler());
   client.setGzipFileHandler(CvsVersioningSystem.getInstance().getGzippedFileHandler());
   return client;
 }
예제 #2
0
  private void setLocalDirectory(Client client, File[] files) throws IllegalCommandException {
    if (files.length == 0) {
      return;
    }

    File commonParent;

    if (files[0].isDirectory()) { // XXX it does not work for checkout
      commonParent = files[0];
    } else {
      commonParent = files[0].getParentFile();
    }

    for (int i = 1; i < files.length; i++) {
      if (!Utils.isParentOrEqual(commonParent, files[i])) {
        for (; ; ) {
          commonParent = commonParent.getParentFile();
          if (commonParent == null)
            throw new IllegalCommandException("Files do not have common parent!"); // NOI18N
          if (Utils.isParentOrEqual(commonParent, files[i])) {
            break;
          }
        }
      }
    }

    // we must not run commands from within folders that are not yet in CVS, try to find the closest
    // uptodate parent
    FileStatusCache cache = CvsVersioningSystem.getInstance().getStatusCache();
    for (File versionedCommonParent = commonParent;
        versionedCommonParent != null;
        versionedCommonParent = versionedCommonParent.getParentFile()) {
      FileInformation info = cache.getStatus(versionedCommonParent);
      if (info.getStatus() == FileInformation.STATUS_VERSIONED_UPTODATE) {
        commonParent = versionedCommonParent;
        break;
      }
    }
    client.setLocalPath(commonParent.getAbsolutePath());
  }