Skip to content

Commit bb2e3f9

Browse files
committed
refactor
1 parent 702a0b0 commit bb2e3f9

File tree

2 files changed

+20
-29
lines changed

2 files changed

+20
-29
lines changed

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

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class SVNVCS implements IVCS {
3535

3636
private BasicAuthenticationManager authManager;
3737
private SVNRepository repository;
38-
private ISVNOptions options;
38+
private final ISVNOptions options;
3939
private SVNClientManager clientManager;
4040
private SVNURL trunkSVNUrl;
4141
private SVNAuthentication userPassAuth;
@@ -110,7 +110,7 @@ public void createBranch(String srcBranchName, String dstBranchName, String comm
110110
createBranch(fromUrl, toUrl, commitMessage);
111111
}
112112

113-
public void createBranch(SVNURL fromUrl, SVNURL toUrl, String commitMessage) {
113+
private void createBranch(SVNURL fromUrl, SVNURL toUrl, String commitMessage) {
114114
try {
115115
SVNCopyClient copyClient = clientManager.getCopyClient();
116116
SVNCopySource copySource = new SVNCopySource(SVNRevision.HEAD, SVNRevision.HEAD, fromUrl);
@@ -189,11 +189,11 @@ public VCSMergeResult merge(String srcBranchName, String dstBranchName, String c
189189
}
190190
}
191191

192-
protected SVNWCClient getRevertClient(DefaultSVNOptions options) {
192+
SVNWCClient getRevertClient(DefaultSVNOptions options) {
193193
return new SVNWCClient(authManager, options);
194194
}
195195

196-
public void checkout(SVNURL sourceUrl, File destPath, String revision) throws SVNException {
196+
private void checkout(SVNURL sourceUrl, File destPath, String revision) throws SVNException {
197197
SVNUpdateClient updateClient = clientManager.getUpdateClient();
198198
updateClient.setIgnoreExternals(false);
199199
SVNRevision svnRevision = revision == null ? SVNRevision.HEAD : SVNRevision.parse(revision);
@@ -338,14 +338,14 @@ private List<VCSDiffEntry> fillUnifiedDiffs(final String srcBranchName, final St
338338
return res;
339339
}
340340

341-
protected SVNLogEntry getDirFirstCommit(final String dir) throws SVNException {
341+
private SVNLogEntry getDirFirstCommit(final String dir) throws SVNException {
342342
@SuppressWarnings("unchecked")
343343
Collection<SVNLogEntry> entries = repository.log(new String[] { dir }, null, 0 /* start from first commit */,
344344
-1 /* to the head commit */, true, true);
345345
return entries.iterator().next();
346346
}
347347

348-
protected SVNLogEntry getBranchFirstCommit(final String branchPath) throws SVNException {
348+
SVNLogEntry getBranchFirstCommit(final String branchPath) throws SVNException {
349349
return getDirFirstCommit(getBranchName(branchPath));
350350
}
351351

@@ -359,18 +359,14 @@ private List<VCSDiffEntry> getDiffEntries(final String srcBranchName, final Stri
359359
SvnTarget.fromURL(getBranchUrl(dstBranchName), SVNRevision.HEAD),
360360
SvnTarget.fromURL(getBranchUrl(srcBranchName), SVNRevision.HEAD));
361361

362-
summarizeDiff.setReceiver(new ISvnObjectReceiver<SvnDiffStatus>() {
363-
public void receive(SvnTarget target, SvnDiffStatus diffStatus) throws SVNException {
364-
if (diffStatus.getPath().length() == 0) {
365-
return;
366-
}
367-
VCSDiffEntry entry = new VCSDiffEntry(diffStatus.getPath(),
368-
SVNChangeTypeToVCSChangeType(diffStatus.getModificationType()), null);
369-
res.add(entry);
370-
}
371-
372-
373-
});
362+
summarizeDiff.setReceiver((target, diffStatus) -> {
363+
if (diffStatus.getPath().length() == 0) {
364+
return;
365+
}
366+
VCSDiffEntry entry = new VCSDiffEntry(diffStatus.getPath(),
367+
SVNChangeTypeToVCSChangeType(diffStatus.getModificationType()), null);
368+
res.add(entry);
369+
});
374370
summarizeDiff.run();
375371

376372
return res;
@@ -423,7 +419,7 @@ public Set<String> getBranches(String path) {
423419
}
424420

425421
@SuppressWarnings("unchecked")
426-
protected List<String> listEntries(String path) throws SVNException {
422+
List<String> listEntries(String path) throws SVNException {
427423
List<String> res = new ArrayList<>();
428424
if (path == null) {
429425
return res;
@@ -463,12 +459,7 @@ public List<VCSCommit> log(String branchName, int limit) {
463459
getBranchUrl(branchName); // for exception test only
464460
repository.log(new String[] { getBranchName(branchName) },
465461
-1L /* start from head descending */,
466-
0L, true, true, limit, new ISVNLogEntryHandler() {
467-
@Override
468-
public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
469-
res.add(svnLogEntryToVCSCommit(logEntry));
470-
}
471-
});
462+
0L, true, true, limit, logEntry -> res.add(svnLogEntryToVCSCommit(logEntry)));
472463
return res;
473464
} catch (SVNException e) {
474465
throw new EVCSException(e);
@@ -557,7 +548,7 @@ public VCSCommit getHeadCommit(String branchName) {
557548
}
558549
}
559550

560-
protected SVNLogEntry getDirHeadLogEntry(String dir) throws SVNException {
551+
SVNLogEntry getDirHeadLogEntry(String dir) throws SVNException {
561552
@SuppressWarnings("unchecked")
562553
Collection<SVNLogEntry> entries = repository.log(new String[] { dir }, null, -1 /* start from head commit */,
563554
0 /* to the first commit */, true, true);
@@ -605,7 +596,7 @@ public VCSTag createTag(String branchName, String tagName, String tagMessage, St
605596
}
606597
}
607598

608-
protected SVNLogEntry revToSVNEntry(String branchName, Long rev) throws SVNException {
599+
SVNLogEntry revToSVNEntry(String branchName, Long rev) throws SVNException {
609600
SVNDirEntry info = repository.info(branchName, rev);
610601
@SuppressWarnings("unchecked")
611602
Collection<SVNLogEntry> entries = repository.log(new String[] {branchName}, null, info.getRevision(), info.getRevision(), true, true);
@@ -644,7 +635,7 @@ public void checkout(String branchName, String targetPath, String revision) {
644635
}
645636
}
646637

647-
protected List<VCSTag> getTags(String onRevision) throws SVNException {
638+
List<VCSTag> getTags(String onRevision) throws SVNException {
648639
List<VCSTag> res = new ArrayList<>();
649640
@SuppressWarnings("unchecked")
650641
Collection<SVNDirEntry> dirEntries = repository.getDir(TAGS_PATH, -1 , null, (Collection<SVNDirEntry>) null);

src/test/java/org/scm4j/vcs/svn/SVNVCSTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public void testCredentials() throws Exception {
112112
testAuth(svn, "user", "pass");
113113
}
114114

115-
public void testAuth(SVNVCS svn, String user, String pass) throws Exception {
115+
private void testAuth(SVNVCS svn, String user, String pass) throws Exception {
116116
SVNRepository repo = svn.getSVNRepository();
117117
SVNAuthentication auth = repo.getAuthenticationManager().getFirstAuthentication("svn.simple", "",
118118
svn.getTrunkSVNUrl());

0 commit comments

Comments
 (0)