Java Code Examples for com.intellij.openapi.vcs.history.VcsRevisionNumber#NULL

The following examples show how to use com.intellij.openapi.vcs.history.VcsRevisionNumber#NULL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TFSDiffProvider.java    From azure-devops-intellij with MIT License 6 votes vote down vote up
@Nullable
public VcsRevisionNumber getCurrentRevision(final VirtualFile virtualFile) {
    try {
        // need to make a file because the VirtualFile object path is in system-independent format
        final File localFile = VfsUtilCore.virtualToIoFile(virtualFile);
        final String filePath = localFile.getPath();
        final ServerContext context = TFSVcs.getInstance(project).getServerContext(true);
        final ItemInfo itemInfo = CommandUtils.getItemInfo(context, filePath);
        return createRevision(itemInfo, filePath);
    } catch (Exception e) {
        logger.warn("Unable to getCurrentRevision", e);
        AbstractVcsHelper.getInstance(project).showError(
                new VcsException(LocalizationServiceImpl.getInstance().getExceptionMessage(e), e), TFSVcs.TFVC_NAME);
    }
    return VcsRevisionNumber.NULL;
}
 
Example 2
Source File: Difference.java    From consulo with Apache License 2.0 6 votes vote down vote up
private ContentRevision createContentRevision(final Entry e, final IdeaGateway gw) {
  if (e == null) return null;

  return new ContentRevision() {
    @Nullable
    public String getContent() throws VcsException {
      if (e.isDirectory()) return null;
      return e.getContent().getString(e, gw);
    }

    @Nonnull
    public FilePath getFile() {
      return new FilePathImpl(new File(e.getPath()), e.isDirectory());
    }

    @Nonnull
    public VcsRevisionNumber getRevisionNumber() {
      return VcsRevisionNumber.NULL;
    }
  };
}
 
Example 3
Source File: TFSDiffProvider.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
public ItemLatestState getLastRevision(final FilePath localPath) {
    try {
        // need to make a file because the FilePath object path is in system-independent format
        final File localFile = localPath.getIOFile();
        final VcsRevisionNumber revisionNumber = getRevisionNumber(localFile.getPath(), localFile.getName());
        if (revisionNumber != VcsRevisionNumber.NULL) {
            return new ItemLatestState(revisionNumber, true, false);
        }
    } catch (final Exception e) {
        logger.warn("Unable to getLastRevision", e);
        AbstractVcsHelper.getInstance(project).showError(
                new VcsException(LocalizationServiceImpl.getInstance().getExceptionMessage(e), e), TFSVcs.TFVC_NAME);
    }
    return new ItemLatestState(VcsRevisionNumber.NULL, false, false);
}
 
Example 4
Source File: TFSDiffProvider.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
/**
 * Creates a revision number for the given file
 *
 * @param filePath
 * @param fileName
 * @return
 */
private VcsRevisionNumber getRevisionNumber(final String filePath, final String fileName) {
    final TfvcVersionDescriptor versionDescriptor = new TfvcVersionDescriptor();
    versionDescriptor.setVersionType(TfvcVersionType.LATEST);
    final ServerContext context = TFSVcs.getInstance(project).getServerContext(true);
    final List<TfvcItem> item = context.getTfvcHttpClient().getItems(context.getTeamProjectReference().getId(),
            TfsFileUtil.translateLocalItemToServerItem(filePath, getUpdatedMappings()),
            VersionControlRecursionTypeCaseSensitive.NONE, versionDescriptor);

    if (!item.isEmpty() && item.get(0) != null) {
        return new TfsRevisionNumber(item.get(0).getChangesetVersion(), fileName, item.get(0).getChangeDate().toString());
    }
    return VcsRevisionNumber.NULL;
}
 
Example 5
Source File: BlameAnnotationImpl.java    From GitToolBox with Apache License 2.0 5 votes vote down vote up
@NotNull
private VcsRevisionNumber getLineRevisionNumber(int lineIndex) {
  if (lineIndex < 0 || lineIndex >= lineRevisions.length) {
    return VcsRevisionNumber.NULL;
  }
  VcsRevisionNumber revisionNumber = lineRevisions[lineIndex];
  if (revisionNumber == null) {
    VcsRevisionNumber lineRevisionNumber = provider.getRevisionNumber(lineIndex);
    lineRevisions[lineIndex] = lineRevisionNumber;
    revisionNumber = lineRevisionNumber;
  }
  return revisionNumber;
}
 
Example 6
Source File: IncrementalBlameCalculator.java    From GitToolBox with Apache License 2.0 5 votes vote down vote up
@Nullable
public RevisionDataProvider annotate(@NotNull GitRepository repository,
                                     @NotNull VirtualFile file,
                                     @NotNull VcsRevisionNumber revision) {
  if (revision != VcsRevisionNumber.NULL) {
    return gateway.annotateTimer().timeSupplier(() -> annotateImpl(repository, file, revision));
  }
  return null;
}
 
Example 7
Source File: BlameCacheImpl.java    From GitToolBox with Apache License 2.0 5 votes vote down vote up
@NotNull
private VcsRevisionNumber currentRepoRevision(@NotNull VirtualFile file) {
  GitRepository repo = gateway.getRepoForFile(file);
  if (repo != null) {
    return gateway.getCurrentRevision(repo);
  }
  return VcsRevisionNumber.NULL;
}
 
Example 8
Source File: LocalChangeListImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static boolean sameBeforeRevision(final Change change1, final Change change2) {
  final ContentRevision b1 = change1.getBeforeRevision();
  final ContentRevision b2 = change2.getBeforeRevision();
  if (b1 != null && b2 != null) {
    final VcsRevisionNumber rn1 = b1.getRevisionNumber();
    final VcsRevisionNumber rn2 = b2.getRevisionNumber();
    final boolean isBinary1 = (b1 instanceof BinaryContentRevision);
    final boolean isBinary2 = (b2 instanceof BinaryContentRevision);
    return rn1 != VcsRevisionNumber.NULL && rn2 != VcsRevisionNumber.NULL && rn1.compareTo(rn2) == 0 && isBinary1 == isBinary2;
  }
  return b1 == null && b2 == null;
}
 
Example 9
Source File: VcsCurrentRevisionProxy.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public VcsRevisionNumber getRevisionNumber() {
  try {
    return getVcsRevision().getRevisionNumber();
  }
  catch(VcsException ex) {
    return VcsRevisionNumber.NULL;
  }
}
 
Example 10
Source File: ChangesComparatorTest.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private static Change change(@Nonnull String path) throws Exception {
  ContentRevision before = new MockContentRevision(new FilePathImpl(new File(path), false), VcsRevisionNumber.NULL);
  ContentRevision after = new MockContentRevision(new FilePathImpl(new File(path), false), VcsRevisionNumber.NULL);
  return new Change(before, after);
}
 
Example 11
Source File: CurrentContentRevision.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public VcsRevisionNumber getRevisionNumber() {
  return VcsRevisionNumber.NULL;
}
 
Example 12
Source File: ChangeGoToChangePopupAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public VcsRevisionNumber getRevisionNumber() {
  return VcsRevisionNumber.NULL;
}
 
Example 13
Source File: FakeRevision.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public VcsRevisionNumber getRevisionNumber() {
  return VcsRevisionNumber.NULL;
}