private List<Change> convertPaths(List<Change> changesForPatch) throws VcsException { initAddOption(); final List<Change> changes = new ArrayList<Change>(); for (Change change : changesForPatch) { if (!isUnderOldDir(change, myOldFilePath)) continue; ContentRevision before = null; ContentRevision after = null; if (change.getBeforeRevision() != null) { before = new SimpleContentRevision( change.getBeforeRevision().getContent(), rebasePath(myOldFilePath, myNewFilePath, change.getBeforeRevision().getFile()), change.getBeforeRevision().getRevisionNumber().asString()); } if (change.getAfterRevision() != null) { // if addition or move - do not move to the new path if (myAdd && (change.getBeforeRevision() == null || change.isMoved() || change.isRenamed())) { after = change.getAfterRevision(); } else { after = new SimpleContentRevision( change.getAfterRevision().getContent(), rebasePath(myOldFilePath, myNewFilePath, change.getAfterRevision().getFile()), change.getAfterRevision().getRevisionNumber().asString()); } } changes.add(new Change(before, after)); } return changes; }
private boolean containAdditions(final List<Change> changes) { boolean addFound = false; for (Change change : changes) { if (change.getBeforeRevision() == null || change.isMoved() || change.isRenamed()) { addFound = true; break; } } return addFound; }
private void correctScopeForMoves( final VcsModifiableDirtyScope scope, final Collection<Change> changes) { if (scope == null) return; for (Change change : changes) { if (change.isMoved() || change.isRenamed()) { scope.addDirtyFile(change.getBeforeRevision().getFile()); scope.addDirtyFile(change.getAfterRevision().getFile()); } } }
public void execute() { int ok = Messages.showOkCancelDialog( myVcs.getProject(), (myChange.isMoved() ? SvnBundle.message( "confirmation.resolve.tree.conflict.merge.moved", myOldPresentation, myNewPresentation) : SvnBundle.message( "confirmation.resolve.tree.conflict.merge.renamed", myOldPresentation, myNewPresentation)), TreeConflictRefreshablePanel.TITLE, Messages.getQuestionIcon()); if (Messages.OK != ok) return; FileDocumentManager.getInstance().saveAllDocuments(); // final String name = "Merge changes from theirs for: " + myOldPresentation; final Continuation fragmented = Continuation.createFragmented(myVcs.getProject(), false); fragmented.addExceptionHandler( VcsException.class, new Consumer<VcsException>() { @Override public void consume(VcsException e) { myWarnings.add(e); if (e.isWarning()) { return; } AbstractVcsHelper.getInstance(myVcs.getProject()) .showErrors(myWarnings, TreeConflictRefreshablePanel.TITLE); } }); final List<TaskDescriptor> tasks = new SmartList<TaskDescriptor>(); tasks.add( myDescription.isDirectory() ? new PreloadChangesContentsForDir() : new PreloadChangesContentsForFile()); tasks.add(new ConvertTextPaths()); tasks.add(new PatchCreator()); tasks.add(new SelectPatchesInApplyPatchDialog()); tasks.add(new SelectBinaryFiles()); fragmented.run(tasks); }
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(); } }