File file, Repository repository, boolean withFiles)
throws HistoryException, SQLException {
final String filePath = getSourceRootRelativePath(file);
final String reposPath = toUnixPath(repository.getDirectoryName());
final ArrayList<HistoryEntry> entries = new ArrayList<HistoryEntry>();
final ConnectionResource conn =
connectionManager.getConnectionResource();
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
try {
final PreparedStatement ps;
if (file.isDirectory()) {
// Fetch history for all files under this directory.
ps = conn.getStatement(GET_DIR_HISTORY);
ps.setString(2, filePath);
} else {
// Fetch history for a single file only.
ps = conn.getStatement(RuntimeEnvironment.isRenamedFilesEnabled() && (getFilemovesCount() > 0) ?
GET_FILE_HISTORY : GET_FILE_HISTORY_FOLDED);
ps.setString(2, getParentPath(filePath));
ps.setString(3, getBaseName(filePath));
}
ps.setString(1, reposPath);
final PreparedStatement filePS =
withFiles ? conn.getStatement(GET_CS_FILES) : null;
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
// Get the information about a changeset
String revision = rs.getString(1);