Example #1
0
  /**
   * 将日志写入文件
   *
   * @param logs
   * @param destFile
   */
  private static void writeLogToFile(Collection<SVNLog> logs, File destFile) throws Exception {
    if (logs == null || logs.isEmpty()) {
      return;
    }
    if (!destFile.exists()) {
      destFile.createNewFile();
    }
    List<String> contents = new LinkedList<String>();
    for (SVNLog e : logs) {
      contents.add(e.toSimpleString());
    }

    FileUtils.writeLines(destFile, contents, false);
  }
Example #2
0
  /**
   * 根据日志获取现在"添加、修改"的项目
   *
   * @param repository
   * @param remoteRoot
   * @param logs
   * @param savePath
   * @throws Exception
   */
  private static void getDelta4Add(
      SVNRepository repository, String remoteRoot, Collection<SVNLog> logs, String savePath)
      throws Exception {
    SVNNodeKind nodeKind = null;
    if (logs == null || logs.isEmpty()) {
      return;
    }

    File localRoot = new File(savePath);

    // 清空或创建目录
    if (localRoot.exists()) {
      FileUtils.cleanDirectory(localRoot);
    } else {
      localRoot.mkdirs();
    }

    String remotePath = null;
    String localPath = null;
    File localEntry = null;
    for (SVNLog l : logs) {
      if (l.getType() == SVNLog.TYPE_DEL) {
        continue;
      }
      remotePath = remoteRoot + l.getPath();
      localPath = savePath + l.getPath();
      nodeKind = repository.checkPath(remotePath, l.getRevision());
      if (nodeKind == SVNNodeKind.DIR) {
        localEntry = new File(localPath);
        if (!localEntry.exists()) {
          localEntry.mkdirs();
        }
      }

      if (nodeKind == SVNNodeKind.FILE) {
        localEntry = new File(localPath);
        getFile(repository, remotePath, localEntry, l.getRevision());
      }
    }
  }