What's the purpose of this loop ? 

I suspect it is no longer needed as you map resources to repositories using the new ResourceUtil class called from discardChanges().

If this is correct also method getRepository(IResource resource) can be removed.