Mercurial > hg > mercurial
changeset 397:36b1bc5add89 Faradi-7.0.x
Method getContent() should throw exception for non-existing files
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Thu, 01 Mar 2012 20:15:42 +0400 |
parents | 0dc8e99dc529 |
children | 3491c67a0b35 45f25ca68312 |
files | mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java |
diffstat | 2 files changed, 15 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java Wed Feb 29 12:22:51 2012 +0400 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java Thu Mar 01 20:15:42 2012 +0400 @@ -165,21 +165,14 @@ CatCommand cc = new CatCommand(settings, workingDir); cc.setRevId(cset.getId()); File parentDir = cc.execute(Collections.singletonList(filePath)); + File file = new File(parentDir, filePath); try { - File file = new File(parentDir, filePath); - if (file.isFile()) { - try { - return FileUtil.loadFileBytes(file); - } catch (IOException e) { - throw new VcsException("Failed to load content of file: " + file.getAbsolutePath(), e); - } - } else { - Loggers.VCS.warn("Unable to obtain content of the file: " + filePath); - } + return FileUtil.loadFileBytes(file); + } catch (IOException e) { + throw new VcsException("Failed to load content of file " + filePath + " at revision " + version, e); } finally { deleteTmpDir(parentDir); } - return new byte[0]; } @NotNull
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java Wed Feb 29 12:22:51 2012 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java Thu Mar 01 20:15:42 2012 +0400 @@ -215,6 +215,17 @@ assertEquals(new String(content), "file from the test_branch\r\nfile modified"); } + public void get_content_of_non_existing_file_should_throw_exception() throws Exception { + VcsRootImpl vcsRoot = createVcsRoot(simpleRepo()); + + try { + myVcs.getContent("non/existing/file", vcsRoot, "8:04c3ae4c6312"); + fail("getContent() should throw exception for non-existing file"); + } catch (VcsException e) { + assertTrue(true); + } + } + public void test_test_connection() throws IOException, VcsException { VcsRootImpl vcsRoot = createVcsRoot(simpleRepo()); vcsRoot.addProperty(Constants.REPOSITORY_PROP, "/some/non/existent/path");