repository = null;
dir = dir.getParentFile();
} while(dir != null);
if (repository == null) {
throw new HgRepositoryNotFoundException(String.format("Can't locate .hg/ directory of Mercurial repository in %s nor in parent dirs", location)).setLocation(location.getPath());
}
try {
String repoPath = repository.getParentFile().getAbsolutePath();
HgRepository rv = new HgRepository(getSessionContext(), repoPath, repository);
int requiresFlags = rv.getImplHelper().getRequiresFlags();
if ((requiresFlags & RequiresFile.REVLOGV1) == 0) {
throw new HgRepositoryNotFoundException(String.format("%s: repository version is not supported (Mercurial <0.9?)", repoPath)).setLocation(location.getPath());
}
return rv;
} catch (HgRuntimeException ex) {
HgRepositoryNotFoundException e = new HgRepositoryNotFoundException("Failed to initialize Hg4J library").setLocation(location.getPath());
e.initCause(ex);
throw e;
}
}