use of com.intellij.openapi.vcs.history.VcsRevisionNumber in project intellij-community by JetBrains.
the class FileAnnotation method createDefaultCurrentFileRevisionProvider.
@Nullable
private static CurrentFileRevisionProvider createDefaultCurrentFileRevisionProvider(@NotNull FileAnnotation annotation) {
List<VcsFileRevision> revisions = annotation.getRevisions();
if (revisions == null)
return null;
Map<VcsRevisionNumber, VcsFileRevision> map = new HashMap<>();
for (VcsFileRevision revision : revisions) {
map.put(revision.getRevisionNumber(), revision);
}
List<VcsFileRevision> lineToRevision = new ArrayList<>(annotation.getLineCount());
for (int i = 0; i < annotation.getLineCount(); i++) {
lineToRevision.add(map.get(annotation.getLineRevisionNumber(i)));
}
return (lineNumber) -> {
LOG.assertTrue(lineNumber >= 0 && lineNumber < lineToRevision.size());
return lineToRevision.get(lineNumber);
};
}
use of com.intellij.openapi.vcs.history.VcsRevisionNumber in project intellij-community by JetBrains.
the class VcsVirtualFile method loadContent.
private void loadContent() throws IOException {
if (myContent != null)
return;
assert myFileRevision != null;
final VcsFileSystem vcsFileSystem = ((VcsFileSystem) getFileSystem());
try {
myFileRevision.loadContent();
fireBeforeContentsChange();
myModificationStamp++;
final VcsRevisionNumber revisionNumber = myFileRevision.getRevisionNumber();
if (revisionNumber instanceof ShortVcsRevisionNumber) {
setRevision(((ShortVcsRevisionNumber) revisionNumber).toShortString());
} else {
setRevision(revisionNumber.asString());
}
myContent = myFileRevision.getContent();
myCharset = new CharsetToolkit(myContent).guessEncoding(myContent.length);
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
vcsFileSystem.fireContentsChanged(this, VcsVirtualFile.this, 0);
}
});
} catch (VcsException e) {
myContentLoadFailed = true;
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
vcsFileSystem.fireBeforeFileDeletion(this, VcsVirtualFile.this);
}
});
myContent = ArrayUtil.EMPTY_BYTE_ARRAY;
setRevision("0");
Messages.showMessageDialog(VcsBundle.message("message.text.could.not.load.virtual.file.content", getPresentableUrl(), e.getLocalizedMessage()), VcsBundle.message("message.title.could.not.load.content"), Messages.getInformationIcon());
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
vcsFileSystem.fireFileDeleted(this, VcsVirtualFile.this, getName(), getParent());
}
});
} catch (ProcessCanceledException ex) {
myContent = null;
}
}
use of com.intellij.openapi.vcs.history.VcsRevisionNumber in project intellij-community by JetBrains.
the class ShelvedChange method getChange.
public Change getChange(Project project) {
// todo unify with
if (myChange == null) {
File baseDir = new File(project.getBaseDir().getPath());
File file = getAbsolutePath(baseDir, myBeforePath);
FilePath beforePath = VcsUtil.getFilePath(file, false);
beforePath.refresh();
ContentRevision beforeRevision = null;
if (myFileStatus != FileStatus.ADDED) {
beforeRevision = new CurrentContentRevision(beforePath) {
@Override
@NotNull
public VcsRevisionNumber getRevisionNumber() {
return new TextRevisionNumber(VcsBundle.message("local.version.title"));
}
};
}
ContentRevision afterRevision = null;
if (myFileStatus != FileStatus.DELETED) {
FilePath afterPath = VcsUtil.getFilePath(getAbsolutePath(baseDir, myAfterPath), false);
afterRevision = new PatchedContentRevision(project, beforePath, afterPath);
}
myChange = new Change(beforeRevision, afterRevision, myFileStatus);
}
return myChange;
}
use of com.intellij.openapi.vcs.history.VcsRevisionNumber in project intellij-community by JetBrains.
the class CvsChangeProvider method processFile.
private void processFile(final VirtualFile dir, @Nullable VirtualFile file, Entry entry, final ChangelistBuilder builder, final ProgressIndicator progress) throws VcsException {
final FilePath filePath = VcsUtil.getFilePath(dir, entry.getFileName());
final FileStatus status = CvsStatusProvider.getStatus(file, entry);
final VcsRevisionNumber number = createRevisionNumber(entry.getRevision(), status);
processStatus(filePath, file, status, number, builder);
progress.checkCanceled();
checkSwitchedFile(filePath, builder, dir, entry);
}
use of com.intellij.openapi.vcs.history.VcsRevisionNumber in project intellij-community by JetBrains.
the class GitAnnotationProvider method annotate.
@NotNull
private GitFileAnnotation annotate(@NotNull final FilePath repositoryFilePath, @Nullable final VcsRevisionNumber revision, @NotNull final VirtualFile file) throws VcsException {
GitVcs vcs = GitVcs.getInstance(myProject);
assert vcs != null;
VcsRevisionNumber actualRevision = revision != null ? revision : vcs.getDiffProvider().getCurrentRevision(file);
if (actualRevision != null) {
Object annotatedData = myCache.get(repositoryFilePath, GitVcs.getKey(), actualRevision);
if (annotatedData instanceof CachedData)
return restoreFromCache(file, actualRevision, (CachedData) annotatedData);
}
GitFileAnnotation fileAnnotation = doAnnotate(repositoryFilePath, actualRevision, file);
if (actualRevision != null) {
myCache.put(repositoryFilePath, GitVcs.getKey(), actualRevision, cacheData(fileAnnotation));
}
return fileAnnotation;
}
Aggregations