本文整理汇总了Java中com.intellij.openapi.vcs.history.VcsFileRevision类的典型用法代码示例。如果您正苦于以下问题:Java VcsFileRevision类的具体用法?Java VcsFileRevision怎么用?Java VcsFileRevision使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VcsFileRevision类属于com.intellij.openapi.vcs.history包,在下文中一共展示了VcsFileRevision类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AnnotateCurrentRevisionAction
import com.intellij.openapi.vcs.history.VcsFileRevision; //导入依赖的package包/类
public AnnotateCurrentRevisionAction(@NotNull FileAnnotation annotation, @NotNull AbstractVcs vcs) {
super("Annotate Revision", "Annotate selected revision in new tab", AllIcons.Actions.Annotate,
annotation, vcs);
List<VcsFileRevision> revisions = annotation.getRevisions();
if (revisions == null) {
myRevisions = null;
return;
}
Map<VcsRevisionNumber, VcsFileRevision> map = new HashMap<VcsRevisionNumber, VcsFileRevision>();
for (VcsFileRevision revision : revisions) {
map.put(revision.getRevisionNumber(), revision);
}
myRevisions = new ArrayList<VcsFileRevision>(annotation.getLineCount());
for (int i = 0; i < annotation.getLineCount(); i++) {
myRevisions.add(map.get(annotation.getLineRevisionNumber(i)));
}
}
示例2: AnnotatePreviousRevisionAction
import com.intellij.openapi.vcs.history.VcsFileRevision; //导入依赖的package包/类
public AnnotatePreviousRevisionAction(@NotNull FileAnnotation annotation, @NotNull AbstractVcs vcs) {
super("Annotate Previous Revision", "Annotate successor of selected revision in new tab", AllIcons.Actions.Annotate,
annotation, vcs);
List<VcsFileRevision> revisions = annotation.getRevisions();
if (revisions == null) {
myRevisions = null;
return;
}
Map<VcsRevisionNumber, VcsFileRevision> map = new HashMap<VcsRevisionNumber, VcsFileRevision>();
for (int i = 0; i < revisions.size(); i++) {
VcsFileRevision revision = revisions.get(i);
VcsFileRevision previousRevision = i + 1 < revisions.size() ? revisions.get(i + 1) : null;
map.put(revision.getRevisionNumber(), previousRevision);
}
myRevisions = new ArrayList<VcsFileRevision>(annotation.getLineCount());
for (int i = 0; i < annotation.getLineCount(); i++) {
myRevisions.add(map.get(annotation.getLineRevisionNumber(i)));
}
}
示例3: isEnabled
import com.intellij.openapi.vcs.history.VcsFileRevision; //导入依赖的package包/类
public boolean isEnabled(@NotNull AnActionEvent e) {
if (e.getProject() == null) return false;
VcsFileRevision fileRevision = getFileRevision(e);
if (fileRevision == null) return false;
VirtualFile file = getFile(e);
if (file == null) return false;
AbstractVcs vcs = getVcs(e);
if (vcs == null) return false;
AnnotationProvider provider = vcs.getCachingAnnotationProvider();
if (provider == null || !provider.isAnnotationValid(fileRevision)) return false;
final ProjectLevelVcsManagerImpl plVcsManager = (ProjectLevelVcsManagerImpl)ProjectLevelVcsManager.getInstance(vcs.getProject());
if (plVcsManager.getBackgroundableActionHandler(VcsBackgroundableActions.ANNOTATE).isInProgress(key(file))) return false;
return true;
}
示例4: getFile
import com.intellij.openapi.vcs.history.VcsFileRevision; //导入依赖的package包/类
@Nullable
@Override
protected VirtualFile getFile(@NotNull AnActionEvent e) {
VcsFileRevision revision = getFileRevision(e);
if (revision == null) return null;
final FileType currentFileType = myAnnotation.getFile().getFileType();
FilePath filePath =
(revision instanceof VcsFileRevisionEx ? ((VcsFileRevisionEx)revision).getPath() : VcsUtil.getFilePath(myAnnotation.getFile()));
return new VcsVirtualFile(filePath.getPath(), revision, VcsFileSystem.getInstance()) {
@NotNull
@Override
public FileType getFileType() {
FileType type = super.getFileType();
if (!type.isBinary()) return type;
if (!currentFileType.isBinary()) return currentFileType;
return PlainTextFileType.INSTANCE;
}
};
}
示例5: annotate
import com.intellij.openapi.vcs.history.VcsFileRevision; //导入依赖的package包/类
private GitFileAnnotation annotate(@NotNull final FilePath repositoryFilePath,
@Nullable final VcsRevisionNumber revision,
@NotNull final List<VcsFileRevision> revisions,
@NotNull final VirtualFile file) throws VcsException {
GitSimpleHandler h = new GitSimpleHandler(myProject, GitUtil.getGitRoot(repositoryFilePath), GitCommand.BLAME);
h.setStdoutSuppressed(true);
h.setCharset(file.getCharset());
h.addParameters("--porcelain", "-l", "-t", "-w");
if (revision == null) {
h.addParameters("HEAD");
}
else {
h.addParameters(revision.asString());
}
h.endOptions();
h.addRelativePaths(repositoryFilePath);
String output = h.run();
GitFileAnnotation annotation = parseAnnotations(revision, file, output);
annotation.addLogEntries(revisions);
return annotation;
}
示例6: showDiffWithBranch
import com.intellij.openapi.vcs.history.VcsFileRevision; //导入依赖的package包/类
private static void showDiffWithBranch(@NotNull Project project, @NotNull VirtualFile file, @NotNull String head,
@NotNull String branchToCompare) throws VcsException {
FilePath filePath = VcsUtil.getFilePath(file);
// we could use something like GitRepository#getCurrentRevision here,
// but this way we can easily identify if the file is available in the branch
GitRevisionNumber compareRevisionNumber = (GitRevisionNumber)GitHistoryUtils.getCurrentRevision(project, filePath, branchToCompare);
if (compareRevisionNumber == null) {
fileDoesntExistInBranchError(project, file, branchToCompare);
return;
}
GitRevisionNumber currentRevisionNumber = (GitRevisionNumber)GitHistoryUtils.getCurrentRevision(project, filePath, head);
if (currentRevisionNumber == null) {
LOG.error(String.format("Current revision number is null for file [%s] and branch [%s]", filePath, head));
return;
}
// constructing the revision with human readable name (will work for files comparison however).
VcsFileRevision compareRevision = new GitFileRevision(project, filePath,
new GitRevisionNumber(branchToCompare, compareRevisionNumber.getTimestamp()));
CurrentRevision currentRevision = new CurrentRevision(file, new GitRevisionNumber(head, currentRevisionNumber.getTimestamp()));
new GitDiffFromHistoryHandler(project).showDiffForTwo(project, VcsUtil.getFilePath(file), compareRevision, currentRevision);
}
示例7: history
import com.intellij.openapi.vcs.history.VcsFileRevision; //导入依赖的package包/类
public static List<VcsFileRevision> history(@NotNull Project project,
@NotNull FilePath path,
@Nullable VirtualFile root,
@NotNull VcsRevisionNumber startingFrom,
String... parameters) throws VcsException {
final List<VcsFileRevision> rc = new ArrayList<VcsFileRevision>();
final List<VcsException> exceptions = new ArrayList<VcsException>();
history(project, path, root, startingFrom, new Consumer<GitFileRevision>() {
@Override public void consume(GitFileRevision gitFileRevision) {
rc.add(gitFileRevision);
}
}, new Consumer<VcsException>() {
@Override public void consume(VcsException e) {
exceptions.add(e);
}
}, parameters);
if (!exceptions.isEmpty()) {
throw exceptions.get(0);
}
return rc;
}
示例8: annotate
import com.intellij.openapi.vcs.history.VcsFileRevision; //导入依赖的package包/类
public FileAnnotation annotate(VirtualFile file, VcsFileRevision revision) throws VcsException {
final VirtualFile vcsRoot = VcsUtil.getVcsRootFor(myProject, VcsUtil.getFilePath(file.getPath()));
if (vcsRoot == null) {
throw new VcsException("vcs root is null for " + file);
}
final HgFile hgFile = new HgFile(vcsRoot, VfsUtilCore.virtualToIoFile(file));
HgFile fileToAnnotate = revision instanceof HgFileRevision
? HgUtil.getFileNameInTargetRevision(myProject, ((HgFileRevision)revision).getRevisionNumber(), hgFile)
: new HgFile(vcsRoot,
HgUtil.getOriginalFileName(hgFile.toFilePath(), ChangeListManager.getInstance(myProject)));
final List<HgAnnotationLine> annotationResult = (new HgAnnotateCommand(myProject)).execute(fileToAnnotate, revision);
final List<HgFileRevision> logResult;
try {
HgLogCommand logCommand = new HgLogCommand(myProject);
logCommand.setFollowCopies(true);
logResult = logCommand.execute(fileToAnnotate, -1, false);
}
catch (HgCommandException e) {
throw new VcsException("Can not annotate, " + HgVcsMessages.message("hg4idea.error.log.command.execution"), e);
}
VcsRevisionNumber revisionNumber = revision == null ?
new HgWorkingCopyRevisionsCommand(myProject).tip(vcsRoot) :
revision.getRevisionNumber();
return new HgAnnotation(myProject, hgFile, annotationResult, logResult, revisionNumber);
}
示例9: execute
import com.intellij.openapi.vcs.history.VcsFileRevision; //导入依赖的package包/类
public List<HgAnnotationLine> execute(@NotNull HgFile hgFile, VcsFileRevision revision) {
final List<String> arguments = new ArrayList<String>();
arguments.add("-cvnudl");
HgVcs vcs = HgVcs.getInstance(myProject);
if (vcs != null &&
vcs.getProjectSettings().isWhitespacesIgnoredInAnnotations() &&
vcs.getVersion().isIgnoreWhitespaceDiffInAnnotationsSupported()) {
arguments.add("-w");
}
if (revision != null) {
arguments.add("-r");
HgRevisionNumber revisionNumber = (HgRevisionNumber)revision.getRevisionNumber();
arguments.add(revisionNumber.getChangeset());
}
arguments.add(hgFile.getRelativePath());
final HgCommandResult result = new HgCommandExecutor(myProject).executeInCurrentThread(hgFile.getRepo(), "annotate", arguments);
if (result == null) {
return Collections.emptyList();
}
List<String> outputLines = result.getOutputLines();
return parse(outputLines);
}
示例10: testCurrentAndPreviousRevisions
import com.intellij.openapi.vcs.history.VcsFileRevision; //导入依赖的package包/类
/**
* 1. Make two versions of a file (create, add, commit, modify, commit).
* 2. Get the revisions history.
* 3. Verify versions' contents and the current version.
*/
@Test
public void testCurrentAndPreviousRevisions() throws Exception {
int versions = 0;
fillFile(myProjectDir, new String[]{ AFILE }, INITIAL_FILE_CONTENT);
addAll();
commitAll("initial content");
versions++;
fillFile(myProjectDir, new String[] { AFILE} , UPDATED_FILE_CONTENT);
commitAll("updated content");
versions++;
final VcsHistorySession session = getHistorySession(AFILE);
final List<VcsFileRevision> revisions = session.getRevisionList();
for (VcsFileRevision rev : revisions) {
rev.loadContent();
}
assertEquals(revisions.size(), versions);
assertTrue(session.isCurrentRevision(revisions.get(0).getRevisionNumber()));
assertEquals(revisions.get(0).getContent(), UPDATED_FILE_CONTENT.getBytes());
assertEquals(revisions.get(1).getContent(), INITIAL_FILE_CONTENT.getBytes());
}
示例11: adjustAnnotation
import com.intellij.openapi.vcs.history.VcsFileRevision; //导入依赖的package包/类
private static void adjustAnnotation(@Nullable List<VcsFileRevision> revisions, @NotNull Annotation[] lineAnnotations) {
if (revisions != null) {
final Map<String, VcsFileRevision> revisionMap = new HashMap<String, VcsFileRevision>();
for (VcsFileRevision vcsFileRevision : revisions) {
revisionMap.put(vcsFileRevision.getRevisionNumber().asString(), vcsFileRevision);
}
for (Annotation lineAnnotation : lineAnnotations) {
final String revisionNumber = lineAnnotation.getRevision();
final VcsFileRevision revision = revisionMap.get(revisionNumber);
if (revision != null) {
lineAnnotation.setUser(revision.getAuthor());
lineAnnotation.setDate(revision.getRevisionDate());
}
}
}
}
示例12: testHistoryImpl
import com.intellij.openapi.vcs.history.VcsFileRevision; //导入依赖的package包/类
private void testHistoryImpl(String s) throws VcsException {
final VcsHistoryProvider provider = myVcs.getVcsHistoryProvider();
final VcsAppendableHistoryPartnerAdapter partner = new VcsAppendableHistoryPartnerAdapter() {
@Override
public void acceptRevision(VcsFileRevision revision) {
super.acceptRevision(revision);
if(getSession().getRevisionList().size() > 1) {
throw new ProcessCanceledException();
}
}
};
try {
provider.reportAppendableHistory(VcsContextFactory.SERVICE.getInstance().createFilePathOnNonLocal(s, true), partner);
} catch (ProcessCanceledException e) {
//ok
}
final List<VcsFileRevision> list = partner.getSession().getRevisionList();
Assert.assertTrue(! list.isEmpty());
}
示例13: createSession
import com.intellij.openapi.vcs.history.VcsFileRevision; //导入依赖的package包/类
private static VcsAbstractHistorySession createSession(final VcsRevisionNumber currentRevisionNumber,
final List<TfsFileRevision> revisions,
final boolean isFile) {
return new VcsAbstractHistorySession(revisions) {
public VcsRevisionNumber calcCurrentRevisionNumber() {
return currentRevisionNumber;
}
public HistoryAsTreeProvider getHistoryAsTreeProvider() {
return null;
}
@Override
public VcsHistorySession copy() {
return createSession(currentRevisionNumber, revisions, isFile);
}
@Override
public boolean isContentAvailable(final VcsFileRevision revision) {
return isFile;
}
};
}
示例14: showAffectedPaths
import com.intellij.openapi.vcs.history.VcsFileRevision; //导入依赖的package包/类
@Override
protected void showAffectedPaths(int lineNum) {
if (lineNum < myLineRevisions.length) {
final VcsFileRevision revision = myLineRevisions[lineNum];
final int changeset = ((VcsRevisionNumber.Int)revision.getRevisionNumber()).getValue();
final CommittedChangeList changeList =
new TFSChangeList(myWorkspace, changeset, revision.getAuthor(), revision.getRevisionDate(), revision.getCommitMessage(), myVcs);
String changesetString = ((TfsRevisionNumber)revision.getRevisionNumber()).getChangesetString();
final String progress = MessageFormat.format("Loading changeset {0}...", changesetString);
ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
public void run() {
changeList.getChanges();
}
}, progress, false, myVcs.getProject());
final String title = MessageFormat.format("Changeset {0}", changesetString);
AbstractVcsHelper.getInstance(myVcs.getProject()).showChangesListBrowser(changeList, title);
}
}
示例15: getRevisions
import com.intellij.openapi.vcs.history.VcsFileRevision; //导入依赖的package包/类
@Nullable
@Override
public List<VcsFileRevision> getRevisions() {
final HashSet<ArtifactInfo> artifactInfos = new HashSet<ArtifactInfo>(myMap.values());
final List<VcsFileRevision> result = new ArrayList<VcsFileRevision>(myMap.size());
//todo correct filepath
final FilePath fp = new FilePathImpl(myVirtualFile);
for (ArtifactInfo artifactInfo : artifactInfos) {
result.add(new FossilFileRevision(myProject, fp, new FossilRevisionNumber(artifactInfo.getHash(), artifactInfo.getDate()),
artifactInfo.getUser(), artifactInfo.getComment()));
}
Collections.sort(result, new Comparator<VcsFileRevision>() {
@Override
public int compare(final VcsFileRevision o1, final VcsFileRevision o2) {
return o1.getRevisionDate().compareTo(o2.getRevisionDate());
}
});
return result;
}