Exemple #1
0
  public void removeEntriesWithPathForAuthor(String path, String author) {
    if (logEntries == null || logEntries.isEmpty()) {
      return;
    }

    int count = logEntries.size();
    int i = 0;

    while (i < count) {
      LogEntry logEntry = logEntries.get(i);
      if (!logEntry.getAuthor().equals(author)) {
        i++;
        continue;
      }

      logEntry.removeEntriesWithPath(path);
      if (logEntry.isEmpty()) {
        logEntries.remove(logEntry);
        count--;
        continue;
      }

      i++;
    }

    isOrdered = false;
  }
Exemple #2
0
  public void removeNotLastModifications() {
    List<String> uniquePaths = getUniquePaths();
    for (String path : uniquePaths) {
      int lastRevision = getLastModificationRevisionForPath(path);

      int count = logEntries.size();
      int i = 0;

      while (i < count) {
        LogEntry entry = logEntries.get(i);

        if (entry.getRevision() < lastRevision) {
          entry.removeEntriesWithPath(path);
          if (entry.isEmpty()) {
            logEntries.remove(entry);
            count--;
            i--;
          }
        }

        i++;
      }
    }

    isOrdered = false;
  }
Exemple #3
0
  public int getMaxLogEntryRevision() {
    if (isEmpty()) {
      return -1;
    }

    List<LogEntry> logEntries = getOrderedLogEntries();

    return logEntries.get(logEntries.size() - 1).getRevision();
  }
Exemple #4
0
  private List<LogEntry> getUnorderedAuthorLogEntries(String author) {
    List<LogEntry> entries = new LinkedList<LogEntry>();

    for (LogEntry logEntry : logEntries) {
      if (logEntry.getAuthor().equals(author)) {
        entries.add(logEntry);
      }
    }

    return entries;
  }
Exemple #5
0
  public List<String> getAuthors() {
    List<String> authors = new LinkedList<String>();

    for (LogEntry logEntry : logEntries) {
      if (!authors.contains(logEntry.getAuthor())) {
        authors.add(logEntry.getAuthor());
      }
    }

    Collections.sort(authors);

    return authors;
  }
Exemple #6
0
  public List<String> getUniquePaths() {
    List<String> uniquePathEntries = new LinkedList<String>();

    for (LogEntry logEntry : logEntries) {
      List<PathEntry> pathEntries = logEntry.getPathEntries();
      for (PathEntry pathEntry : pathEntries) {
        if (!uniquePathEntries.contains(pathEntry.getPath())) {
          uniquePathEntries.add(pathEntry.getPath());
        }
      }
    }

    return uniquePathEntries;
  }
Exemple #7
0
  public List<PathEntry> getOrderedByRevisionAuthorPathEntries(String author) {
    List<PathEntry> orderedPathEntries = new LinkedList<PathEntry>();

    List<LogEntry> logEntries = getUnorderedAuthorLogEntries(author);
    for (LogEntry logEntry : logEntries) {
      List<PathEntry> pathEntries = logEntry.getPathEntries();
      for (PathEntry pathEntry : pathEntries) {
        orderedPathEntries.add(pathEntry);
      }
    }

    Collections.sort(orderedPathEntries);

    return orderedPathEntries;
  }
Exemple #8
0
  public List<String> getAuthorUniquePaths(String author) {
    List<LogEntry> logEntries = getUnorderedAuthorLogEntries(author);
    List<String> uniquePathEntries = new LinkedList<String>();

    for (LogEntry logEntry : logEntries) {
      List<PathEntry> pathEntries = logEntry.getPathEntries();
      for (PathEntry pathEntry : pathEntries) {
        if (!uniquePathEntries.contains(pathEntry.getPath())) {
          uniquePathEntries.add(pathEntry.getPath());
        }
      }
    }

    return uniquePathEntries;
  }
Exemple #9
0
  public void removeLogEntriesWithRevisionLowerThan(int revision) {
    List<LogEntry> logEntries = getOrderedLogEntries();
    if (logEntries.isEmpty()) {
      return;
    }

    int count = this.logEntries.size();
    int i = 0;

    while (i < count) {
      LogEntry entry = this.logEntries.get(i);
      if (entry.getRevision() < revision) {
        this.logEntries.remove(entry);
        count--;
        continue;
      }

      i++;
    }

    isOrdered = false;
  }
Exemple #10
0
  public void removeEntriesWithPath(String path) {
    if (logEntries == null || logEntries.isEmpty()) {
      return;
    }

    int count = logEntries.size();
    int i = 0;

    while (i < count) {
      LogEntry logEntry = logEntries.get(i);
      logEntry.removeEntriesWithPath(path);

      if (logEntry.isEmpty()) {
        logEntries.remove(logEntry);
        count--;
        continue;
      }

      i++;
    }

    isOrdered = false;
  }
Exemple #11
0
  private void writeChanges(PrintWriter out) {
    List<String> authors = getAuthors();
    for (String author : authors) {
      List<LogEntry> logEntries = getOrderedAuthorLogEntries(author);
      if (logEntries == null || logEntries.isEmpty()) {
        continue;
      }

      out.println(
          MessageFormat.format(
              AUTHOR_START_NODE,
              new String[] {
                author,
                Integer.toString(getAuthorLogEntriesCount(author)),
                Integer.toString(logEntries.size())
              }));

      for (LogEntry logEntry : logEntries) {
        writeLogEntry(out, logEntry);
      }

      out.println(AUTHOR_END_NODE);
    }
  }
Exemple #12
0
 public void addLogEntry(LogEntry logEntry) {
   logEntries.add(logEntry);
   isOrdered = false;
 }