use of org.opengrok.indexer.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class IndexDatabaseTest method checkDataExistence.
private void checkDataExistence(String fileName, boolean shouldExist) {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
for (String dirName : new String[] { "historycache", IndexDatabase.XREF_DIR }) {
File dataDir = new File(env.getDataRootFile(), dirName);
File dataFile = new File(dataDir, TandemPath.join(fileName, ".gz"));
if (shouldExist) {
assertTrue(dataFile.exists(), "file " + fileName + " not found in " + dirName);
} else {
assertFalse(dataFile.exists(), "file " + fileName + " found in " + dirName);
}
}
}
use of org.opengrok.indexer.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class IndexDatabaseTest method setUpClass.
@BeforeAll
public static void setUpClass() throws Exception {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
repository = new TestRepository();
repository.create(HistoryGuru.class.getResource("/repositories"));
env.setSourceRoot(repository.getSourceRoot());
env.setDataRoot(repository.getDataRoot());
env.setHistoryEnabled(true);
env.setProjectsEnabled(true);
RepositoryFactory.initializeIgnoredNames(env);
// Note that all tests in this class share the index created below.
// Ergo, if they need to modify it, this has to be done in such a way
// so that it does not affect other tests, no matter in which order
// the tests are run.
Indexer indexer = Indexer.getInstance();
indexer.prepareIndexer(env, true, true, false, null, null);
env.setDefaultProjectsFromNames(new TreeSet<>(Arrays.asList("/c")));
indexer.doIndexerExecution(true, null, null);
}
use of org.opengrok.indexer.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class BitKeeperRepository method getHistory.
/**
* Construct a History for a file in this repository.
*
* @param file a file in the repository
* @param sinceRevision omit history from before, and including, this revision
* @return history a history object
*/
@Override
History getHistory(File file, String sinceRevision) throws HistoryException {
final File absolute = file.getAbsoluteFile();
final File directory = absolute.getParentFile();
final String basename = absolute.getName();
final ArrayList<String> argv = new ArrayList<>();
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
argv.add(RepoCommand);
argv.add("log");
if (sinceRevision != null) {
argv.add("-r" + sinceRevision + "..");
}
argv.add("-d" + LOG_DSPEC);
argv.add(basename);
final Executor executor = new Executor(argv, directory);
final BitKeeperHistoryParser parser = new BitKeeperHistoryParser(datePatterns[0]);
if (executor.exec(true, parser) != 0) {
throw new HistoryException(executor.getErrorString());
}
final RuntimeEnvironment env = RuntimeEnvironment.getInstance();
final History history = parser.getHistory();
// because we know it :-)
if (env.isTagsEnabled()) {
assignTagsInHistory(history);
}
return history;
}
use of org.opengrok.indexer.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class BitKeeperRepository method buildTagList.
/**
* Constructs a set of tags up front.
*
* @param directory the repository directory
* @param cmdType command timeout type
*/
@Override
public void buildTagList(File directory, CommandTimeoutType cmdType) {
final ArrayList<String> argv = new ArrayList<>();
argv.add("bk");
argv.add("tags");
argv.add("-d" + getTagDspec());
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
final Executor executor = new Executor(argv, directory, env.getCommandTimeout(cmdType));
final BitKeeperTagParser parser = new BitKeeperTagParser(datePatterns[0]);
int status = executor.exec(true, parser);
if (status != 0) {
LOGGER.log(Level.WARNING, "Failed to get tags for: \"{0}\" Exit code: {1}", new Object[] { directory.getAbsolutePath(), String.valueOf(status) });
} else {
tagList = parser.getEntries();
}
}
use of org.opengrok.indexer.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class PerforceRepository method isInP4Depot.
/**
* Check if a given file is in the depot.
*
* @param file The file to test
* @param cmdType command timeout type
* @return true if the given file is in the depot, false otherwise
*/
boolean isInP4Depot(File file, CommandTimeoutType cmdType) {
boolean status = false;
if (isWorking()) {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
ArrayList<String> cmd = new ArrayList<>();
String name = protectPerforceFilename(file.getName());
File dir = file.getParentFile();
if (file.isDirectory()) {
dir = file;
name = "*";
cmd.add(RepoCommand);
cmd.add("dirs");
cmd.add(name);
Executor executor = new Executor(cmd, dir, env.getCommandTimeout(cmdType));
executor.exec();
/* OUTPUT:
stdout: //depot_path/name
stderr: name - no such file(s).
*/
status = (executor.getOutputString().contains("//"));
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.log(Level.FINEST, "p4 status is {0} for {1}", new Object[] { status, file });
}
}
if (!status) {
cmd.clear();
cmd.add(RepoCommand);
cmd.add("files");
cmd.add(name);
Executor executor = new Executor(cmd, dir, env.getCommandTimeout(cmdType));
executor.exec();
/* OUTPUT:
stdout: //depot_path/name
stderr: name - no such file(s).
*/
status = (executor.getOutputString().contains("//"));
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.log(Level.FINEST, "p4 status is {0} for {1}", new Object[] { status, file });
}
}
}
return status;
}
Aggregations