@Test public void testB2() throws SVNException { ForkPoint forkPoint = findFork.find(b2, "branches/b1"); assertThat(forkPoint.commit()).isEqualTo("9"); }
@CheckForNull public ForkPoint find(Path location, String referenceBranch) throws SVNException { SVNClientManager clientManager = newSvnClientManager(configuration); SVNRevision revision = getSvnRevision(location, clientManager); LOG.debug("latest revision is " + revision); String svnRefBranch = "/" + referenceBranch; SVNLogEntryHolder handler = new SVNLogEntryHolder(); SVNRevision endRevision = SVNRevision.create(1); SVNRevision startRevision = SVNRevision.create(revision.getNumber()); do { clientManager.getLogClient().doLog(new File[] {location.toFile()}, startRevision, endRevision, true, true, -1, handler); SVNLogEntry lastEntry = handler.getLastEntry(); Optional<SVNLogEntryPath> copyFromReference = lastEntry.getChangedPaths().values().stream() .filter(e -> e.getCopyPath() != null && e.getCopyPath().equals(svnRefBranch)) .findFirst(); if (copyFromReference.isPresent()) { return new ForkPoint(String.valueOf(copyFromReference.get().getCopyRevision()), Instant.ofEpochMilli(lastEntry.getDate().getTime())); } if (lastEntry.getChangedPaths().isEmpty()) { return null; } SVNLogEntryPath firstChangedPath = lastEntry.getChangedPaths().values().iterator().next(); if (firstChangedPath.getCopyPath() == null) { return null; } startRevision = SVNRevision.create(firstChangedPath.getCopyRevision()); } while (true); }
FindFork { @CheckForNull public ForkPoint find(Path location, String referenceBranch) throws SVNException { SVNClientManager clientManager = newSvnClientManager(configuration); SVNRevision revision = getSvnRevision(location, clientManager); LOG.debug("latest revision is " + revision); String svnRefBranch = "/" + referenceBranch; SVNLogEntryHolder handler = new SVNLogEntryHolder(); SVNRevision endRevision = SVNRevision.create(1); SVNRevision startRevision = SVNRevision.create(revision.getNumber()); do { clientManager.getLogClient().doLog(new File[] {location.toFile()}, startRevision, endRevision, true, true, -1, handler); SVNLogEntry lastEntry = handler.getLastEntry(); Optional<SVNLogEntryPath> copyFromReference = lastEntry.getChangedPaths().values().stream() .filter(e -> e.getCopyPath() != null && e.getCopyPath().equals(svnRefBranch)) .findFirst(); if (copyFromReference.isPresent()) { return new ForkPoint(String.valueOf(copyFromReference.get().getCopyRevision()), Instant.ofEpochMilli(lastEntry.getDate().getTime())); } if (lastEntry.getChangedPaths().isEmpty()) { return null; } SVNLogEntryPath firstChangedPath = lastEntry.getChangedPaths().values().iterator().next(); if (firstChangedPath.getCopyPath() == null) { return null; } startRevision = SVNRevision.create(firstChangedPath.getCopyRevision()); } while (true); } }
FindFork { @CheckForNull public ForkPoint find(Path location, String referenceBranch) throws SVNException { SVNClientManager clientManager = newSvnClientManager(configuration); SVNRevision revision = getSvnRevision(location, clientManager); LOG.debug("latest revision is " + revision); String svnRefBranch = "/" + referenceBranch; SVNLogEntryHolder handler = new SVNLogEntryHolder(); SVNRevision endRevision = SVNRevision.create(1); SVNRevision startRevision = SVNRevision.create(revision.getNumber()); do { clientManager.getLogClient().doLog(new File[] {location.toFile()}, startRevision, endRevision, true, true, -1, handler); SVNLogEntry lastEntry = handler.getLastEntry(); Optional<SVNLogEntryPath> copyFromReference = lastEntry.getChangedPaths().values().stream() .filter(e -> e.getCopyPath() != null && e.getCopyPath().equals(svnRefBranch)) .findFirst(); if (copyFromReference.isPresent()) { return new ForkPoint(String.valueOf(copyFromReference.get().getCopyRevision()), Instant.ofEpochMilli(lastEntry.getDate().getTime())); } if (lastEntry.getChangedPaths().isEmpty()) { return null; } SVNLogEntryPath firstChangedPath = lastEntry.getChangedPaths().values().iterator().next(); if (firstChangedPath.getCopyPath() == null) { return null; } startRevision = SVNRevision.create(firstChangedPath.getCopyRevision()); } while (true); } FindFork(SvnConfiguration configuration); }
FindFork { @CheckForNull public ForkPoint find(Path location, String referenceBranch) throws SVNException { SVNClientManager clientManager = newSvnClientManager(configuration); SVNRevision revision = getSvnRevision(location, clientManager); LOG.debug("latest revision is " + revision); String svnRefBranch = "/" + referenceBranch; SVNLogEntryHolder handler = new SVNLogEntryHolder(); SVNRevision endRevision = SVNRevision.create(1); SVNRevision startRevision = SVNRevision.create(revision.getNumber()); do { clientManager.getLogClient().doLog(new File[] {location.toFile()}, startRevision, endRevision, true, true, -1, handler); SVNLogEntry lastEntry = handler.getLastEntry(); Optional<SVNLogEntryPath> copyFromReference = lastEntry.getChangedPaths().values().stream() .filter(e -> e.getCopyPath() != null && e.getCopyPath().equals(svnRefBranch)) .findFirst(); if (copyFromReference.isPresent()) { return new ForkPoint(String.valueOf(copyFromReference.get().getCopyRevision()), Instant.ofEpochMilli(lastEntry.getDate().getTime())); } if (lastEntry.getChangedPaths().isEmpty()) { return null; } SVNLogEntryPath firstChangedPath = lastEntry.getChangedPaths().values().iterator().next(); if (firstChangedPath.getCopyPath() == null) { return null; } startRevision = SVNRevision.create(firstChangedPath.getCopyRevision()); } while (true); } FindFork(SvnConfiguration configuration); @CheckForNull Instant findDate(Path location, String referenceBranch); @CheckForNull ForkPoint find(Path location, String referenceBranch); }
FindFork { @CheckForNull public ForkPoint find(Path location, String referenceBranch) throws SVNException { SVNClientManager clientManager = newSvnClientManager(configuration); SVNRevision revision = getSvnRevision(location, clientManager); LOG.debug("latest revision is " + revision); String svnRefBranch = "/" + referenceBranch; SVNLogEntryHolder handler = new SVNLogEntryHolder(); SVNRevision endRevision = SVNRevision.create(1); SVNRevision startRevision = SVNRevision.create(revision.getNumber()); do { clientManager.getLogClient().doLog(new File[] {location.toFile()}, startRevision, endRevision, true, true, -1, handler); SVNLogEntry lastEntry = handler.getLastEntry(); Optional<SVNLogEntryPath> copyFromReference = lastEntry.getChangedPaths().values().stream() .filter(e -> e.getCopyPath() != null && e.getCopyPath().equals(svnRefBranch)) .findFirst(); if (copyFromReference.isPresent()) { return new ForkPoint(String.valueOf(copyFromReference.get().getCopyRevision()), Instant.ofEpochMilli(lastEntry.getDate().getTime())); } if (lastEntry.getChangedPaths().isEmpty()) { return null; } SVNLogEntryPath firstChangedPath = lastEntry.getChangedPaths().values().iterator().next(); if (firstChangedPath.getCopyPath() == null) { return null; } startRevision = SVNRevision.create(firstChangedPath.getCopyRevision()); } while (true); } FindFork(SvnConfiguration configuration); @CheckForNull Instant findDate(Path location, String referenceBranch); @CheckForNull ForkPoint find(Path location, String referenceBranch);  }