@NotNull public ApplyPatchStatus nonWriteActionPreCheck() { final List<FilePatch> failedPreCheck = myVerifier.nonWriteActionPreCheck(); myFailedPatches.addAll(failedPreCheck); myPatches.removeAll(failedPreCheck); final List<FilePatch> skipped = myVerifier.getSkipped(); final boolean applyAll = skipped.isEmpty(); myPatches.removeAll(skipped); if (!failedPreCheck.isEmpty()) return ApplyPatchStatus.FAILURE; return applyAll ? ApplyPatchStatus.SUCCESS : ((skipped.size() == myPatches.size()) ? ApplyPatchStatus.ALREADY_APPLIED : ApplyPatchStatus.PARTIAL); }
private List<CommittedChangeList> loadSvnChangeListsForPatch(TreeConflictDescription description) throws VcsException { long max = description.getSourceRightVersion().getPegRevision(); long min = description.getSourceLeftVersion().getPegRevision(); final ChangeBrowserSettings settings = new ChangeBrowserSettings(); settings.USE_CHANGE_BEFORE_FILTER = settings.USE_CHANGE_AFTER_FILTER = true; settings.CHANGE_BEFORE = "" + max; settings.CHANGE_AFTER = "" + min; final List<SvnChangeList> committedChanges = myVcs .getCachingCommittedChangesProvider() .getCommittedChanges( settings, new SvnRepositoryLocation( description.getSourceRightVersion().getRepositoryRoot().toString()), 0); final List<CommittedChangeList> lst = new ArrayList<CommittedChangeList>(committedChanges.size() - 1); for (SvnChangeList change : committedChanges) { if (change.getNumber() == min) { continue; } lst.add(change); } return lst; }
private Collection<VirtualFile> promptAboutAddition( SvnVcs vcs, List<VirtualFile> addedVFiles, VcsShowConfirmationOption.Value value, AbstractVcsHelper vcsHelper) { Collection<VirtualFile> filesToProcess; if (value == VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY) { filesToProcess = addedVFiles; } else { final String singleFilePrompt; if (addedVFiles.size() == 1 && addedVFiles.get(0).isDirectory()) { singleFilePrompt = SvnBundle.getString("confirmation.text.add.dir"); } else { singleFilePrompt = SvnBundle.getString("confirmation.text.add.file"); } filesToProcess = vcsHelper.selectFilesToProcess( addedVFiles, SvnBundle.message("confirmation.title.add.multiple.files"), null, SvnBundle.message("confirmation.title.add.file"), singleFilePrompt, vcs.getAddConfirmation()); } return filesToProcess; }
@Nullable private static Change[] loadFakeRevisions(final Project project, final Change[] changes) { List<Change> matchingChanges = new ArrayList<Change>(); for (Change change : changes) { matchingChanges.addAll( ChangeListManager.getInstance(project).getChangesIn(ChangesUtil.getFilePath(change))); } return matchingChanges.toArray(new Change[matchingChanges.size()]); }
@Override public <S> List<S> filterUniqueRoots( final List<S> in, final Convertor<S, VirtualFile> convertor) { if (in.size() <= 1) return in; final List<MyPair<S>> infos = new ArrayList<MyPair<S>>(in.size()); final SvnFileUrlMappingImpl mapping = (SvnFileUrlMappingImpl) getSvnFileUrlMapping(); final List<S> notMatched = new LinkedList<S>(); for (S s : in) { final VirtualFile vf = convertor.convert(s); if (vf == null) continue; final File ioFile = new File(vf.getPath()); SVNURL url = mapping.getUrlForFile(ioFile); if (url == null) { url = SvnUtil.getUrl(this, ioFile); if (url == null) { notMatched.add(s); continue; } } infos.add(new MyPair<S>(vf, url.toString(), s)); } final List<MyPair<S>> filtered = new ArrayList<MyPair<S>>(infos.size()); ForNestedRootChecker.filterOutSuperfluousChildren(this, infos, filtered); final List<S> converted = ObjectsConvertor.convert( filtered, new Convertor<MyPair<S>, S>() { @Override public S convert(final MyPair<S> o) { return o.getSrc(); } }); if (!notMatched.isEmpty()) { // potential bug is here: order is not kept. but seems it only occurs for cases where result // is sorted after filtering so ok converted.addAll(notMatched); } return converted; }
@Override public void consume(Collection<FilePath> directlyAffected) { List<Change> changes = new ArrayList<>(); for (FilePath file : directlyAffected) { final Change change = myChangeListManager.getChange(file); if (change != null) { changes.add(change); } } myChangeListManager.moveChangesTo( myTargetChangeList, changes.toArray(new Change[changes.size()])); }