Search in sources :

Example 41 with AbstractVcs

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;
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) VcsHistorySession(com.intellij.openapi.vcs.history.VcsHistorySession) VcsHistoryProvider(com.intellij.openapi.vcs.history.VcsHistoryProvider) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs) FilesTooBigForDiffException(com.intellij.util.diff.FilesTooBigForDiffException) Nullable(org.jetbrains.annotations.Nullable)

Example 42 with AbstractVcs

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);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsLogData(com.intellij.vcs.log.data.VcsLogData) VcsLogProvider(com.intellij.vcs.log.VcsLogProvider) VcsRoot(com.intellij.openapi.vcs.VcsRoot) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs)

Example 43 with AbstractVcs

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;
}
Also used : AbstractVcs(com.intellij.openapi.vcs.AbstractVcs)

Example 44 with AbstractVcs

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));
        }
    });
}
Also used : VcsUtil(com.intellij.vcsUtil.VcsUtil) Arrays(java.util.Arrays) ModuleExtKt(com.jetbrains.extensions.ModuleExtKt) StringUtil(com.intellij.openapi.util.text.StringUtil) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs) Project(com.intellij.openapi.project.Project) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull) Collections(java.util.Collections) Sdk(com.intellij.openapi.projectRoots.Sdk) CheckinEnvironment(com.intellij.openapi.vcs.checkin.CheckinEnvironment) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) Project(com.intellij.openapi.project.Project) CheckinEnvironment(com.intellij.openapi.vcs.checkin.CheckinEnvironment) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem)

Aggregations

AbstractVcs (com.intellij.openapi.vcs.AbstractVcs)44 VirtualFile (com.intellij.openapi.vfs.VirtualFile)22 NotNull (org.jetbrains.annotations.NotNull)12 Project (com.intellij.openapi.project.Project)9 FilePath (com.intellij.openapi.vcs.FilePath)7 VcsRoot (com.intellij.openapi.vcs.VcsRoot)7 ProjectLevelVcsManager (com.intellij.openapi.vcs.ProjectLevelVcsManager)6 Nullable (org.jetbrains.annotations.Nullable)5 Module (com.intellij.openapi.module.Module)3 VcsDirectoryMapping (com.intellij.openapi.vcs.VcsDirectoryMapping)3 VcsKey (com.intellij.openapi.vcs.VcsKey)3 VcsFileRevision (com.intellij.openapi.vcs.history.VcsFileRevision)3 VcsHistoryProvider (com.intellij.openapi.vcs.history.VcsHistoryProvider)3 VcsRevisionNumber (com.intellij.openapi.vcs.history.VcsRevisionNumber)3 Date (java.util.Date)3 Pair (com.intellij.openapi.util.Pair)2 VcsException (com.intellij.openapi.vcs.VcsException)2 DiffProvider (com.intellij.openapi.vcs.diff.DiffProvider)2 VcsHistorySession (com.intellij.openapi.vcs.history.VcsHistorySession)2 VcsLogProvider (com.intellij.vcs.log.VcsLogProvider)2