* @param features the features to delete
*/
public void delete(Iterator<String> features) {
Map<String, RevTreeBuilder> parents = Maps.newHashMap();
final RevTree currentWorkHead = getTree();
while (features.hasNext()) {
String featurePath = features.next();
// System.err.println("removing " + feature);
String parentPath = NodeRef.parentPath(featurePath);
RevTreeBuilder parentTree;
if (parents.containsKey(parentPath)) {
parentTree = parents.get(parentPath);
} else {
parentTree = context.command(FindOrCreateSubtree.class).setIndex(true)
.setParent(Suppliers.ofInstance(Optional.of(currentWorkHead)))
.setChildPath(parentPath).call().builder(indexDatabase);
parents.put(parentPath, parentTree);
}
String featureName = NodeRef.nodeFromPath(featurePath);
parentTree.remove(featureName);
}
ObjectId newTree = null;
for (Map.Entry<String, RevTreeBuilder> entry : parents.entrySet()) {
String path = entry.getKey();
RevTreeBuilder parentTree = entry.getValue();
RevTree newTypeTree = parentTree.build();
ObjectId metadataId = null;
Optional<NodeRef> currentTreeRef = context.command(FindTreeChild.class).setIndex(true)
.setParent(currentWorkHead).setChildPath(path).call();
if (currentTreeRef.isPresent()) {