@Test public void testAnnotationInvalid() throws Exception { assertNotNull("Couldn't read bitkeeper test repository.", bkRepo); final File file = new File(bkRepo.getDirectoryName(), "fakename.cpp"); boolean caughtCurrent = false; try { final Annotation currentVersion = bkRepo.annotate(file, "+"); } catch (final IOException e) { caughtCurrent = true; } assertTrue("No exception thrown by annotate with fake file", caughtCurrent); boolean caughtFirst = false; try { final Annotation firstVersion = bkRepo.annotate(file, "1.1"); } catch (final IOException e) { caughtFirst = true; } assertTrue("No exception thrown by annotate with fake file", caughtFirst); }
@Override public Annotation annotate(File file, String revision) throws IOException { final File absolute = file.getCanonicalFile(); 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("annotate"); argv.add("-aur"); if (revision != null) { argv.add("-r" + revision); } argv.add(basename); final Executor executor = new Executor(argv, directory, RuntimeEnvironment.getInstance().getInteractiveCommandTimeout()); final BitKeeperAnnotationParser parser = new BitKeeperAnnotationParser(basename); int status = executor.exec(true, parser); if (status != 0) { LOGGER.log(Level.WARNING, "Failed to get annotations for: \"{0}\" Exit code: {1}", new Object[]{file.getAbsolutePath(), String.valueOf(status)}); throw new IOException(executor.getErrorString()); } else { return parser.getAnnotation(); } }
BitKeeperRepository extends Repository { @Override public Annotation annotate(File file, String revision) throws IOException { final File absolute = file.getCanonicalFile(); 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("annotate"); argv.add("-aur"); if (revision != null) { argv.add("-r" + revision); } argv.add(basename); final Executor executor = new Executor(argv, directory, RuntimeEnvironment.getInstance().getInteractiveCommandTimeout()); final BitKeeperAnnotationParser parser = new BitKeeperAnnotationParser(basename); int status = executor.exec(true, parser); if (status != 0) { LOGGER.log(Level.WARNING, "Failed to get annotations for: \"{0}\" Exit code: {1}", new Object[]{file.getAbsolutePath(), String.valueOf(status)}); throw new IOException(executor.getErrorString()); } else { return parser.getAnnotation(); } } }
BitKeeperRepository extends Repository { @Override public Annotation annotate(File file, String revision) throws IOException { final File absolute = file.getCanonicalFile(); 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("annotate"); argv.add("-aur"); if (revision != null) { argv.add("-r" + revision); } argv.add(basename); final Executor executor = new Executor(argv, directory, RuntimeEnvironment.getInstance().getInteractiveCommandTimeout()); final BitKeeperAnnotationParser parser = new BitKeeperAnnotationParser(basename); int status = executor.exec(true, parser); if (status != 0) { LOGGER.log(Level.WARNING, "Failed to get annotations for: \"{0}\" Exit code: {1}", new Object[]{file.getAbsolutePath(), String.valueOf(status)}); throw new IOException(executor.getErrorString()); } else { return parser.getAnnotation(); } } BitKeeperRepository(); }
BitKeeperRepository extends Repository { @Override public Annotation annotate(File file, String revision) throws IOException { final File absolute = file.getCanonicalFile(); 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("annotate"); argv.add("-aur"); if (revision != null) { argv.add("-r" + revision); } argv.add(basename); final Executor executor = new Executor(argv, directory, RuntimeEnvironment.getInstance().getInteractiveCommandTimeout()); final BitKeeperAnnotationParser parser = new BitKeeperAnnotationParser(basename); int status = executor.exec(true, parser); if (status != 0) { LOGGER.log(Level.WARNING, "Failed to get annotations for: \"{0}\" Exit code: {1}", new Object[]{file.getAbsolutePath(), String.valueOf(status)}); throw new IOException(executor.getErrorString()); } else { return parser.getAnnotation(); } } BitKeeperRepository(); @Override boolean isWorking(); Version getVersion(); @Override boolean fileHasHistory(File file); @Override boolean fileHasAnnotation(File file); @Override Annotation annotate(File file, String revision); @Override void buildTagList(File directory, CommandTimeoutType cmdType); }
BitKeeperRepository extends Repository { @Override public Annotation annotate(File file, String revision) throws IOException { final File absolute = file.getCanonicalFile(); 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("annotate"); argv.add("-aur"); if (revision != null) { argv.add("-r" + revision); } argv.add(basename); final Executor executor = new Executor(argv, directory, RuntimeEnvironment.getInstance().getInteractiveCommandTimeout()); final BitKeeperAnnotationParser parser = new BitKeeperAnnotationParser(basename); int status = executor.exec(true, parser); if (status != 0) { LOGGER.log(Level.WARNING, "Failed to get annotations for: \"{0}\" Exit code: {1}", new Object[]{file.getAbsolutePath(), String.valueOf(status)}); throw new IOException(executor.getErrorString()); } else { return parser.getAnnotation(); } } BitKeeperRepository(); @Override boolean isWorking(); Version getVersion(); @Override boolean fileHasHistory(File file); @Override boolean fileHasAnnotation(File file); @Override Annotation annotate(File file, String revision); @Override void buildTagList(File directory, CommandTimeoutType cmdType); static final String CMD_PROPERTY_KEY; static final String CMD_FALLBACK; }