public void addChangeToCorrespondingList(final Change change, final VcsKey vcsKey) { final String path = ChangesUtil.getFilePath(change).getPath(); LOG.debug( "[addChangeToCorrespondingList] for change " + path + " type: " + change.getType() + " have before revision: " + (change.getBeforeRevision() != null)); assert myDefault != null; for (LocalChangeList list : myMap.values()) { if (list.isDefault()) { LOG.debug( "[addChangeToCorrespondingList] skip default list: " + list.getName() + " type: " + change.getType() + " have before revision: " + (change.getBeforeRevision() != null)); continue; } if (((LocalChangeListImpl) list).processChange(change)) { LOG.debug( "[addChangeToCorrespondingList] matched: " + list.getName() + " type: " + change.getType() + " have before revision: " + (change.getBeforeRevision() != null)); myIdx.changeAdded(change, vcsKey); return; } } ((LocalChangeListImpl) myDefault).processChange(change); myIdx.changeAdded(change, vcsKey); }
public boolean addChangeToList( @NotNull final String name, final Change change, final VcsKey vcsKey) { LOG.debug( "[addChangeToList] name: " + name + " change: " + ChangesUtil.getFilePath(change).getPath() + " vcs: " + (vcsKey == null ? null : vcsKey.getName())); final LocalChangeList changeList = myMap.get(name); if (changeList != null) { ((LocalChangeListImpl) changeList).addChange(change); myIdx.changeAdded(change, vcsKey); } return changeList != null; }
private void checkForMultipleCopiesNotMove(boolean somethingChanged) { final MultiMap<FilePath, Pair<Change, String>> moves = new MultiMap<FilePath, Pair<Change, String>>() { @NotNull protected Collection<Pair<Change, String>> createCollection() { return new LinkedList<Pair<Change, String>>(); } }; for (LocalChangeList changeList : myMap.values()) { final Collection<Change> changes = changeList.getChanges(); for (Change change : changes) { if (change.isMoved() || change.isRenamed()) { moves.putValue( change.getBeforeRevision().getFile(), Pair.create(change, changeList.getName())); } } } for (FilePath filePath : moves.keySet()) { final List<Pair<Change, String>> copies = (List<Pair<Change, String>>) moves.get(filePath); if (copies.size() == 1) continue; Collections.sort(copies, MyChangesAfterRevisionComparator.getInstance()); for (int i = 0; i < (copies.size() - 1); i++) { somethingChanged = true; final Pair<Change, String> item = copies.get(i); final Change oldChange = item.getFirst(); final Change newChange = new Change(null, oldChange.getAfterRevision()); final LocalChangeListImpl list = (LocalChangeListImpl) myMap.get(item.getSecond()); list.removeChange(oldChange); list.addChange(newChange); final VcsKey key = myIdx.getVcsFor(oldChange); myIdx.changeRemoved(oldChange); myIdx.changeAdded(newChange, key); } } if (somethingChanged) { FileStatusManager.getInstance(myProject).fileStatusesChanged(); } }