Search in sources :

Example 1 with ChangeSet

use of com.intellij.history.core.changes.ChangeSet in project intellij-community by JetBrains.

the class ChangeList method iterChanges.

// todo synchronization issue: changeset may me modified while being iterated
public synchronized Iterable<ChangeSet> iterChanges() {
    return new Iterable<ChangeSet>() {

        public Iterator<ChangeSet> iterator() {
            return new Iterator<ChangeSet>() {

                private final TIntHashSet recursionGuard = new TIntHashSet(1000);

                private ChangeSetHolder currentBlock;

                private ChangeSet next = fetchNext();

                public boolean hasNext() {
                    return next != null;
                }

                public ChangeSet next() {
                    ChangeSet result = next;
                    next = fetchNext();
                    return result;
                }

                private ChangeSet fetchNext() {
                    if (currentBlock == null) {
                        synchronized (ChangeList.this) {
                            if (myCurrentChangeSet != null) {
                                currentBlock = new ChangeSetHolder(-1, myCurrentChangeSet);
                            } else {
                                currentBlock = myStorage.readPrevious(-1, recursionGuard);
                            }
                        }
                    } else {
                        synchronized (ChangeList.this) {
                            currentBlock = myStorage.readPrevious(currentBlock.id, recursionGuard);
                        }
                    }
                    if (currentBlock == null)
                        return null;
                    return currentBlock.changeSet;
                }

                public void remove() {
                    throw new UnsupportedOperationException();
                }
            };
        }
    };
}
Also used : Iterator(java.util.Iterator) ChangeSet(com.intellij.history.core.changes.ChangeSet) TIntHashSet(gnu.trove.TIntHashSet)

Example 2 with ChangeSet

use of com.intellij.history.core.changes.ChangeSet in project intellij-community by JetBrains.

the class ChangeSetsProcessor method process.

protected void process() {
    Pair<String, List<ChangeSet>> pathAndChanges = collectChanges();
    List<ChangeSet> changes = pathAndChanges.second;
    if (changes.isEmpty()) {
        nothingToVisit();
        return;
    }
    for (ChangeSet c : changes) {
        visit(c);
    }
}
Also used : List(java.util.List) ChangeSet(com.intellij.history.core.changes.ChangeSet)

Example 3 with ChangeSet

use of com.intellij.history.core.changes.ChangeSet in project intellij-community by JetBrains.

the class RevisionsTest method testAfterRevisionForRootEntry.

@Test
public void testAfterRevisionForRootEntry() {
    RootEntry root = new RootEntry();
    LocalHistoryFacade facade = new InMemoryLocalHistoryFacade();
    ChangeSet cs = addChangeSet(facade, createFile(root, "f1"));
    addChangeSet(facade, createFile(root, "f2"));
    Revision r = new ChangeRevision(facade, root, "", cs, false);
    RootEntry e = (RootEntry) r.findEntry();
    assertEquals(e.getClass(), RootEntry.class);
    assertNotNull(e.findEntry("f1"));
    assertNull(e.findEntry("f2"));
}
Also used : RootEntry(com.intellij.history.core.tree.RootEntry) InMemoryLocalHistoryFacade(com.intellij.history.core.InMemoryLocalHistoryFacade) LocalHistoryFacade(com.intellij.history.core.LocalHistoryFacade) InMemoryLocalHistoryFacade(com.intellij.history.core.InMemoryLocalHistoryFacade) ChangeSet(com.intellij.history.core.changes.ChangeSet) Test(org.junit.Test)

Example 4 with ChangeSet

use of com.intellij.history.core.changes.ChangeSet in project intellij-community by JetBrains.

the class ByteContentRetriever method collectChanges.

@Override
protected Pair<String, List<ChangeSet>> collectChanges() {
    final List<ChangeSet> result = new ArrayList<>();
    myVcs.accept(new ChangeVisitor() {

        @Override
        public void begin(ChangeSet c) throws StopVisitingException {
            if (c.affectsPath(myPath))
                result.add(c);
        }
    });
    return Pair.create(myPath, result);
}
Also used : ArrayList(java.util.ArrayList) ChangeVisitor(com.intellij.history.core.changes.ChangeVisitor) ChangeSet(com.intellij.history.core.changes.ChangeSet)

Example 5 with ChangeSet

use of com.intellij.history.core.changes.ChangeSet in project intellij-community by JetBrains.

the class PurgingTest method assertRemainedChangesTimestamps.

private void assertRemainedChangesTimestamps(long... tt) {
    assertEquals(tt.length, getVcs().getChangeListInTests().getChangesInTests().size());
    for (int i = 0; i < tt.length; i++) {
        long t = tt[i];
        ChangeSet c = getVcs().getChangeListInTests().getChangesInTests().get(i);
        assertEquals(t, c.getTimestamp());
    }
}
Also used : ChangeSet(com.intellij.history.core.changes.ChangeSet)

Aggregations

ChangeSet (com.intellij.history.core.changes.ChangeSet)5 InMemoryLocalHistoryFacade (com.intellij.history.core.InMemoryLocalHistoryFacade)1 LocalHistoryFacade (com.intellij.history.core.LocalHistoryFacade)1 ChangeVisitor (com.intellij.history.core.changes.ChangeVisitor)1 RootEntry (com.intellij.history.core.tree.RootEntry)1 TIntHashSet (gnu.trove.TIntHashSet)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Test (org.junit.Test)1