Skip to content

Commit 8137f2b

Browse files
committed
getCommitsRange() test implemented
getBranchHeadCommit() test implemented documentation updated
1 parent 1abf876 commit 8137f2b

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

src/main/java/org/scm4j/vcs/svn/SVNVCS.java

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,12 @@ private void fillUnifiedDiffs(final String srcBranchName, final String dstBranch
340340
final SvnDiff diff = svnOperationFactory.createDiff();
341341

342342
if (entry.getChangeType() == VCSChangeType.ADD) {
343-
SVNLogEntry firstCommit = getBranchFirstCommit(getBranchName(dstBranchName));
343+
SVNLogEntry firstCommit = getBranchFirstCommit(dstBranchName);
344344
diff.setSource(SvnTarget.fromURL(getBranchUrl(srcBranchName).appendPath(entry.getFilePath(), true), SVNRevision.HEAD),
345345
SVNRevision.create(firstCommit.getRevision()),
346346
SVNRevision.create(repository.info(getBranchName(dstBranchName), -1).getRevision()));
347347
} else if (entry.getChangeType() == VCSChangeType.DELETE) {
348-
SVNLogEntry firstCommit = getBranchFirstCommit(getBranchName(dstBranchName));
348+
SVNLogEntry firstCommit = getBranchFirstCommit(dstBranchName);
349349
diff.setSource(SvnTarget.fromURL(getBranchUrl(dstBranchName).appendPath(entry.getFilePath(), true), SVNRevision.HEAD),
350350
SVNRevision.create(repository.info(getBranchName(dstBranchName), -1).getRevision()),
351351
SVNRevision.create(firstCommit.getRevision()));
@@ -367,7 +367,7 @@ private void fillUnifiedDiffs(final String srcBranchName, final String dstBranch
367367

368368
private SVNLogEntry getBranchFirstCommit(final String branchPath) throws SVNException {
369369
final List<SVNLogEntry> logEntries = new ArrayList<>();
370-
repository.log(new String[] { branchPath }, -1 /* start from head descending */,
370+
repository.log(new String[] { getBranchName(branchPath) }, -1 /* start from head descending */,
371371
0, true, true, -1, new ISVNLogEntryHandler() {
372372
@Override
373373
public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
@@ -518,23 +518,22 @@ public String removeFile(String branchName, String filePath, String commitMessag
518518
}
519519

520520
@Override
521-
public List<VCSCommit> getCommitsRange(String branchName, String startFromCommitId, WalkDirection direction, int limit) {
521+
public List<VCSCommit> getCommitsRange(String branchName, String firstCommitId, WalkDirection direction, int limit) {
522522
final List<VCSCommit> res = new ArrayList<>();
523523
try {
524-
String bn = getBranchName(branchName);
524+
525525
Long sinceCommit;
526526
Long untilCommit;
527527
if (direction == WalkDirection.ASC) {
528-
sinceCommit = startFromCommitId == null ? getBranchFirstCommit(bn).getRevision() :
529-
Long.parseLong(startFromCommitId);
528+
sinceCommit = firstCommitId == null ? getBranchFirstCommit(branchName).getRevision() :
529+
Long.parseLong(firstCommitId);
530530
untilCommit = Long.parseLong(getHeadCommit(branchName).getRevision());
531531
} else {
532-
sinceCommit = startFromCommitId == null ? getBranchFirstCommit(bn).getRevision() :
533-
Long.parseLong(startFromCommitId);
534-
untilCommit = getBranchFirstCommit(bn).getRevision();
532+
sinceCommit = firstCommitId == null ? Long.parseLong(getHeadCommit(branchName).getRevision()) :
533+
Long.parseLong(firstCommitId);
534+
untilCommit = getBranchFirstCommit(branchName).getRevision();
535535
}
536-
537-
repository.log(new String[] { bn }, sinceCommit, untilCommit, true, true, limit,
536+
repository.log(new String[] { getBranchName(branchName) }, sinceCommit, untilCommit, true, true, limit,
538537
new ISVNLogEntryHandler() {
539538
@Override
540539
public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
@@ -552,15 +551,14 @@ public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
552551
}
553552

554553
@Override
555-
public List<VCSCommit> getCommitsRange(String branchName, String afterCommitId, String untilCommitId) {
554+
public List<VCSCommit> getCommitsRange(String branchName, String firstCommitId, String untilCommitId) {
556555
final List<VCSCommit> res = new ArrayList<>();
557556
try {
558-
String bn = getBranchName(branchName);
559-
Long sinceCommit = afterCommitId == null ?
560-
getBranchFirstCommit(bn).getRevision() :
561-
Long.parseLong(afterCommitId);
557+
Long sinceCommit = firstCommitId == null ?
558+
getBranchFirstCommit(branchName).getRevision() :
559+
Long.parseLong(firstCommitId);
562560
Long untilCommit = untilCommitId == null ? -1L : Long.parseLong(untilCommitId);
563-
repository.log(new String[] { bn }, sinceCommit, untilCommit, true, true, 0 /* limit */,
561+
repository.log(new String[] { getBranchName(branchName) }, sinceCommit, untilCommit, true, true, 0 /* limit */,
564562
new ISVNLogEntryHandler() {
565563
@Override
566564
public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
@@ -593,10 +591,8 @@ public VCSCommit getHeadCommit(String branchName) {
593591
} catch (Exception e) {
594592
throw new RuntimeException(e);
595593
}
596-
597594
}
598-
599-
595+
600596
@Override
601597
public String toString() {
602598
return "SVNVCS [url=" + repo.getRepoUrl() + "]";

0 commit comments

Comments
 (0)