Skip to content

Commit b66d5b6

Browse files
committed
Revert "devide getFileContent(): from branch and from revision #1"
This reverts commit b57ab50.
1 parent b57ab50 commit b66d5b6

File tree

2 files changed

+5
-35
lines changed

2 files changed

+5
-35
lines changed

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

+2-32
Original file line numberDiff line numberDiff line change
@@ -222,39 +222,9 @@ public void setProxy(String host, int port, String proxyUser, String proxyPasswo
222222
authManager.setProxy(host, port, proxyUser, proxyPassword.toCharArray());
223223
}
224224

225-
@Override
226-
public String getFileContentFromBranch(String branchName, String filePath) throws EVCSFileNotFound {
227-
return getFileContent(branchName, filePath, null);
228-
}
229225

230226
@Override
231-
public String getFileContentFromRevision(String revision, String filePath) throws EVCSFileNotFound {
232-
final String[] branchNames = new String[1];
233-
ISVNLogEntryHandler handler = new ISVNLogEntryHandler() {
234-
@Override
235-
public void handleLogEntry(SVNLogEntry arg0) throws SVNException {
236-
Map<String, SVNLogEntryPath> map = arg0.getChangedPaths();
237-
for (Map.Entry<String, SVNLogEntryPath> entry: map.entrySet()) {
238-
if (branchNames[0] == null) {
239-
SVNLogEntryPath svnLogEntryPath = entry.getValue();
240-
branchNames[0] = svnLogEntryPath.getPath().replace(filePath, "").replaceFirst("/", "");
241-
}
242-
}
243-
}
244-
};
245-
246-
try {
247-
repository.log(new String[] {""}, Long.parseLong(revision), Long.parseLong(revision), true, true, 1, handler);
248-
return getFileContent(branchNames[0].equals(MASTER_PATH) ? null : branchNames[0], filePath, revision);
249-
} catch (SVNException e) {
250-
throw new EVCSException(e);
251-
252-
} catch (Exception e) {
253-
throw new RuntimeException(e);
254-
}
255-
}
256-
257-
private String getFileContent(String branchName, String filePath, String revision) {
227+
public String getFileContent(String branchName, String filePath, String revision) {
258228
ByteArrayOutputStream baos = new ByteArrayOutputStream();
259229
try {
260230
repository.getFile(new File(getBranchName(branchName), filePath).getPath().replace("\\", "/"),
@@ -269,7 +239,7 @@ private String getFileContent(String branchName, String filePath, String revisio
269239
} catch (SVNException e1) {
270240
throw new EVCSException(e1);
271241
}
272-
throw new EVCSFileNotFound(getRepoUrl(), filePath, revision);
242+
throw new EVCSFileNotFound(getRepoUrl(), getBranchName(branchName), filePath, revision);
273243
}
274244
throw new EVCSException(e);
275245
} catch (Exception e) {

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public void testGetFileContentExceptions() throws Exception {
267267
svn.setSVNRepository(mockedRepo);
268268
doThrow(testSVNException).when(mockedRepo).getFile(anyString(), anyLong(), any(SVNProperties.class), any(OutputStream.class));
269269
try {
270-
vcs.getFileContentFromBranch("", "");
270+
vcs.getFileContent("", "", "");
271271
fail();
272272
} catch (EVCSException e) {
273273
checkEVCSException(e);
@@ -276,7 +276,7 @@ public void testGetFileContentExceptions() throws Exception {
276276
SVNRepository repo = svn.getSVNRepository();
277277
svn.setSVNRepository(null);
278278
try {
279-
vcs.getFileContentFromBranch("", "");
279+
vcs.getFileContent("", "", "");
280280
fail();
281281
} catch (RuntimeException e) {
282282
assertTrue(e.getCause() instanceof NullPointerException);
@@ -286,7 +286,7 @@ public void testGetFileContentExceptions() throws Exception {
286286
doCallRealMethod().when(mockedRepo).getFile(anyString(), anyLong(), any(SVNProperties.class), any(OutputStream.class));
287287
doThrow(testSVNException).when(mockedRepo).checkPath(anyString(), anyLong());
288288
try {
289-
vcs.getFileContentFromBranch("wrong-branch", "");
289+
vcs.getFileContent("wrong-branch", "", "");
290290
fail();
291291
} catch (EVCSException e) {
292292
checkEVCSException(e);

0 commit comments

Comments
 (0)