Search in sources :

Example 1 with CvsRevisionNumber

use of com.intellij.cvsSupport2.history.CvsRevisionNumber in project intellij-community by JetBrains.

the class UpdatedFilesProcessor method addFileMessage.

public void addFileMessage(FileMessage message) {
    String path = message.getFileAbsolutePath();
    VirtualFile virtualFile = getVirtualFileFor(path);
    final int messageType = message.getType();
    if (virtualFile != null && messageType == FileMessage.NOT_IN_REPOSITORY && FileTypeManager.getInstance().isFileIgnored(virtualFile)) {
        return;
    }
    FileGroup collection = getCollectionFor(messageType, virtualFile);
    LOG.assertTrue(collection != null, String.valueOf(messageType));
    final CvsRevisionNumber revision = message.getRevision();
    collection.add(path, CvsVcs2.getKey(), revision);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileGroup(com.intellij.openapi.vcs.update.FileGroup) CvsRevisionNumber(com.intellij.cvsSupport2.history.CvsRevisionNumber)

Example 2 with CvsRevisionNumber

use of com.intellij.cvsSupport2.history.CvsRevisionNumber 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 CvsRevisionNumber

use of com.intellij.cvsSupport2.history.CvsRevisionNumber in project intellij-community by JetBrains.

the class CvsChangeListsBuilder method getBranchName.

@Nullable
private static String getBranchName(final Revision revision, final List<SymbolicName> symbolicNames) {
    final CvsRevisionNumber number = new CvsRevisionNumber(revision.getNumber().trim());
    final int[] subRevisions = number.getSubRevisions();
    String branchNumberString = null;
    if (subRevisions != null && subRevisions.length >= 4) {
        final int branchRevNumber = subRevisions[subRevisions.length - 2];
        final CvsRevisionNumber branchNumber = number.removeTailVersions(2).addTailVersions(0, branchRevNumber);
        branchNumberString = branchNumber.asString();
    }
    if (branchNumberString == null) {
        final String branches = revision.getBranches();
        if (branches != null && branches.length() > 0) {
            final String[] branchNames = branches.split(";");
            final CvsRevisionNumber revisionNumber = new CvsRevisionNumber(branchNames[0].trim());
            final int[] branchSubRevisions = revisionNumber.getSubRevisions();
            assert branchSubRevisions != null;
            final int rev = branchSubRevisions[branchSubRevisions.length - 1];
            final CvsRevisionNumber branchNumber = revisionNumber.removeTailVersions(1).addTailVersions(0, rev);
            branchNumberString = branchNumber.asString();
        }
    }
    if (branchNumberString != null) {
        for (SymbolicName name : symbolicNames) {
            if (name.getRevision().equals(branchNumberString)) {
                return name.getName();
            }
        }
    }
    return null;
}
Also used : SymbolicName(org.netbeans.lib.cvsclient.command.log.SymbolicName) CvsRevisionNumber(com.intellij.cvsSupport2.history.CvsRevisionNumber) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with CvsRevisionNumber

use of com.intellij.cvsSupport2.history.CvsRevisionNumber in project intellij-community by JetBrains.

the class StickyHeadGetter method getBranchHeadRevision.

@Nullable
protected String getBranchHeadRevision(final VirtualFile parent, final String name, final Convertor<CvsRevisionNumber, Boolean> chooser) {
    final LocalPathIndifferentLogOperation operation = new LocalPathIndifferentLogOperation(new File(parent.getPath(), name));
    final Ref<Boolean> logSuccess = new Ref<>(Boolean.TRUE);
    final CvsExecutionEnvironment cvsExecutionEnvironment = new CvsExecutionEnvironment(new CvsMessagesAdapter(), CvsExecutionEnvironment.DUMMY_STOPPER, new ErrorProcessor() {

        public void addError(VcsException ex) {
            logSuccess.set(Boolean.FALSE);
        }

        public List<VcsException> getErrors() {
            return null;
        }
    }, PostCvsActivity.DEAF, myProject);
    try {
        // should already be logged in
        //operation.login(context);
        operation.execute(cvsExecutionEnvironment, false);
    } catch (VcsException | CommandAbortedException e) {
    //
    }
    if (Boolean.TRUE.equals(logSuccess.get())) {
        return extractRevision(operation, chooser);
    }
    return null;
}
Also used : ErrorProcessor(com.intellij.cvsSupport2.cvsoperations.cvsErrors.ErrorProcessor) Ref(com.intellij.openapi.util.Ref) LocalPathIndifferentLogOperation(com.intellij.cvsSupport2.cvsoperations.cvsLog.LocalPathIndifferentLogOperation) CvsExecutionEnvironment(com.intellij.cvsSupport2.cvsoperations.common.CvsExecutionEnvironment) CommandAbortedException(org.netbeans.lib.cvsclient.command.CommandAbortedException) VcsException(com.intellij.openapi.vcs.VcsException) CvsMessagesAdapter(com.intellij.cvsSupport2.cvsoperations.cvsMessages.CvsMessagesAdapter) List(java.util.List) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with CvsRevisionNumber

use of com.intellij.cvsSupport2.history.CvsRevisionNumber in project intellij-community by JetBrains.

the class TagsHelper method collectSortedRevisionsNames.

private static Collection<String> collectSortedRevisionsNames(Collection<CvsRevisionNumber> revisions) {
    if (revisions == null)
        return new ArrayList<>();
    final ArrayList<CvsRevisionNumber> list = new ArrayList<>(revisions);
    Collections.sort(list, (o, o1) -> o.compareTo(o1));
    final ArrayList<String> result = new ArrayList<>();
    for (final CvsRevisionNumber aList : list) {
        result.add(aList.toString());
    }
    return result;
}
Also used : CvsRevisionNumber(com.intellij.cvsSupport2.history.CvsRevisionNumber)

Aggregations

CvsRevisionNumber (com.intellij.cvsSupport2.history.CvsRevisionNumber)10 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 Nullable (org.jetbrains.annotations.Nullable)4 File (java.io.File)3 SimpleRevision (com.intellij.cvsSupport2.cvsoperations.dateOrRevision.SimpleRevision)2 CvsBinaryContentRevision (com.intellij.cvsSupport2.changeBrowser.CvsBinaryContentRevision)1 CvsContentRevision (com.intellij.cvsSupport2.changeBrowser.CvsContentRevision)1 CvsConnectionSettings (com.intellij.cvsSupport2.connections.CvsConnectionSettings)1 CvsExecutionEnvironment (com.intellij.cvsSupport2.cvsoperations.common.CvsExecutionEnvironment)1 ErrorProcessor (com.intellij.cvsSupport2.cvsoperations.cvsErrors.ErrorProcessor)1 LocalPathIndifferentLogOperation (com.intellij.cvsSupport2.cvsoperations.cvsLog.LocalPathIndifferentLogOperation)1 CvsMessagesAdapter (com.intellij.cvsSupport2.cvsoperations.cvsMessages.CvsMessagesAdapter)1 SelectTagDialog (com.intellij.cvsSupport2.cvsoperations.cvsTagOrBranch.ui.SelectTagDialog)1 RevisionOrDate (com.intellij.cvsSupport2.cvsoperations.dateOrRevision.RevisionOrDate)1 Ref (com.intellij.openapi.util.Ref)1 VcsException (com.intellij.openapi.vcs.VcsException)1 Change (com.intellij.openapi.vcs.changes.Change)1 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)1 ItemLatestState (com.intellij.openapi.vcs.diff.ItemLatestState)1 FileGroup (com.intellij.openapi.vcs.update.FileGroup)1