Search in sources :

Example 1 with Revision

use of org.netbeans.lib.cvsclient.command.log.Revision in project intellij-community by JetBrains.

the class CvsHistoryProvider method createRevisions.

private List<VcsFileRevision> createRevisions(final CvsEnvironment connectionSettings, final File lightweightFileForFile) {
    final LocalPathIndifferentLogOperation logOperation = new LocalPathIndifferentLogOperation(connectionSettings);
    logOperation.addFile(lightweightFileForFile);
    final CvsOperationExecutor executor = new CvsOperationExecutor(myProject);
    final ArrayList<VcsFileRevision> result = new ArrayList<>();
    executor.performActionSync(new CommandCvsHandler(CvsBundle.message("operation.name.load.file.content"), logOperation), new DefaultCvsOperationExecutorCallback() {

        @Override
        public void executionFinishedSuccessfully() {
            final LogInformation firstLogInformation = logOperation.getFirstLogInformation();
            if (firstLogInformation != null) {
                final List<Revision> revisionList = firstLogInformation.getRevisionList();
                for (Revision revision : revisionList) {
                    result.add(new CvsFileRevisionImpl(revision, lightweightFileForFile, firstLogInformation, connectionSettings, myProject));
                }
            }
        }
    });
    Collections.sort(result, Collections.reverseOrder(VcsFileRevisionComparator.INSTANCE));
    return result;
}
Also used : LocalPathIndifferentLogOperation(com.intellij.cvsSupport2.cvsoperations.cvsLog.LocalPathIndifferentLogOperation) Revision(org.netbeans.lib.cvsclient.command.log.Revision) CvsOperationExecutor(com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutor) LogInformation(org.netbeans.lib.cvsclient.command.log.LogInformation) DefaultCvsOperationExecutorCallback(com.intellij.cvsSupport2.cvsExecution.DefaultCvsOperationExecutorCallback) CvsChangeList(com.intellij.cvsSupport2.changeBrowser.CvsChangeList) List(java.util.List) CommandCvsHandler(com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler)

Example 2 with Revision

use of org.netbeans.lib.cvsclient.command.log.Revision 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 Revision

use of org.netbeans.lib.cvsclient.command.log.Revision in project intellij-community by JetBrains.

the class CvsCommittedChangesProvider method getOneList.

@Nullable
@Override
public Pair<CvsChangeList, FilePath> getOneList(VirtualFile file, final VcsRevisionNumber number) throws VcsException {
    final File ioFile = new File(file.getPath());
    final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(ioFile);
    final VirtualFile vcsRoot = ProjectLevelVcsManager.getInstance(myProject).getVcsRootFor(filePath);
    final CvsRepositoryLocation cvsLocation = getLocationFor(filePath);
    if (cvsLocation == null)
        return null;
    final String module = CvsUtil.getModuleName(vcsRoot);
    final CvsEnvironment connectionSettings = cvsLocation.getEnvironment();
    if (connectionSettings.isOffline()) {
        return null;
    }
    final CvsChangeListsBuilder builder = new CvsChangeListsBuilder(module, connectionSettings, myProject, vcsRoot);
    final Ref<CvsChangeList> result = new Ref<>();
    final LoadHistoryOperation operation = new LoadHistoryOperation(connectionSettings, wrapper -> {
        final List<Revision> revisions = wrapper.getRevisions();
        if (revisions.isEmpty())
            return;
        final RevisionWrapper revision = new RevisionWrapper(wrapper.getFile(), revisions.get(0), null);
        result.set(builder.addRevision(revision));
    }, cvsLocation.getModuleName(), number.asString());
    final CvsResult executionResult = operation.run(myProject);
    if (executionResult.isCanceled()) {
        throw new ProcessCanceledException();
    } else if (executionResult.hasErrors()) {
        throw executionResult.composeError();
    }
    if (result.isNull()) {
        return null;
    }
    final Date commitDate = result.get().getCommitDate();
    final CvsEnvironment rootConnectionSettings = CvsEntriesManager.getInstance().getCvsConnectionSettingsFor(vcsRoot);
    final long t = commitDate.getTime();
    final Date dateFrom = new Date(t - CvsChangeList.SUITABLE_DIFF);
    final Date dateTo = new Date(t + CvsChangeList.SUITABLE_DIFF);
    final LoadHistoryOperation operation2 = new LoadHistoryOperation(rootConnectionSettings, module, dateFrom, dateTo, wrapper -> {
        final List<RevisionWrapper> wrappers = builder.revisionWrappersFromLog(wrapper);
        if (wrappers != null) {
            for (RevisionWrapper revisionWrapper : wrappers) {
                if (result.get().containsFileRevision(revisionWrapper)) {
                    continue;
                }
                builder.addRevision(revisionWrapper);
            }
        }
    });
    final CvsResult cvsResult = operation2.run(myProject);
    if (cvsResult.hasErrors()) {
        throw cvsResult.composeError();
    }
    return Pair.create(result.get(), filePath);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CvsResult(com.intellij.openapi.cvsIntegration.CvsResult) Ref(com.intellij.openapi.util.Ref) Revision(org.netbeans.lib.cvsclient.command.log.Revision) CvsEnvironment(com.intellij.cvsSupport2.connections.CvsEnvironment) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with Revision

use of org.netbeans.lib.cvsclient.command.log.Revision in project intellij-community by JetBrains.

the class RevisionWrapper method readFromStream.

public static RevisionWrapper readFromStream(final DataInput stream) throws IOException {
    final String file = stream.readUTF();
    final String number = stream.readUTF();
    final Revision revision = new Revision(number);
    final long time = stream.readLong();
    revision.setDate(new Date(time));
    revision.setAuthor(stream.readUTF());
    revision.setState(stream.readUTF());
    final String lines = stream.readUTF();
    if (lines.length() > 0) {
        revision.setLines(lines);
    }
    revision.setMessage(stream.readUTF());
    final String branches = stream.readUTF();
    if (branches.length() > 0) {
        revision.setBranches(branches);
    }
    final String branch = stream.readUTF();
    return new RevisionWrapper(file, revision, branch.length() > 0 ? branch : null);
}
Also used : Revision(org.netbeans.lib.cvsclient.command.log.Revision) Date(java.util.Date)

Example 5 with Revision

use of org.netbeans.lib.cvsclient.command.log.Revision in project intellij-community by JetBrains.

the class CvsChangeListsBuilder method addRevision.

public CvsChangeList addRevision(RevisionWrapper revisionWrapper) {
    final Revision revision = revisionWrapper.getRevision();
    final CvsChangeList version = findOrCreateVersionFor(revision.getMessage(), revisionWrapper.getTime(), revision.getAuthor(), revisionWrapper.getBranch(), revisionWrapper.getFile());
    version.addFileRevision(revisionWrapper);
    return version;
}
Also used : Revision(org.netbeans.lib.cvsclient.command.log.Revision)

Aggregations

Revision (org.netbeans.lib.cvsclient.command.log.Revision)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 File (java.io.File)2 Nullable (org.jetbrains.annotations.Nullable)2 CvsChangeList (com.intellij.cvsSupport2.changeBrowser.CvsChangeList)1 CvsEnvironment (com.intellij.cvsSupport2.connections.CvsEnvironment)1 CvsOperationExecutor (com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutor)1 DefaultCvsOperationExecutorCallback (com.intellij.cvsSupport2.cvsExecution.DefaultCvsOperationExecutorCallback)1 CommandCvsHandler (com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler)1 LocalPathIndifferentLogOperation (com.intellij.cvsSupport2.cvsoperations.cvsLog.LocalPathIndifferentLogOperation)1 SimpleRevision (com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision)1 CvsRevisionNumber (com.intellij.cvsSupport2.history.CvsRevisionNumber)1 CvsResult (com.intellij.openapi.cvsIntegration.CvsResult)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 Ref (com.intellij.openapi.util.Ref)1 Change (com.intellij.openapi.vcs.changes.Change)1 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)1 Date (java.util.Date)1 List (java.util.List)1 LogInformation (org.netbeans.lib.cvsclient.command.log.LogInformation)1