Search in sources :

Example 1 with CvsInfo

use of com.intellij.cvsSupport2.application.CvsInfo in project intellij-community by JetBrains.

the class CvsChangeProvider method checkSwitchedDir.

private void checkSwitchedDir(final VirtualFile dir, final ChangelistBuilder builder, final VcsDirtyScope scope, Collection<VirtualFile> cvsRoots) {
    final VirtualFile parentDir = dir.getParent();
    if (parentDir == null || cvsRoots.contains(dir) || !myVcsManager.isFileInContent(parentDir)) {
        return;
    }
    final CvsInfo info = myEntriesManager.getCvsInfoFor(dir);
    if (info.getRepository() == null) {
        if (info.getIgnoreFilter().shouldBeIgnored(dir)) {
            builder.processIgnoredFile(dir);
        } else {
            builder.processUnversionedFile(dir);
        }
        return;
    }
    final String dirTag = info.getStickyTag();
    final CvsInfo parentInfo = myEntriesManager.getCvsInfoFor(parentDir);
    final String parentDirTag = parentInfo.getStickyTag();
    if (!Comparing.equal(dirTag, parentDirTag)) {
        final String caption = getSwitchedTagCaption(dirTag, parentDirTag, true);
        if (caption != null) {
            builder.processSwitchedFile(dir, caption, true);
        }
    } else if (!scope.belongsTo(VcsContextFactory.SERVICE.getInstance().createFilePathOn(parentDir))) {
        // check if we're doing a partial refresh below a switched dir (IDEADEV-16611)
        final String parentBranch = myChangeListManager.getSwitchedBranch(parentDir);
        if (parentBranch != null) {
            builder.processSwitchedFile(dir, parentBranch, true);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CvsInfo(com.intellij.cvsSupport2.application.CvsInfo)

Example 2 with CvsInfo

use of com.intellij.cvsSupport2.application.CvsInfo in project intellij-community by JetBrains.

the class CvsChangeProvider method getDirectoryContent.

private static DirectoryContent getDirectoryContent(VirtualFile directory, final ProgressIndicator progress) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Retrieving directory content for " + directory);
    }
    final CvsInfo cvsInfo = CvsEntriesManager.getInstance().getCvsInfoFor(directory);
    final DirectoryContent result = new DirectoryContent(cvsInfo);
    final HashMap<String, VirtualFile> nameToFileMap = new HashMap<>();
    for (VirtualFile child : CvsVfsUtil.getChildrenOf(directory)) {
        nameToFileMap.put(child.getName(), child);
    }
    for (final Entry entry : cvsInfo.getEntries()) {
        progress.checkCanceled();
        final String fileName = entry.getFileName();
        if (entry.isDirectory()) {
            if (nameToFileMap.containsKey(fileName)) {
                final VirtualFile virtualFile = nameToFileMap.get(fileName);
                if (isInContent(virtualFile)) {
                    result.addDirectory(new VirtualFileEntry(virtualFile, entry));
                }
            } else if (!entry.isRemoved() && !FileTypeManager.getInstance().isFileIgnored(fileName)) {
                result.addDeletedDirectory(entry);
            }
        } else {
            if (nameToFileMap.containsKey(fileName) || entry.isRemoved()) {
                final VirtualFile virtualFile = nameToFileMap.get(fileName);
                if (isInContent(virtualFile)) {
                    result.addFile(new VirtualFileEntry(virtualFile, entry));
                }
            } else if (!entry.isAddedFile()) {
                result.addDeletedFile(entry);
            }
        }
        nameToFileMap.remove(fileName);
    }
    for (final String name : nameToFileMap.keySet()) {
        progress.checkCanceled();
        final VirtualFile unknown = nameToFileMap.get(name);
        if (unknown.isDirectory()) {
            if (isInContent(unknown)) {
                result.addUnknownDirectory(unknown);
            }
        } else {
            if (isInContent(unknown)) {
                final boolean isIgnored = result.getCvsInfo().getIgnoreFilter().shouldBeIgnored(unknown);
                if (isIgnored) {
                    result.addIgnoredFile(unknown);
                } else {
                    result.addUnknownFile(unknown);
                }
            }
        }
    }
    return result;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VirtualFileEntry(com.intellij.cvsSupport2.checkinProject.VirtualFileEntry) Entry(org.netbeans.lib.cvsclient.admin.Entry) HashMap(com.intellij.util.containers.HashMap) VirtualFileEntry(com.intellij.cvsSupport2.checkinProject.VirtualFileEntry) CvsInfo(com.intellij.cvsSupport2.application.CvsInfo) DirectoryContent(com.intellij.cvsSupport2.checkinProject.DirectoryContent)

Example 3 with CvsInfo

use of com.intellij.cvsSupport2.application.CvsInfo in project intellij-community by JetBrains.

the class CvsChangeProvider method checkTopLevelForBeingSwitched.

private void checkTopLevelForBeingSwitched(final VirtualFile dir, final ChangelistBuilder builder) {
    final CvsInfo info = myEntriesManager.getCvsInfoFor(dir);
    if (info.getRepository() == null)
        return;
    final String dirTag = info.getStickyTag();
    if (dirTag != null) {
        final String caption = getSwitchedTagCaption(dirTag, null, false);
        if (caption != null) {
            builder.processRootSwitch(dir, caption);
        }
    } else {
        builder.processRootSwitch(dir, CvsUtil.HEAD);
    }
}
Also used : CvsInfo(com.intellij.cvsSupport2.application.CvsInfo)

Example 4 with CvsInfo

use of com.intellij.cvsSupport2.application.CvsInfo in project intellij-community by JetBrains.

the class CvsUtil method restoreFile.

public static void restoreFile(final VirtualFile file) {
    CvsEntriesManager cvsEntriesManager = CvsEntriesManager.getInstance();
    VirtualFile directory = file == null ? null : file.getParent();
    LOG.assertTrue(directory != null);
    CvsInfo cvsInfo = cvsEntriesManager.getCvsInfoFor(directory);
    Entry entry = cvsInfo.getEntryNamed(file.getName());
    LOG.assertTrue(entry != null);
    String revision = entry.getRevision();
    LOG.assertTrue(StringUtil.startsWithChar(revision, '-'));
    String originalRevision = revision.substring(1);
    String date = Entry.formatLastModifiedDate(CvsStatusProvider.createDateDiffersTo(file.getTimeStamp()));
    String kwdSubstitution = entry.getOptions() == null ? "" : entry.getOptions();
    String stickyDataString = entry.getStickyData();
    Entry newEntry = Entry.createEntryForLine("/" + file.getName() + "/" + originalRevision + "/" + date + "/" + kwdSubstitution + "/" + stickyDataString);
    try {
        saveEntryForFile(CvsVfsUtil.getFileFor(file), newEntry);
        cvsEntriesManager.clearCachedEntriesFor(directory);
    } catch (final IOException e) {
        SwingUtilities.invokeLater(() -> Messages.showErrorDialog(CvsBundle.message("message.error.restore.entry", file.getPresentableUrl(), e.getLocalizedMessage()), CvsBundle.message("message.error.restore.entry.title")));
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Entry(org.netbeans.lib.cvsclient.admin.Entry) CvsEntriesManager(com.intellij.cvsSupport2.application.CvsEntriesManager) CvsInfo(com.intellij.cvsSupport2.application.CvsInfo) IOException(java.io.IOException)

Aggregations

CvsInfo (com.intellij.cvsSupport2.application.CvsInfo)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 Entry (org.netbeans.lib.cvsclient.admin.Entry)2 CvsEntriesManager (com.intellij.cvsSupport2.application.CvsEntriesManager)1 DirectoryContent (com.intellij.cvsSupport2.checkinProject.DirectoryContent)1 VirtualFileEntry (com.intellij.cvsSupport2.checkinProject.VirtualFileEntry)1 HashMap (com.intellij.util.containers.HashMap)1 IOException (java.io.IOException)1