use of com.intellij.history.core.changes.Change in project intellij-community by JetBrains.
the class FileListeningTest method testDeletionDoesNotVersionIgnoredFilesRecursively.
public void testDeletionDoesNotVersionIgnoredFilesRecursively() throws Exception {
String dir1 = createDirectoryExternally("dir");
createFileExternally("dir/f.txt");
createFileExternally("dir/f.class");
createFileExternally("dir/subdir/f.txt");
createDirectoryExternally("dir/subdir/subdir2");
createFileExternally("dir/subdir/subdir2/f.txt");
LocalFileSystem.getInstance().refresh(false);
addExcludedDir(myRoot.getPath() + "/dir/subdir");
addContentRoot(myRoot.getPath() + "/dir/subdir/subdir2");
final VirtualFile vDir1 = LocalFileSystem.getInstance().findFileByPath(dir1);
assertNotNull(dir1, vDir1);
delete(vDir1);
List<Change> changes = getVcs().getChangeListInTests().getChangesInTests().get(0).getChanges();
assertEquals(1, changes.size());
Entry e = ((DeleteChange) changes.get(0)).getDeletedEntry();
final List<Entry> children = e.getChildren();
sortEntries(children);
assertEquals(2, children.size());
assertEquals("f.txt", children.get(0).getName());
assertEquals("subdir", children.get(1).getName());
assertEquals(1, children.get(1).getChildren().size());
assertEquals("subdir2", children.get(1).getChildren().get(0).getName());
}
use of com.intellij.history.core.changes.Change in project intellij-community by JetBrains.
the class ChangeRange method revert.
public ChangeRange revert(ChangeRange reverse) throws IOException {
final Ref<Long> first = new Ref<>();
final Ref<Long> last = new Ref<>();
LocalHistoryFacade.Listener l = new LocalHistoryFacade.Listener() {
public void changeAdded(Change c) {
if (first.isNull())
first.set(c.getId());
last.set(c.getId());
}
};
myVcs.addListener(l, null);
try {
myVcs.accept(new UndoChangeRevertingVisitor(myGateway, myToChangeId, myFromChangeId));
} catch (UndoChangeRevertingVisitor.RuntimeIOException e) {
throw (IOException) e.getCause();
} finally {
myVcs.removeListener(l);
}
if (reverse != null) {
if (first.isNull())
first.set(reverse.myFromChangeId);
if (last.isNull())
last.set(reverse.myToChangeId);
}
return new ChangeRange(myGateway, myVcs, first.get(), last.get());
}
use of com.intellij.history.core.changes.Change in project intellij-community by JetBrains.
the class ByteContentRetriever method recordContentAndTimestamp.
private void recordContentAndTimestamp(ChangeSet c) {
// todo what if the path is being changed during changes?
for (Change each : c.getChanges()) {
if (!(each instanceof ContentChange))
continue;
ContentChange cc = (ContentChange) each;
if (!cc.affectsPath(myPath))
continue;
myCurrentFileTimestamp = cc.getOldTimestamp();
myCurrentFileContent = cc.getOldContent();
}
}
use of com.intellij.history.core.changes.Change in project intellij-community by JetBrains.
the class FileListeningTest method testIgnoringFilesRecursively.
public void testIgnoringFilesRecursively() throws Exception {
addExcludedDir(myRoot.getPath() + "/dir/subdir");
addContentRoot(createModule("foo"), myRoot.getPath() + "/dir/subdir/subsubdir1");
String dir = createDirectoryExternally("dir");
String dir1_file = createFileExternally("dir/f.txt");
createFileExternally("dir/f.class");
createFileExternally("dir/subdir/f.txt");
String subsubdir1 = createDirectoryExternally("dir/subdir/subsubdir1");
String subsubdir1_file = createFileExternally("dir/subdir/subsubdir1/f.txt");
createDirectoryExternally("dir/subdir/subsubdir2");
createFileExternally("dir/subdir/subsubdir2/f.txt");
myRoot.refresh(false, true);
List<Change> changes = getVcs().getChangeListInTests().getChangesInTests().get(0).getChanges();
List<String> actual = new SmartList<>();
for (Change each : changes) {
actual.add(((StructuralChange) each).getPath());
}
List<String> expected = new ArrayList<>(Arrays.asList(dir, subsubdir1, dir1_file, subsubdir1_file));
Collections.sort(actual);
Collections.sort(expected);
assertOrderedEquals(actual, expected);
// ignored folders should not be loaded in VFS
assertEquals("dir\n" + " f.class\n" + " f.txt\n" + " subdir\n" + " subsubdir1\n" + " f.txt\n", buildDBFileStructure(myRoot, 0, new StringBuilder()).toString());
}
Aggregations