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; }
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; }
public int getMaxLogEntryRevision() { if (isEmpty()) { return -1; } List<LogEntry> logEntries = getOrderedLogEntries(); return logEntries.get(logEntries.size() - 1).getRevision(); }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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); } }
public void addLogEntry(LogEntry logEntry) { logEntries.add(logEntry); isOrdered = false; }