package com.link_intersystems.gitdirstat.domain;

import java.io.IOException;
import java.util.Collection;

public class PathDeletionIndexFilter implements IndexFilter {

	private Collection<String> pathsToDelete;

	public PathDeletionIndexFilter(Collection<String> pathsToDelete) {
		this.pathsToDelete = pathsToDelete;
	}

	@Override
	public void apply(CommitUpdate commitUpdate) throws IOException {
		TreeUpdate treeUpdate = commitUpdate.getTreeUpdate();
		while (treeUpdate.hasNext()) {
			TreeFileUpdate fileUpdate = treeUpdate.next();
			String path = fileUpdate.getPath();
			if (pathsToDelete.contains(path)) {
				fileUpdate.delete();
			}
		}
	}
}

@@ -99,16 +99,42 @@
 lection;
+%0Aimport java.util.HashSet;
 %0A%0Apublic
@@ -478,16 +478,100 @@
 date();%0A
+%09%09Collection%3CString%3E actualPathsToDelete = new HashSet%3CString%3E(%0A%09%09%09%09pathsToDelete);%0A
 %09%09while 
@@ -691,17 +691,23 @@
 %0A%09%09%09if (
-p
+actualP
 athsToDe
@@ -715,16 +715,14 @@
 ete.
-contains
+remove
 (pat
@@ -757,16 +757,72 @@
 );%0A%09%09%09%7D%0A
+%09%09%09if (actualPathsToDelete.isEmpty()) %7B%0A%09%09%09%09break;%0A%09%09%09%7D%0A
 %09%09%7D%0A%09%7D%0A%7D

Stop iterating tree if all index filter paths are deleted