public long getLatestRevision() throws ClientException { try { return svnRepository.getLatestRevision(); } catch (SVNException e) { throw ClientException.fromException(e); } }
FSRepositoryFactory.setup(); File pathToRepository = new File("/path/to/repository"); SVNRepository svnRepository = SVNRepositoryFactory.create(SVNURL.fromFile(pathToRepository)); try { final long latestRevision = svnRepository.getLatestRevision(); System.out.println("latestRevision = " + latestRevision); } finally { svnRepository.closeSession(); }
private void updateCommitLog(Date _as_of) throws SVNException { // In all of the following cases, no further log entries must be collected if(this.logEntries!=null && (this.asOf==null || (_as_of!=null && this.asOf.before(_as_of)))) return; // Retrieve the log this.asOf = _as_of; final long latest_rev = this.rootRepo.getLatestRevision(); // Search as of ... long first_rev = 0; if(this.asOf!=null) first_rev = this.rootRepo.getDatedRevision(this.asOf); this.logEntries = rootRepo.log(new String[] { "" }, null, first_rev, latest_rev, true, true); }
private SVNNodeKind kind() throws ExistsException { SVNRepository repository; repository = root.getRepository(); try { return repository.checkPath(path, repository.getLatestRevision()); } catch (SVNException e) { throw new ExistsException(this, e); } }
public List<Long> getRevisions(long start, long end) throws SVNException { Collection<SVNFileRevision> revisions; List<Long> result; revisions = (Collection<SVNFileRevision>) root.getRepository().getFileRevisions(path, null, start, end); result = new ArrayList<>(); for (SVNFileRevision rev : revisions) { result.add(rev.getRevision()); } return result; }
public static void checkFileContent(@NotNull SVNRepository repo, @NotNull String filePath, @NotNull byte[] content) throws IOException, SVNException { try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) { repo.getFile(filePath, repo.getLatestRevision(), null, stream); Assert.assertEquals(stream.toByteArray(), content); } }
public static void checkFileContent(@NotNull SVNRepository repo, @NotNull String filePath, @NotNull String content) throws IOException, SVNException { try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) { repo.getFile(filePath, repo.getLatestRevision(), null, stream); Assert.assertEquals(new String(stream.toByteArray(), StandardCharsets.UTF_8), content); } }
public List<Long> getRevisions(long start, long end) throws SVNException { Collection<SVNFileRevision> revisions; List<Long> result; revisions = (Collection<SVNFileRevision>) root.getRepository().getFileRevisions(path, null, start, end); result = new ArrayList<Long>(); for (SVNFileRevision rev : revisions) { result.add(rev.getRevision()); } return result; }
@Override public boolean exists() throws ExistsException { try { return exists(root.getRepository().getLatestRevision()); } catch (SVNException e) { throw new ExistsException(this, e); } }
@NotNull private List<Long> loadUpdateRevisions(@NotNull SVNRepository repo, @NotNull String path) throws SVNException { final long maxRevision = repo.getLatestRevision(); final LinkedList<Long> revisions = new LinkedList<>(); repo.log(new String[]{path}, maxRevision, 0, false, false, logEntry -> revisions.addFirst(logEntry.getRevision())); return new ArrayList<>(revisions); }
private void checkUser(@NotNull String login, @NotNull String password) throws Exception { try (SvnTestServer server = createServer(rootToken, null)) { server.openSvnRepository(login, password).getLatestRevision(); } }
private void checkUser(@NotNull String login, @NotNull String password) throws Exception { try (SvnTestServer server = createServer(administratorToken, null)) { server.openSvnRepository(login, password).getLatestRevision(); } }
public static void checkDirProp(@NotNull SVNRepository repo, @NotNull String filePath, @Nullable Map<String, String> expected) throws SVNException { SVNProperties props = new SVNProperties(); repo.getDir(filePath, repo.getLatestRevision(), props, new ArrayList<>()); checkProp(props, expected); }
private void check(@NotNull SvnTester server, @NotNull String path, @Nullable SVNDepth depth, @NotNull ISVNReporterBaton reporterBaton, @NotNull String expected) throws SVNException { final SVNRepository repo = server.openSvnRepository(); final ReportSVNEditor editor = new ReportSVNEditor(); repo.update(repo.getLatestRevision(), path, depth, false, reporterBaton, editor); Assert.assertEquals(editor.toString(), expected); } }
public static void checkFileProp(@NotNull SVNRepository repo, @NotNull String filePath, @Nullable Map<String, String> expected) throws SVNException { SVNProperties props = new SVNProperties(); repo.getFile(filePath, repo.getLatestRevision(), props, null); checkProp(props, expected); }
private void testTagMapping(@NotNull GitlabProject project) throws Exception { try (SvnTestServer server = createServer(rootToken, dir -> new GitLabMappingConfig(dir, GitCreateMode.EMPTY, Collections.singleton("git-as-svn")))) { openSvnRepository(server, project, user, userPassword).getLatestRevision(); } }
@Test void gitlabMappingAsRoot() throws Exception { try (SvnTestServer server = createServer(rootToken, dir -> new GitLabMappingConfig(dir, GitCreateMode.EMPTY))) { openSvnRepository(server, gitlabProject, user, userPassword).getLatestRevision(); } }
private void checkUser(@NotNull String login, @NotNull String password) throws Exception { try ( EmbeddedDirectoryServer ldap = EmbeddedDirectoryServer.create(); SvnTestServer server = SvnTestServer.createEmpty(ldap.createUserConfig(), false) ) { server.openSvnRepository(login, password).getLatestRevision(); } }
/** * Test for #119. */ @Ignore @Test void gitlabMappingAsUser() throws Exception { final GitLabToken userToken = createToken(user, userPassword, false); try (SvnTestServer server = createServer(userToken, dir -> new GitLabMappingConfig(dir, GitCreateMode.EMPTY))) { openSvnRepository(server, gitlabProject, root, rootPassword).getLatestRevision(); } } }
private void checkAnonymous(boolean anonymousRead) throws Exception { try ( EmbeddedDirectoryServer ldap = EmbeddedDirectoryServer.create(); SvnTestServer server = SvnTestServer.createEmpty(ldap.createUserConfig(), anonymousRead) ) { server.openSvnRepository().getLatestRevision(); } }