Search in sources :

Example 36 with Executor

use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.

the class MonotoneRepository method getHistoryLogExecutor.

/**
     * Get an executor to be used for retrieving the history log for the named
     * file or directory.
     *
     * @param file The file or directory to retrieve history for
     * @param sinceRevision the oldest changeset to return from the executor, or
     *                  {@code null} if all changesets should be returned
     * @return An Executor ready to be started
     */
Executor getHistoryLogExecutor(File file, String sinceRevision) throws IOException {
    String abs = file.getCanonicalPath();
    String filename = "";
    if (abs.length() > directoryName.length()) {
        filename = abs.substring(directoryName.length() + 1);
    }
    List<String> cmd = new ArrayList<>();
    ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
    cmd.add(RepoCommand);
    cmd.add("log");
    if (sinceRevision != null) {
        cmd.add("--to");
        cmd.add(sinceRevision);
    }
    cmd.add("--no-graph");
    cmd.add("--no-merges");
    cmd.add("--no-format-dates");
    cmd.add(filename);
    return new Executor(cmd, new File(directoryName), sinceRevision != null);
}
Also used : Executor(org.opensolaris.opengrok.util.Executor) ArrayList(java.util.ArrayList) File(java.io.File)

Example 37 with Executor

use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.

the class PerforceHistoryParser method parseDirectory.

private History parseDirectory(File file) throws IOException {
    ArrayList<String> cmd = new ArrayList<String>();
    cmd.add("p4");
    cmd.add("changes");
    cmd.add("-t");
    cmd.add("...");
    Executor executor = new Executor(cmd, file.getCanonicalFile());
    executor.exec();
    return parseChanges(executor.getOutputReader());
}
Also used : Executor(org.opensolaris.opengrok.util.Executor) ArrayList(java.util.ArrayList)

Example 38 with Executor

use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.

the class PerforceHistoryParser method getRevisions.

public static History getRevisions(File file, String rev) throws IOException {
    ArrayList<String> cmd = new ArrayList<String>();
    cmd.add("p4");
    cmd.add("filelog");
    cmd.add("-lti");
    cmd.add(file.getName() + PerforceRepository.getRevisionCmd(rev));
    Executor executor = new Executor(cmd, file.getCanonicalFile().getParentFile());
    executor.exec();
    return parseFileLog(executor.getOutputReader());
}
Also used : Executor(org.opensolaris.opengrok.util.Executor) ArrayList(java.util.ArrayList)

Example 39 with Executor

use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.

the class MercurialRepository method determineParent.

@Override
String determineParent() throws IOException {
    File directory = new File(directoryName);
    List<String> cmd = new ArrayList<>();
    ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
    cmd.add(RepoCommand);
    cmd.add("paths");
    cmd.add("default");
    Executor executor = new Executor(cmd, directory);
    if (executor.exec(false) != 0) {
        throw new IOException(executor.getErrorString());
    }
    return executor.getOutputString().trim();
}
Also used : Executor(org.opensolaris.opengrok.util.Executor) ArrayList(java.util.ArrayList) IOException(java.io.IOException) File(java.io.File)

Example 40 with Executor

use of org.opensolaris.opengrok.util.Executor in project OpenGrok by OpenGrok.

the class MercurialRepository method determineBranch.

/**
     * Return name of the branch or "default"
     */
@Override
String determineBranch() throws IOException {
    List<String> cmd = new ArrayList<>();
    ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
    cmd.add(RepoCommand);
    cmd.add("branch");
    Executor executor = new Executor(cmd, new File(directoryName));
    if (executor.exec(false) != 0) {
        throw new IOException(executor.getErrorString());
    }
    return executor.getOutputString().trim();
}
Also used : Executor(org.opensolaris.opengrok.util.Executor) ArrayList(java.util.ArrayList) IOException(java.io.IOException) File(java.io.File)

Aggregations

Executor (org.opensolaris.opengrok.util.Executor)56 ArrayList (java.util.ArrayList)43 File (java.io.File)33 IOException (java.io.IOException)33 BufferedReader (java.io.BufferedReader)6 InputStream (java.io.InputStream)4 Properties (java.util.Properties)4 Matcher (java.util.regex.Matcher)4 BufferedInputStream (java.io.BufferedInputStream)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 Date (java.util.Date)2 RuntimeEnvironment (org.opensolaris.opengrok.configuration.RuntimeEnvironment)2 FileInputStream (java.io.FileInputStream)1 FileReader (java.io.FileReader)1 ParseException (java.text.ParseException)1 HashMap (java.util.HashMap)1 Scanner (java.util.Scanner)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1