use of org.opensolaris.opengrok.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class Repository method createCache.
/**
* Create a history log cache for all files in this repository.
* {@code getHistory()} is used to fetch the history for the entire
* repository. If {@code hasHistoryForDirectories()} returns {@code false},
* this method is a no-op.
*
* @param cache the cache instance in which to store the history log
* @param sinceRevision if non-null, incrementally update the cache with all
* revisions after the specified revision; otherwise, create the full
* history starting with the initial revision
*
* @throws HistoryException on error
*/
final void createCache(HistoryCache cache, String sinceRevision) throws HistoryException {
if (!isWorking()) {
return;
}
// this way. Just give up and return.
if (!hasHistoryForDirectories()) {
LOGGER.log(Level.INFO, "Skipping creation of history cache for {0}, since retrieval " + "of history for directories is not implemented for this " + "repository type.", getDirectoryName());
return;
}
File directory = new File(getDirectoryName());
History history;
try {
history = getHistory(directory, sinceRevision);
} catch (HistoryException he) {
if (sinceRevision == null) {
// Failed to get full history, so fail.
throw he;
}
// Failed to get partial history. This may have been caused
// by changes in the revision numbers since the last update
// (bug #14724) so we'll try to regenerate the cache from
// scratch instead.
LOGGER.log(Level.INFO, "Failed to get partial history. Attempting to " + "recreate the history cache from scratch.", he);
history = null;
}
if (sinceRevision != null && history == null) {
// Failed to get partial history, now get full history instead.
history = getHistory(directory);
// Got full history successfully. Clear the history cache so that
// we can recreate it from scratch.
cache.clear(this);
}
// We need to refresh list of tags for incremental reindex.
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
if (env.isTagsEnabled() && this.hasFileBasedTags()) {
this.buildTagList(new File(this.directoryName));
}
if (history != null) {
cache.store(history, this);
}
}
use of org.opensolaris.opengrok.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class IndexerTest method testIncrementalIndexAddRemoveFile.
@Test
public void testIncrementalIndexAddRemoveFile() throws Exception {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
env.setCtags(System.getProperty(ctagsProperty, "ctags"));
env.setSourceRoot(repository.getSourceRoot());
env.setDataRoot(repository.getDataRoot());
if (env.validateExuberantCtags()) {
Project project = new Project();
String ppath = "bug3430";
project.setPath("/" + ppath);
IndexDatabase idb = new IndexDatabase(project);
assertNotNull(idb);
MyIndexChangeListener listener = new MyIndexChangeListener();
idb.addIndexChangedListener(listener);
idb.update();
assertEquals(1, listener.files.size());
listener.reset();
repository.addDummyFile(ppath);
idb.update();
assertEquals("No new file added", 1, listener.files.size());
repository.removeDummyFile(ppath);
idb.update();
assertEquals("Didn't remove the dummy file", 0, listener.files.size());
assertEquals("Didn't remove the dummy file", 1, listener.removedFiles.size());
} else {
System.out.println("Skipping test. Could not find a ctags I could use in path.");
}
}
use of org.opensolaris.opengrok.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class IndexerTest method testIndexGeneration.
/**
* Test of doIndexerExecution method, of class Indexer.
* @throws java.lang.Exception
*/
@Test
public void testIndexGeneration() throws Exception {
System.out.println("Generating index by using the class methods");
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
env.setCtags(System.getProperty(ctagsProperty, "ctags"));
if (env.validateExuberantCtags()) {
env.setSourceRoot(repository.getSourceRoot());
env.setDataRoot(repository.getDataRoot());
env.setVerbose(true);
Indexer.getInstance().prepareIndexer(env, true, true, "/c", null, false, false, false, null, null, new ArrayList<>(), false);
Indexer.getInstance().doIndexerExecution(true, 1, null, null);
} else {
System.out.println("Skipping test. Could not find a ctags I could use in path.");
}
}
use of org.opensolaris.opengrok.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class IndexDatabaseTest method setUpClass.
@BeforeClass
public static void setUpClass() throws Exception {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
assertTrue("No ctags available", env.validateExuberantCtags());
repository = new TestRepository();
repository.create(IndexDatabase.class.getResourceAsStream("source.zip"));
env.setSourceRoot(repository.getSourceRoot());
env.setDataRoot(repository.getDataRoot());
Indexer indexer = Indexer.getInstance();
indexer.prepareIndexer(env, true, true, "/c", null, false, false, false, null, null, new ArrayList<String>(), false);
indexer.doIndexerExecution(true, 1, null, null);
}
use of org.opensolaris.opengrok.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class IndexerTest method testBug3430.
@Test
public void testBug3430() throws Exception {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
env.setCtags(System.getProperty(ctagsProperty, "ctags"));
env.setSourceRoot(repository.getSourceRoot());
env.setDataRoot(repository.getDataRoot());
if (env.validateExuberantCtags()) {
Project project = new Project();
project.setPath("/bug3430");
IndexDatabase idb = new IndexDatabase(project);
assertNotNull(idb);
MyIndexChangeListener listener = new MyIndexChangeListener();
idb.addIndexChangedListener(listener);
idb.update();
assertEquals(1, listener.files.size());
} else {
System.out.println("Skipping test. Could not find a ctags I could use in path.");
}
}
Aggregations