private static List<TextFilePatch> loadTextPatches( final Project project, final ShelvedChangeList changeList, final List<ShelvedChange> changes, final List<FilePatch> remainingPatches, final CommitContext commitContext) throws IOException, PatchSyntaxException { final List<TextFilePatch> textFilePatches; textFilePatches = loadPatches(project, changeList.PATH, commitContext); if (changes != null) { final Iterator<TextFilePatch> iterator = textFilePatches.iterator(); while (iterator.hasNext()) { TextFilePatch patch = iterator.next(); if (!needUnshelve(patch, changes)) { remainingPatches.add(patch); iterator.remove(); } } } return textFilePatches; }
private void recycleChangeList( final ShelvedChangeList listCopy, final ShelvedChangeList newList) { if (newList != null) { for (Iterator<ShelvedBinaryFile> shelvedChangeListIterator = listCopy.getBinaryFiles().iterator(); shelvedChangeListIterator.hasNext(); ) { final ShelvedBinaryFile binaryFile = shelvedChangeListIterator.next(); for (ShelvedBinaryFile newBinary : newList.getBinaryFiles()) { if (Comparing.equal(newBinary.BEFORE_PATH, binaryFile.BEFORE_PATH) && Comparing.equal(newBinary.AFTER_PATH, binaryFile.AFTER_PATH)) { shelvedChangeListIterator.remove(); } } } for (Iterator<ShelvedChange> iterator = listCopy.getChanges(myProject).iterator(); iterator.hasNext(); ) { final ShelvedChange change = iterator.next(); for (ShelvedChange newChange : newList.getChanges(myProject)) { if (Comparing.equal(change.getBeforePath(), newChange.getBeforePath()) && Comparing.equal(change.getAfterPath(), newChange.getAfterPath())) { iterator.remove(); } } } // needed only if partial unshelve try { final CommitContext commitContext = new CommitContext(); final List<FilePatch> patches = new ArrayList<FilePatch>(); for (ShelvedChange change : listCopy.getChanges(myProject)) { patches.add(change.loadFilePatch(myProject, commitContext)); } writePatchesToFile(myProject, listCopy.PATH, patches, commitContext); } catch (IOException e) { LOG.info(e); // left file as is } catch (PatchSyntaxException e) { LOG.info(e); // left file as is } } if ((!listCopy.getBinaryFiles().isEmpty()) || (!listCopy.getChanges(myProject).isEmpty())) { listCopy.setRecycled(true); myRecycledShelvedChangeLists.add(listCopy); notifyStateChanged(); } }