Skip to content

Commit 60f6d57

Browse files
committed
createBranch() optimized
1 parent bb2e3f9 commit 60f6d57

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

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

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,9 @@ public SVNURL getBranchUrl(String branchPath) throws SVNException {
9999

100100
@Override
101101
public void createBranch(String srcBranchName, String dstBranchName, String commitMessage) throws EVCSBranchExists {
102-
SVNURL fromUrl;
103-
SVNURL toUrl;
104-
try {
105-
fromUrl = getBranchUrl(srcBranchName);
106-
toUrl = getBranchUrl(dstBranchName);
107-
} catch (SVNException e) {
108-
throw new EVCSException(e);
109-
}
110-
createBranch(fromUrl, toUrl, commitMessage);
111-
}
112-
113-
private void createBranch(SVNURL fromUrl, SVNURL toUrl, String commitMessage) {
114102
try {
103+
SVNURL fromUrl = getBranchUrl(srcBranchName);
104+
SVNURL toUrl = getBranchUrl(dstBranchName);
115105
SVNCopyClient copyClient = clientManager.getCopyClient();
116106
SVNCopySource copySource = new SVNCopySource(SVNRevision.HEAD, SVNRevision.HEAD, fromUrl);
117107
copySource.setCopyContents(false);
@@ -123,13 +113,13 @@ private void createBranch(SVNURL fromUrl, SVNURL toUrl, String commitMessage) {
123113
null); // SVNProperties
124114

125115
} catch (SVNException e) {
126-
if (e.getErrorMessage().getErrorCode().getCode() == SVN_ITEM_EXISTS_ERROR_CODE) {
127-
throw new EVCSBranchExists(e);
128-
}
129-
throw new EVCSException(e);
116+
if (e.getErrorMessage().getErrorCode().getCode() == SVN_ITEM_EXISTS_ERROR_CODE) {
117+
throw new EVCSBranchExists(dstBranchName);
118+
}
119+
throw new EVCSException(e);
130120
}
131121
}
132-
122+
133123
@Override
134124
public void deleteBranch(String branchName, String commitMessage) {
135125
try {

0 commit comments

Comments
 (0)