Search in sources :

Example 1 with InvalidVersionNumberException

use of org.suigeneris.jrcs.rcs.InvalidVersionNumberException in project OpenGrok by OpenGrok.

the class BitKeeperRepository method ensureVersion.

/**
 * Updates working and version member variables by running {@code bk --version}.
 */
private void ensureVersion() {
    if (working == null) {
        ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
        final Executor exec = new Executor(new String[] { RepoCommand, "--version" });
        if (exec.exec(false) == 0) {
            working = Boolean.TRUE;
            final Matcher matcher = VERSION_PATTERN.matcher(exec.getOutputString());
            if (matcher.find()) {
                try {
                    version = new Version(matcher.group(1));
                } catch (final InvalidVersionNumberException e) {
                    assert false : "Failed to parse a version number.";
                }
            }
        } else {
            working = Boolean.FALSE;
        }
        if (version == null) {
            version = new Version(0, 0);
        }
    }
}
Also used : Executor(org.opengrok.indexer.util.Executor) Matcher(java.util.regex.Matcher) Version(org.suigeneris.jrcs.rcs.Version) InvalidVersionNumberException(org.suigeneris.jrcs.rcs.InvalidVersionNumberException)

Aggregations

Matcher (java.util.regex.Matcher)1 Executor (org.opengrok.indexer.util.Executor)1 InvalidVersionNumberException (org.suigeneris.jrcs.rcs.InvalidVersionNumberException)1 Version (org.suigeneris.jrcs.rcs.Version)1