@Override
    public void apply(
        @NotNull MultiMap<VirtualFile, TextFilePatchInProgress> patchGroups,
        @Nullable LocalChangeList localList,
        @Nullable String fileName,
        @Nullable
            TransparentlyFailedValueI<Map<String, Map<String, CharSequence>>, PatchSyntaxException>
                additionalInfo) {
      final List<FilePatch> patches;
      try {
        patches = ApplyPatchSaveToFileExecutor.patchGroupsToOneGroup(patchGroups, myBaseDir);
      } catch (IOException e) {
        myInner.handleException(e, true);
        return;
      }

      final PatchApplier<BinaryFilePatch> patchApplier =
          new PatchApplier<BinaryFilePatch>(
              myVcs.getProject(), myBaseDir, patches, localList, null, null);
      patchApplier.execute(false, true); // 3
      boolean thereAreCreations = false;
      for (FilePatch patch : patches) {
        if (patch.isNewFile() || !Comparing.equal(patch.getAfterName(), patch.getBeforeName())) {
          thereAreCreations = true;
          break;
        }
      }
      if (thereAreCreations) {
        // restore deletion of old directory:
        myInner.next(new DirectoryAddition()); // 2
      }
      appendResolveConflictToContext(myInner); // 1
      appendTailToContextLast(myInner); // 4
      myInner.ping();
    }
 public void applyBackToPatch(final FilePatch patch) {
   final String beforeName = patch.getBeforeName();
   if (beforeName != null) {
     patch.setBeforeName(myParts[myBeforeIdx].getCurrentPath());
   }
   final String afterName = patch.getAfterName();
   if (afterName != null) {
     patch.setAfterName(myParts[myAfterIdx].getCurrentPath());
   }
 }
 private static boolean needUnshelve(final FilePatch patch, final List<ShelvedChange> changes) {
   for (ShelvedChange change : changes) {
     if (Comparing.equal(patch.getBeforeName(), change.getBeforePath())) {
       return true;
     }
   }
   return false;
 }
Пример #4
0
 public List<ShelvedChange> getChanges(Project project) {
   if (myChanges == null) {
     try {
       myChanges = new ArrayList<ShelvedChange>();
       final List<? extends FilePatch> list =
           ShelveChangesManager.loadPatchesWithoutContent(project, PATH, null);
       for (FilePatch patch : list) {
         FileStatus status;
         if (patch.isNewFile()) {
           status = FileStatus.ADDED;
         } else if (patch.isDeletedFile()) {
           status = FileStatus.DELETED;
         } else {
           status = FileStatus.MODIFIED;
         }
         myChanges.add(
             new ShelvedChange(PATH, patch.getBeforeName(), patch.getAfterName(), status));
       }
     } catch (Exception e) {
       LOG.error("Failed to parse the file patch: [" + PATH + "]", e);
     }
   }
   return myChanges;
 }
    private PatchStrippable(final FilePatch patch) {
      final boolean onePath =
          patch.isDeletedFile()
              || patch.isNewFile()
              || Comparing.equal(patch.getAfterName(), patch.getBeforeName());
      final int size = onePath ? 1 : 2;
      myParts = new Strippable[size];

      int cnt = 0;
      if (patch.getAfterName() != null) {
        myAfterIdx = 0;
        myParts[cnt] = new StripCapablePath(patch.getAfterName());
        ++cnt;
      } else {
        myAfterIdx = -1;
      }
      if (cnt < size) {
        myParts[cnt] = new StripCapablePath(patch.getBeforeName());
        myBeforeIdx = cnt;
      } else {
        myBeforeIdx = 0;
      }
    }