コード例 #1
0
  public byte[] loadContent() throws IOException, VcsException {
    ContentLoader loader = new ContentLoader(myURL, myRevision, myPegRevision);
    if (ApplicationManager.getApplication().isDispatchThread() && !myRevision.isLocal()) {
      ProgressManager.getInstance()
          .runProcessWithProgressSynchronously(
              loader,
              SvnBundle.message("progress.title.loading.file.content"),
              false,
              myVCS.getProject());
    } else {
      loader.run();
    }

    VcsException exception = loader.getException();
    if (exception == null) {
      final byte[] contents = loader.getContents();
      ContentRevisionCache.checkContentsSize(myURL, contents.length);
      return contents;
    } else {
      LOG.info(
          "Failed to load file '"
              + myURL
              + "' content at revision: "
              + myRevision
              + "\n"
              + exception.getMessage(),
          exception);
      throw exception;
    }
  }
コード例 #2
0
  @Nullable
  public String getContent() throws VcsException {
    try {
      if (myUseBaseRevision) {
        return ContentRevisionCache.getOrLoadCurrentAsString(
                myVcs.getProject(),
                myFile,
                myVcs.getKeyInstanceMethod(),
                new CurrentRevisionProvider() {
                  @Override
                  public VcsRevisionNumber getCurrentRevision() throws VcsException {
                    return getRevisionNumber();
                  }

                  @Override
                  public Pair<VcsRevisionNumber, byte[]> get() throws VcsException, IOException {
                    return Pair.create(getRevisionNumber(), getUpToDateBinaryContent());
                  }
                })
            .getSecond();
      } else {
        return ContentRevisionCache.getOrLoadAsString(
            myVcs.getProject(),
            myFile,
            getRevisionNumber(),
            myVcs.getKeyInstanceMethod(),
            ContentRevisionCache.UniqueType.REPOSITORY_CONTENT,
            new Throwable2Computable<byte[], VcsException, IOException>() {
              @Override
              public byte[] compute() throws VcsException, IOException {
                return getUpToDateBinaryContent();
              }
            });
      }
    } catch (IOException e) {
      throw new VcsException(e);
    }
  }
コード例 #3
0
 public synchronized byte[] getContent() throws IOException, VcsException {
   if (myNoCache) {
     return loadContent();
   }
   return ContentRevisionCache.getOrLoadAsBytes(
       project,
       path,
       revision,
       GitVcs.getKey(),
       ContentRevisionCache.UniqueType.REPOSITORY_CONTENT,
       new Throwable2Computable<byte[], VcsException, IOException>() {
         @Override
         public byte[] compute() throws VcsException, IOException {
           return loadContent();
         }
       });
 }
コード例 #4
0
  public byte[] getContent() throws IOException, VcsException {
    byte[] result;

    if (SVNRevision.HEAD.equals(myRevision)) {
      result = loadContent();
    } else {
      result =
          ContentRevisionCache.getOrLoadAsBytes(
              myVCS.getProject(),
              VcsUtil.getFilePathOnNonLocal(myURL, false),
              getRevisionNumber(),
              myVCS.getKeyInstanceMethod(),
              ContentRevisionCache.UniqueType.REMOTE_CONTENT,
              new Throwable2Computable<byte[], VcsException, IOException>() {
                @Override
                public byte[] compute() throws VcsException, IOException {
                  return loadContent();
                }
              });
    }

    return result;
  }