コード例 #1
0
 public void setAutoBases(@NotNull final Collection<VirtualFile> autoBases) {
   final String path =
       myPatch.getBeforeName() == null ? myPatch.getAfterName() : myPatch.getBeforeName();
   for (VirtualFile autoBase : autoBases) {
     final VirtualFile willBeBase = PathMerger.getBase(autoBase, path);
     if (willBeBase != null) {
       myAutoBases.add(willBeBase);
     }
   }
 }
コード例 #2
0
  private static FilePatchStatus getStatus(final TextFilePatch patch) {
    final String beforeName = patch.getBeforeName().replace("\\", "/");
    final String afterName = patch.getAfterName().replace("\\", "/");

    if (patch.isNewFile() || (beforeName == null)) {
      return FilePatchStatus.ADDED;
    } else if (patch.isDeletedFile() || (afterName == null)) {
      return FilePatchStatus.DELETED;
    }

    if (beforeName.equals(afterName)) return FilePatchStatus.MODIFIED;
    return FilePatchStatus.MOVED_OR_RENAMED;
  }
コード例 #3
0
  public void setNewBase(final VirtualFile base) {
    myBase = base;
    myNewContentRevision = null;
    myCurrentRevision = null;
    myAfterFile = null;
    myConflicts = null;

    final String beforeName = myPatch.getBeforeName();
    if (beforeName != null) {
      myIoCurrentBase = PathMerger.getFile(new File(myBase.getPath()), beforeName);
      myCurrentBase =
          myIoCurrentBase == null ? null : VcsUtil.getVirtualFileWithRefresh(myIoCurrentBase);
      myBaseExists = (myCurrentBase != null) && myCurrentBase.exists();
    } else {
      // creation
      final String afterName = myPatch.getAfterName();
      myBaseExists = true;
      myIoCurrentBase = PathMerger.getFile(new File(myBase.getPath()), afterName);
      myCurrentBase = VcsUtil.getVirtualFileWithRefresh(myIoCurrentBase);
    }
  }
コード例 #4
0
  public ContentRevision getNewContentRevision() {
    if (FilePatchStatus.DELETED.equals(myStatus)) return null;

    if (myNewContentRevision == null) {
      myConflicts = null;
      if (FilePatchStatus.ADDED.equals(myStatus)) {
        final FilePath newFilePath =
            FilePathImpl.createNonLocal(myIoCurrentBase.getAbsolutePath(), false);
        final String content = myPatch.getNewFileText();
        myNewContentRevision =
            new SimpleContentRevision(content, newFilePath, myPatch.getAfterVersionId());
      } else {
        final FilePath newFilePath;
        if (FilePatchStatus.MOVED_OR_RENAMED.equals(myStatus)) {
          newFilePath =
              new FilePathImpl(
                  PathMerger.getFile(new File(myBase.getPath()), myPatch.getAfterName()), false);
        } else {
          newFilePath =
              (myCurrentBase != null)
                  ? new FilePathImpl(myCurrentBase)
                  : new FilePathImpl(myIoCurrentBase, false);
        }
        myNewContentRevision =
            new LazyPatchContentRevision(
                myCurrentBase, newFilePath, myPatch.getAfterVersionId(), myPatch);
        if (myCurrentBase != null) {
          ApplicationManager.getApplication()
              .executeOnPooledThread(
                  new Runnable() {
                    public void run() {
                      ((LazyPatchContentRevision) myNewContentRevision).getContent();
                    }
                  });
        }
      }
    }
    return myNewContentRevision;
  }
コード例 #5
0
 public Couple<String> getKey() {
   return Couple.newOne(myPatch.getBeforeName(), myPatch.getAfterName());
 }