use of com.intellij.openapi.vcs.AbstractVcs in project intellij-community by JetBrains.
the class SrcFileAnnotator method loadFromVersionControl.
@Nullable
private byte[] loadFromVersionControl(long date, VirtualFile f) {
try {
final AbstractVcs vcs = VcsUtil.getVcsFor(myProject, f);
if (vcs == null)
return null;
final VcsHistoryProvider historyProvider = vcs.getVcsHistoryProvider();
if (historyProvider == null)
return null;
final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(f);
final VcsHistorySession session = historyProvider.createSessionFor(filePath);
if (session == null)
return null;
final List<VcsFileRevision> list = session.getRevisionList();
if (list != null) {
for (VcsFileRevision revision : list) {
final Date revisionDate = revision.getRevisionDate();
if (revisionDate == null) {
return null;
}
if (revisionDate.getTime() < date) {
return revision.loadContent();
}
}
}
} catch (Exception e) {
LOG.info(e);
return null;
}
return null;
}
use of com.intellij.openapi.vcs.AbstractVcs in project intellij-community by JetBrains.
the class VcsLogFileHistoryProviderImpl method canShowFileHistory.
@Override
public boolean canShowFileHistory(@NotNull Project project, @NotNull FilePath path) {
if (!Registry.is("vcs.new.history"))
return false;
VcsRoot rootObject = ProjectLevelVcsManager.getInstance(project).getVcsRootObjectFor(path);
if (rootObject == null)
return false;
VirtualFile root = rootObject.getPath();
AbstractVcs vcs = rootObject.getVcs();
if (vcs == null || root == null)
return false;
VcsLogData dataManager = VcsProjectLog.getInstance(project).getDataManager();
if (dataManager == null || !dataManager.getRoots().contains(root) || dataManager.getIndex().getDataGetter() == null)
return false;
List<VcsLogProvider> allLogProviders = Arrays.asList(Extensions.getExtensions(VcsLogProvider.LOG_PROVIDER_EP, project));
VcsLogProvider provider = ContainerUtil.find(allLogProviders, p -> p.getSupportedVcs().equals(vcs.getKeyInstanceMethod()));
if (provider == null)
return false;
return VcsLogProperties.get(provider, VcsLogProperties.SUPPORTS_INDEXING);
}
use of com.intellij.openapi.vcs.AbstractVcs in project intellij-community by JetBrains.
the class CvsFileOperationsHandler method processDeletedFile.
private boolean processDeletedFile(final VirtualFile file) throws IOException {
if (myInternalDelete)
return false;
final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(myProject).getVcsFor(file);
if (vcs != CvsVcs2.getInstance(myProject))
return false;
file.putUserData(CvsStorageSupportingDeletionComponent.FILE_VCS, vcs);
if (!CvsUtil.fileIsUnderCvs(file))
return false;
myComponent.getDeleteHandler().addDeletedRoot(file);
if (file.isDirectory()) {
myInternalDelete = true;
try {
deleteFilesInVFS(file);
} finally {
myInternalDelete = false;
}
return true;
}
return false;
}
use of com.intellij.openapi.vcs.AbstractVcs in project intellij-community by JetBrains.
the class NewFilesProcessor method addToVcsIfNeeded.
/**
* @param localFileNames names of local files to add to VCS
*/
private static void addToVcsIfNeeded(@NotNull final Module module, @NotNull final String... localFileNames) {
final LocalFileSystem fs = LocalFileSystem.getInstance();
fs.refresh(false);
final Project project = module.getProject();
Arrays.stream(localFileNames).map(o -> fs.findFileByPath(o)).filter(o -> o != null).forEach(file -> {
final AbstractVcs<?> vcs = VcsUtil.getVcsFor(project, file);
if (vcs == null) {
return;
}
final CheckinEnvironment environment = vcs.getCheckinEnvironment();
if (environment != null) {
environment.scheduleUnversionedFilesForAddition(Collections.singletonList(file));
}
});
}
Aggregations