Mercurial > hg > mercurial
changeset 762:7bf456c8db53
fix compilation
author | eugene.petrenko@jetbrains.com |
---|---|
date | Tue, 25 Feb 2014 11:58:12 +0100 |
parents | 196f62e515db |
children | d34bfe6e662d |
files | mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialLogTemplate.java mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RepoFactory.java |
diffstat | 2 files changed, 15 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialLogTemplate.java Tue Feb 25 11:53:50 2014 +0100 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialLogTemplate.java Tue Feb 25 11:58:12 2014 +0100 @@ -34,39 +34,32 @@ public class MercurialLogTemplate implements MercurialTemplate { private final String myResourcePath; private final String myTmpFileSuffix; - private File myFile; public MercurialLogTemplate(@NotNull final String resourcePath, @NotNull final String tmpFileSuffix) throws IOException { myResourcePath = resourcePath; myTmpFileSuffix = tmpFileSuffix; - copyTemplate(); } @NotNull - public File getTemplate() throws VcsException { - if (myFile.isFile() && myFile.exists()) - return myFile; + public <T> T withTemplate(@NotNull final WithTemplate<T> action) throws VcsException { + //TODO: we may pack plugin and use jetbrains.buildServer.web.openapi.PluginDescriptor.getPluginRoot() + //TODO: to get path to existing file + final File template = copyTemplate(); try { - copyTemplate(); - return myFile; + return action.action(template); + } finally { + delete(template); + } + } + + private File copyTemplate() throws VcsException { + try { + final File template = createTempFile("teamcity", myTmpFileSuffix); + FileUtil.copyResource(getClass(), myResourcePath, template); + return template; } catch (IOException e) { throw new VcsException("Cannot create mercurial log template", e); } } - - @NotNull - public <T> T withTemplate(@NotNull final WithTemplate<T> action) throws VcsException { - return action.action(getTemplate()); - } - - public void dispose() { - delete(myFile); - } - - private void copyTemplate() throws IOException { - File template = createTempFile("teamcity", myTmpFileSuffix); - FileUtil.copyResource(getClass(), myResourcePath, template); - myFile = template; - } }
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RepoFactory.java Tue Feb 25 11:53:50 2014 +0100 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RepoFactory.java Tue Feb 25 11:58:12 2014 +0100 @@ -63,10 +63,6 @@ } public void dispose() { - myLogTemplate.dispose(); - myLogNoFilesTemplate.dispose(); - myDagTemplate.dispose(); - myFastLogTemplate.dispose(); } }