void () { myListsHolder = new ChangesListCreationHelper(); // key: copied-from final Map<String, ExternallyRenamedChange> copiedAddedChanges = new HashMap<>(); correctBeforePaths(); final List<String> copyDeleted = new ArrayList<>(myDeletedPaths); for(String path: myAddedPaths) { final Change addedChange; if (myCopiedAddedPaths.containsKey(path)) { final String copyTarget = myCopiedAddedPaths.get(path); if (copyDeleted.contains(copyTarget)) { addedChange = new ExternallyRenamedChange(myListsHolder.createRevisionLazily(copyTarget, true), myListsHolder.createRevisionLazily(path, false), copyTarget); addedChange.getMoveRelativePath(myVcs.getProject()); ((ExternallyRenamedChange) addedChange).setCopied(false); copyDeleted.remove(copyTarget); } else { addedChange = new ExternallyRenamedChange(null, myListsHolder.createRevisionLazily(path, false), copyTarget); } copiedAddedChanges.put(copyTarget, (ExternallyRenamedChange) addedChange); } else { addedChange = new Change(null, myListsHolder.createRevisionLazily(path, false)); } myListsHolder.add(path, addedChange); } for(String path: copyDeleted) { final Change deletedChange; if (copiedAddedChanges.containsKey(path)) { // seems never occurs any more final ExternallyRenamedChange addedChange = copiedAddedChanges.get(path); final FilePath source = addedChange.getAfterRevision().getFile(); deletedChange = new ExternallyRenamedChange(myListsHolder.createDeletedItemRevision(path, true), null, path); ((ExternallyRenamedChange) deletedChange).setCopied(false); //addedChange.setRenamedOrMovedTarget(deletedChange.getBeforeRevision().getFile()); ((ExternallyRenamedChange) deletedChange).setRenamedOrMovedTarget(source); } else { deletedChange = new Change(myListsHolder.createDeletedItemRevision(path, true), null); } myListsHolder.add(path, deletedChange); } for(String path: myChangedPaths) { boolean moveAndChange = false; final boolean replaced = myReplacedPaths.contains(path); // this piece: for copied-from (or moved) and further modified for (String addedPath : myAddedPaths) { String copyFromPath = myCopiedAddedPaths.get(addedPath); if ((copyFromPath != null) && (Url.isAncestor(addedPath, path))) { if (addedPath.length() < path.length()) { String relative = Url.getRelative(addedPath, path); copyFromPath = Url.append(copyFromPath, relative); } final ExternallyRenamedChange renamedChange = new ExternallyRenamedChange(myListsHolder.createRevisionLazily(copyFromPath, true), myListsHolder.createRevisionLazily(path, false), copyFromPath); moveAndChange = true; renamedChange.getMoveRelativePath(myVcs.getProject()); renamedChange.setIsReplaced(replaced); final ExternallyRenamedChange addedChange = copiedAddedChanges.get(myCopiedAddedPaths.get(addedPath)); renamedChange.setCopied(addedChange != null && addedChange.isCopied()); myListsHolder.add(path, renamedChange); break; } } if (! moveAndChange) { final ExternallyRenamedChange renamedChange = new ExternallyRenamedChange(myListsHolder.createRevisionLazily(path, true), myListsHolder.createRevisionLazily(path, false), null); renamedChange.setIsReplaced(replaced); renamedChange.setCopied(false); myListsHolder.add(path, renamedChange); } } }