Search in sources :

Example 1 with Entry

use of com.intellij.history.core.tree.Entry in project intellij-community by JetBrains.

the class IdeaGateway method doCreateChildrenForPathOnly.

private void doCreateChildrenForPathOnly(@NotNull DirectoryEntry parent, @NotNull String path, @NotNull Iterable<VirtualFile> children) {
    for (VirtualFile child : children) {
        // on Mac FS root name is "/"
        String name = StringUtil.trimStart(child.getName(), "/");
        if (!path.startsWith(name))
            continue;
        String rest = path.substring(name.length());
        if (!rest.isEmpty() && rest.charAt(0) != '/')
            continue;
        if (!rest.isEmpty() && rest.charAt(0) == '/') {
            rest = rest.substring(1);
        }
        Entry e = doCreateEntryForPathOnly(child, rest);
        if (e == null)
            continue;
        parent.addChild(e);
    }
}
Also used : NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) Entry(com.intellij.history.core.tree.Entry) RootEntry(com.intellij.history.core.tree.RootEntry) FileEntry(com.intellij.history.core.tree.FileEntry) DirectoryEntry(com.intellij.history.core.tree.DirectoryEntry) VirtualFileSystemEntry(com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry)

Example 2 with Entry

use of com.intellij.history.core.tree.Entry in project intellij-community by JetBrains.

the class DifferenceReverter method getFilesToClearROStatus.

@Override
protected List<VirtualFile> getFilesToClearROStatus() throws IOException {
    LinkedHashSet<VirtualFile> files = new LinkedHashSet<>();
    for (Difference each : myDiffs) {
        Entry l = each.getLeft();
        Entry r = each.getRight();
        VirtualFile f = l == null ? null : myGateway.findVirtualFile(l.getPath());
        if (f != null)
            files.add(f);
        f = r == null ? null : myGateway.findVirtualFile(r.getPath());
        if (f != null)
            files.add(f);
    }
    return new ArrayList<>(files);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) VirtualFile(com.intellij.openapi.vfs.VirtualFile) Entry(com.intellij.history.core.tree.Entry) ArrayList(java.util.ArrayList) Difference(com.intellij.history.core.revisions.Difference)

Example 3 with Entry

use of com.intellij.history.core.tree.Entry in project intellij-community by JetBrains.

the class UndoChangeRevertingVisitor method revertDeletion.

private void revertDeletion(VirtualFile parent, Entry e) throws IOException {
    VirtualFile f = myGateway.findOrCreateFileSafely(parent, e.getName(), e.isDirectory());
    if (e.isDirectory()) {
        for (Entry child : e.getChildren()) revertDeletion(f, child);
    } else {
        registerDelayedContentApply(f, e.getContent(), e.getTimestamp());
        registerDelayedROStatusApply(f, e.isReadOnly());
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Entry(com.intellij.history.core.tree.Entry)

Example 4 with Entry

use of com.intellij.history.core.tree.Entry in project intellij-community by JetBrains.

the class LocalHistoryFacade method getByteContentBefore.

private ByteContent getByteContentBefore(RootEntry root, String path, Change change) {
    root = root.copy();
    String newPath = revertUpTo(root, path, null, change, false, false);
    Entry entry = root.findEntry(newPath);
    if (entry == null)
        return new ByteContent(false, null);
    if (entry.isDirectory())
        return new ByteContent(true, null);
    return new ByteContent(false, entry.getContent().getBytesIfAvailable());
}
Also used : RootEntry(com.intellij.history.core.tree.RootEntry) Entry(com.intellij.history.core.tree.Entry) ByteContent(com.intellij.history.ByteContent)

Example 5 with Entry

use of com.intellij.history.core.tree.Entry in project intellij-community by JetBrains.

the class CreateEntryChange method revertOn.

@Override
public void revertOn(RootEntry root, boolean warnOnFileNotFound) {
    Entry e = root.findEntry(myPath);
    if (e == null) {
        cannotRevert(myPath, warnOnFileNotFound);
        return;
    }
    removeEntry(e);
}
Also used : Entry(com.intellij.history.core.tree.Entry) RootEntry(com.intellij.history.core.tree.RootEntry)

Aggregations

Entry (com.intellij.history.core.tree.Entry)37 RootEntry (com.intellij.history.core.tree.RootEntry)25 FileEntry (com.intellij.history.core.tree.FileEntry)12 Test (org.junit.Test)12 DirectoryEntry (com.intellij.history.core.tree.DirectoryEntry)11 VirtualFile (com.intellij.openapi.vfs.VirtualFile)7 Revision (com.intellij.history.core.revisions.Revision)5 StoredContent (com.intellij.history.core.StoredContent)4 Difference (com.intellij.history.core.revisions.Difference)3 NewVirtualFile (com.intellij.openapi.vfs.newvfs.NewVirtualFile)2 ByteContent (com.intellij.history.ByteContent)1 Content (com.intellij.history.core.Content)1 Change (com.intellij.history.core.changes.Change)1 DeleteChange (com.intellij.history.core.changes.DeleteChange)1 StructuralChange (com.intellij.history.core.changes.StructuralChange)1 SelectionCalculator (com.intellij.history.integration.ui.models.SelectionCalculator)1 VirtualFileSystemEntry (com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry)1 THashSet (gnu.trove.THashSet)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1