コード例 #1
0
 private static void extractFileName(
     final String curLine, final FilePatch patch, final boolean before, final boolean gitPatch) {
   String fileName = curLine.substring(4);
   int pos = fileName.indexOf('\t');
   if (pos < 0) {
     pos = fileName.indexOf(' ');
   }
   if (pos >= 0) {
     String versionId = fileName.substring(pos).trim();
     fileName = fileName.substring(0, pos);
     if (versionId.length() > 0 && !EMPTY_REVISION_INFO_PATTERN.matcher(versionId).matches()) {
       if (before) {
         patch.setBeforeVersionId(versionId);
       } else {
         patch.setAfterVersionId(versionId);
       }
     }
   }
   if ("/dev/null".equals(fileName)) return;
   if (before) {
     if (gitPatch && fileName.startsWith("a/")) {
       fileName = fileName.substring(2);
     }
     patch.setBeforeName(fileName);
   } else {
     if (gitPatch && fileName.startsWith("b/")) {
       fileName = fileName.substring(2);
     }
     patch.setAfterName(fileName);
   }
 }
コード例 #2
0
    @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();
    }
コード例 #3
0
 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;
 }