Search in sources :

Example 1 with SimpleRevision

use of com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision in project intellij-community by JetBrains.

the class CvsServicesImpl method getFileContent.

public byte[] getFileContent(Project project, CvsModule cvsFile) throws IOException {
    final GetFileContentOperation operation = new GetFileContentOperation(new File(cvsFile.getPathInCvs()), CvsRootConfiguration.createOn(cvsFile.getRepository()), new SimpleRevision(cvsFile.getRevision()));
    final CvsOperationExecutor executor = new CvsOperationExecutor(project);
    executor.performActionSync(new CommandCvsHandler(CvsBundle.message("operation.name.load.file.content"), operation, false), CvsOperationExecutorCallback.EMPTY);
    if (!executor.hasNoErrors())
        throw new RuntimeException(executor.getFirstError());
    if (operation.isDeleted())
        throw new IOException(CvsBundle.message("exception.text.revision.has.been.deleted"));
    return operation.getFileBytes();
}
Also used : GetFileContentOperation(com.intellij.cvsSupport2.cvsoperations.cvsContent.GetFileContentOperation) CvsOperationExecutor(com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutor) CommandCvsHandler(com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler) IOException(java.io.IOException) File(java.io.File) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) SimpleRevision(com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision)

Example 2 with SimpleRevision

use of com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision in project intellij-community by JetBrains.

the class CvsChangeList method getChanges.

public Collection<Change> getChanges() {
    if (myChanges == null) {
        myChanges = new ArrayList<>();
        for (RevisionWrapper wrapper : myRevisions) {
            final Revision revision = wrapper.getRevision();
            final String state = revision.getState();
            String path = wrapper.getFile();
            final File localFile;
            if (myRootFile != null) {
                final String directorySuffix = myRootFile.isDirectory() ? "/" : "";
                if (StringUtil.startsWithConcatenation(path, myRootPath, directorySuffix)) {
                    path = path.substring(myRootPath.length() + directorySuffix.length());
                    localFile = new File(myRootFile.getPresentableUrl(), path);
                } else {
                    localFile = new File(wrapper.getFile());
                }
            } else {
                localFile = new File(wrapper.getFile());
            }
            final boolean added = isAdded(revision);
            final ContentRevision beforeRevision = added ? null : new CvsContentRevision(new File(wrapper.getFile()), localFile, new SimpleRevision(new CvsRevisionNumber(revision.getNumber()).getPrevNumber().asString()), myEnvironment, myProject);
            final ContentRevision afterRevision = (!added && DEAD_STATE.equals(state)) ? null : new CvsContentRevision(new File(wrapper.getFile()), localFile, new SimpleRevision(revision.getNumber()), myEnvironment, myProject);
            myChanges.add(new Change(beforeRevision, afterRevision));
        }
    }
    return myChanges;
}
Also used : ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) SimpleRevision(com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision) Revision(org.netbeans.lib.cvsclient.command.log.Revision) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) Change(com.intellij.openapi.vcs.changes.Change) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) CvsRevisionNumber(com.intellij.cvsSupport2.history.CvsRevisionNumber) SimpleRevision(com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision)

Example 3 with SimpleRevision

use of com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision in project intellij-community by JetBrains.

the class CommandCvsHandler method createRestoreFileHandler.

public static CvsHandler createRestoreFileHandler(final VirtualFile parent, String name, boolean makeNewFilesReadOnly) {
    final File ioFile = new File(VfsUtilCore.virtualToIoFile(parent), name);
    final Entry entry = CvsEntriesManager.getInstance().getEntryFor(parent, name);
    final String revision = getRevision(entry);
    final CheckoutFileOperation operation = new CheckoutFileOperation(parent, new SimpleRevision(revision), name, makeNewFilesReadOnly);
    final CommandCvsHandler cvsHandler = new CommandCvsHandler(CvsBundle.message("operation.name.restore"), operation, FileSetToBeUpdated.EMPTY);
    operation.addFinishAction(() -> {
        final List<VcsException> errors = cvsHandler.getErrors();
        if (errors != null && !errors.isEmpty())
            return;
        if (entry != null) {
            entry.setRevision(revision);
            entry.setConflict(CvsUtil.formatDate(new Date(ioFile.lastModified())));
            try {
                CvsUtil.saveEntryForFile(ioFile, entry);
            } catch (IOException e) {
                LOG.error(e);
            }
            CvsEntriesManager.getInstance().clearCachedEntriesFor(parent);
        }
    });
    return cvsHandler;
}
Also used : Entry(org.netbeans.lib.cvsclient.admin.Entry) CheckoutFileOperation(com.intellij.cvsSupport2.cvsoperations.cvsCheckOut.CheckoutFileOperation) VcsException(com.intellij.openapi.vcs.VcsException) IOException(java.io.IOException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) CvsLightweightFile(com.intellij.cvsSupport2.actions.cvsContext.CvsLightweightFile) File(java.io.File) SimpleRevision(com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision)

Example 4 with SimpleRevision

use of com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision in project intellij-community by JetBrains.

the class CvsServicesImpl method createCvsVersionOn.

private static ComparableVcsRevisionOnOperation createCvsVersionOn(CvsModule module, Project project) {
    final CvsRootConfiguration rootConfiguration = CvsApplicationLevelConfiguration.getInstance().getConfigurationForCvsRoot(module.getRepository().getStringRepresentation());
    CvsConnectionSettings env = new IDEARootFormatter(rootConfiguration).createConfiguration();
    GetFileContentOperation operation = new GetFileContentOperation(new File(module.getPathInCvs()), env, new SimpleRevision(module.getRevision()));
    return new ComparableVcsRevisionOnOperation(operation, project);
}
Also used : GetFileContentOperation(com.intellij.cvsSupport2.cvsoperations.cvsContent.GetFileContentOperation) CvsConnectionSettings(com.intellij.cvsSupport2.connections.CvsConnectionSettings) ComparableVcsRevisionOnOperation(com.intellij.cvsSupport2.history.ComparableVcsRevisionOnOperation) File(java.io.File) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) CvsRootConfiguration(com.intellij.cvsSupport2.config.CvsRootConfiguration) IDEARootFormatter(com.intellij.cvsSupport2.connections.IDEARootFormatter) SimpleRevision(com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision)

Example 5 with SimpleRevision

use of com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision in project intellij-community by JetBrains.

the class CvsDiffProvider method createFileContent.

public ContentRevision createFileContent(final VcsRevisionNumber revisionNumber, VirtualFile selectedFile) {
    if ((revisionNumber instanceof CvsRevisionNumber)) {
        final CvsConnectionSettings settings = CvsEntriesManager.getInstance().getCvsConnectionSettingsFor(selectedFile.getParent());
        final File file = new File(CvsUtil.getModuleName(selectedFile));
        final CvsRevisionNumber cvsRevisionNumber = ((CvsRevisionNumber) revisionNumber);
        final RevisionOrDate versionInfo;
        if (cvsRevisionNumber.getDateOrRevision() != null) {
            versionInfo = RevisionOrDateImpl.createOn(cvsRevisionNumber.getDateOrRevision());
        } else {
            versionInfo = new SimpleRevision(cvsRevisionNumber.asString());
        }
        if (selectedFile.getFileType().isBinary()) {
            return new CvsBinaryContentRevision(file, file, versionInfo, settings, myProject);
        } else {
            return new CvsContentRevision(file, file, versionInfo, settings, myProject);
        }
    } else {
        return null;
    }
}
Also used : CvsContentRevision(com.intellij.cvsSupport2.changeBrowser.CvsContentRevision) CvsConnectionSettings(com.intellij.cvsSupport2.connections.CvsConnectionSettings) CvsBinaryContentRevision(com.intellij.cvsSupport2.changeBrowser.CvsBinaryContentRevision) RevisionOrDate(com.intellij.cvsSupport2.cvsoperations.dateOrRevision.RevisionOrDate) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) CvsRevisionNumber(com.intellij.cvsSupport2.history.CvsRevisionNumber) SimpleRevision(com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision)

Aggregations

SimpleRevision (com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision)5 File (java.io.File)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 CvsConnectionSettings (com.intellij.cvsSupport2.connections.CvsConnectionSettings)2 GetFileContentOperation (com.intellij.cvsSupport2.cvsoperations.cvsContent.GetFileContentOperation)2 CvsRevisionNumber (com.intellij.cvsSupport2.history.CvsRevisionNumber)2 VcsVirtualFile (com.intellij.openapi.vcs.vfs.VcsVirtualFile)2 IOException (java.io.IOException)2 CvsLightweightFile (com.intellij.cvsSupport2.actions.cvsContext.CvsLightweightFile)1 CvsBinaryContentRevision (com.intellij.cvsSupport2.changeBrowser.CvsBinaryContentRevision)1 CvsContentRevision (com.intellij.cvsSupport2.changeBrowser.CvsContentRevision)1 CvsRootConfiguration (com.intellij.cvsSupport2.config.CvsRootConfiguration)1 IDEARootFormatter (com.intellij.cvsSupport2.connections.IDEARootFormatter)1 CvsOperationExecutor (com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutor)1 CommandCvsHandler (com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler)1 CheckoutFileOperation (com.intellij.cvsSupport2.cvsoperations.cvsCheckOut.CheckoutFileOperation)1 RevisionOrDate (com.intellij.cvsSupport2.cvsoperations.dateOrRevision.RevisionOrDate)1 ComparableVcsRevisionOnOperation (com.intellij.cvsSupport2.history.ComparableVcsRevisionOnOperation)1 VcsException (com.intellij.openapi.vcs.VcsException)1 Change (com.intellij.openapi.vcs.changes.Change)1