Package org.opensolaris.opengrok.util

Examples of org.opensolaris.opengrok.util.Executor


       if (sinceRevision != null) {
           cmd.add("-r");
           cmd.add(sinceRevision + "..-1");
       }

       return new Executor(cmd, new File(getDirectoryName()));
    }
View Full Code Here


            cmd.add("-r");
            cmd.add(revision);
        }
        cmd.add(file.getName());

        Executor exec = new Executor(cmd, file.getParentFile());
        int status = exec.exec();

        if (status != 0) {
            OpenGrokLogger.getLogger().log(Level.WARNING,
                "Failed to get annotations for: \"{0}\" Exit code: {1}",
                new Object[]{file.getAbsolutePath(), String.valueOf(status)});
        }

        return parseAnnotation(exec.getOutputReader(), file.getName());
    }
View Full Code Here

        List<String> cmd = new ArrayList<String>();
        ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
        cmd.add(this.cmd);
        cmd.add("info");
        Executor executor = new Executor(cmd, directory);
        if (executor.exec() != 0) {
            throw new IOException(executor.getErrorString());
        }

        if (executor.getOutputString().indexOf("parent branch:") != -1) {
            cmd.clear();
            cmd.add(this.cmd);
            cmd.add("up");
            executor = new Executor(cmd, directory);
            if (executor.exec() != 0) {
                throw new IOException(executor.getErrorString());
            }
        }
    }
View Full Code Here

        if (revision != null) {
            argv.add("-r"+revision);
        }
        argv.add(file.getCanonicalPath());

        Executor executor = new Executor(argv);
        if (executor.exec() == 0) {
            ret = executor.getOutputStream();
        }

        return ret;
    }
View Full Code Here

        }
        cmd.add("-fmt");
        cmd.add("%e\n%Nd\n%Fu (%u)\n%Vn\n%Nc\n.\n");
        cmd.add(filename);

        return new Executor(cmd, new File(getDirectoryName()));
    }
View Full Code Here

    private static final ClearCaseRepository testRepo =
            new ClearCaseRepository();

    private static String[] runLsvob() {
        if (testRepo.isWorking()) {
            Executor exec = new Executor(new String[] {testRepo.cmd, "lsvob", "-s"});
            int rc;
            if ((rc = exec.exec(true)) == 0) {
                String output = exec.getOutputString();

                if (output == null) {
                    OpenGrokLogger.getLogger().log(Level.SEVERE,
                        "\"cleartool lsvob -s\" output was null");
                    return new String[0];
View Full Code Here

        cmd.add("-c"); // to get correctly formed changeset IDs
        cmd.add(ABBREV_LOG);
        cmd.add("-C");
        cmd.add(fileName);
        File directory = new File(directoryName);
        Executor exec = new Executor(cmd, directory);

        int status = exec.exec();
        if (status != 0) {
            OpenGrokLogger.getLogger().log(Level.SEVERE,
          "Failed to get blame list in resolving correct path");
            return path;
        }
        try (BufferedReader in = new BufferedReader(exec.getOutputReader())) {
            String pattern = "^\\W*" + revision + " (.+?) .*$";
            Pattern commitPattern = Pattern.compile(pattern);
            String line = "";
            Matcher matcher = commitPattern.matcher(line);
            while ((line = in.readLine()) != null) {
View Full Code Here

        }

        if (filename.length() > 0) {
            cmd.add(filename);
        }
        return new Executor(cmd, new File(getDirectoryName()));
    }
View Full Code Here

        if (revision != null) {
            cmd.add(revision);
        }
        cmd.add(file.getName());

        Executor exec = new Executor(cmd, file.getParentFile());
        int status = exec.exec();

        // File might have changed its location
        if (status != 0) {
            cmd.clear();
            ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
            cmd.add(this.cmd);
            cmd.add(BLAME);
            cmd.add("-c"); // to get correctly formed changeset IDs
            cmd.add(ABBREV_BLAME);
            cmd.add("-C");
            cmd.add(file.getName());
            exec = new Executor(cmd, file.getParentFile());
            status = exec.exec();
            if (status != 0) {
                OpenGrokLogger.getLogger().log(Level.SEVERE,
        "Failed to get blame list");
            }
            try (BufferedReader in = new BufferedReader(exec.getOutputReader())) {
                String pattern = "^\\W*" + revision + " (.+?) .*$";
                Pattern commitPattern = Pattern.compile(pattern);
                String line = "";
                Matcher matcher = commitPattern.matcher(line);
                while ((line = in.readLine()) != null) {
                    matcher.reset(line);
                    if (matcher.find()) {
                        String filepath = matcher.group(1);
                        cmd.clear();
                        ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
                        cmd.add(this.cmd);
                        cmd.add(BLAME);
                        cmd.add("-c"); // to get correctly formed changeset IDs
                        cmd.add(ABBREV_BLAME);
                        if (revision != null) {
                            cmd.add(revision);
                        }
                        cmd.add("--");
                        cmd.add(filepath);
                        File directory = new File(directoryName);
                        exec = new Executor(cmd, directory);
                        status = exec.exec();
                        if (status != 0) {
                            OpenGrokLogger.getLogger().log(Level.SEVERE,
              "Failed to get blame details for modified file path");
                        }
                        break;
                    }
                }
            }
        }

        if (status != 0) {
            OpenGrokLogger.getLogger().log(Level.WARNING,
                "Failed to get annotations for: \"{0}\" Exit code: {1}",
                new Object[]{file.getAbsolutePath(), String.valueOf(status)});
        }

        return parseAnnotation(
                newLogReader(exec.getOutputStream()), file.getName());
    }
View Full Code Here

        ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
        cmd.add(this.cmd);
        cmd.add("config");
        cmd.add("--list");

        Executor executor = new Executor(cmd, directory);
        if (executor.exec() != 0) {
            throw new IOException(executor.getErrorString());
        }

        if (executor.getOutputString().indexOf("remote.origin.url=") != -1) {
            cmd.clear();
            cmd.add(this.cmd);
            cmd.add("pull");
            cmd.add("-n");
            cmd.add("-q");
            if (executor.exec() != 0) {
                throw new IOException(executor.getErrorString());
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.opensolaris.opengrok.util.Executor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.