/** * Removes duplicate entries, e.g. those coming form svn:externals. * * @param items list of items * @return filtered list without duplicated entries */ static List<LogEntry> removeDuplicatedEntries(List<LogEntry> items) { Set<LogEntry> entries = new HashSet<LogEntry>(items); for (LogEntry sourceEntry : items) { // LogEntry equality does not consider paths, but some might have localPath attributes // that would get lost by HashSet duplicate removal for (LogEntry destinationEntry : entries) { if (sourceEntry.equals(destinationEntry)) { // get all local paths and set in destination for (Path sourcePath : sourceEntry.getPaths()) { if (sourcePath.localPath != null) { for (Path destinationPath : destinationEntry.getPaths()) { if (sourcePath.value.equals(destinationPath.value)) { destinationPath.localPath = sourcePath.localPath; } } } } } } } return new ArrayList<LogEntry>(entries); }
@Test public void testRemoveIgnoredDirPropChangesNotRemoving() throws Exception { addPathToEntry("A", "file", "a"); addPathToEntry("A", "dir", "b"); addPathToEntry("D", "file", "c"); addPathToEntry("D", "dir", "d"); addPathToEntry("M", "file", "e"); int oldSize = entry.getPaths().size(); entry.removePropertyOnlyPaths(); assertThat(entry.getPaths().size(), is(oldSize)); }
@Test public void testRemoveIgnoredDirPropChanges() throws Exception { addPathToEntry("A", "file", "filetokeep"); addPathToEntry("M", "dir", "dirtodelete"); addPathToEntry("M", "dir", "anotherdirtodelete"); entry.removePropertyOnlyPaths(); assertThat(entry.getPaths().size(), is(1)); }
private void thenValuesMustStartWithSlash() { for(LogEntry entry : changeLogSet.getLogs()) { for(Path path : entry.getPaths()) { Assert.assertTrue(path.getValue().startsWith("/")); } } }
private void thenPathsMustBeEqualToValues() { for(LogEntry entry : changeLogSet.getLogs()) { for(Path path : entry.getPaths()) { Assert.assertEquals(path.getPath(), path.getValue()); } } }
private void thenAffectedPathsMustBeSortedAlphabetically() { for(LogEntry entry : changeLogSet.getLogs()) { String previous = ""; for(Path path : entry.getPaths()) { Assert.assertTrue(previous.compareTo(path.getPath()) <= 0); previous = path.getPath(); } } }
private void andPathsMustNotStartWithSlash() { for(LogEntry entry : changeLogSet.getLogs()) { for(Path path : entry.getPaths()) { Assert.assertFalse(path.getPath().startsWith("/")); } } } }