changeset 754:aae33e807ab3

extract MercurialLogTemplate class
author eugene.petrenko@jetbrains.com
date Tue, 25 Feb 2014 11:30:28 +0100
parents 6b7579d76fdf
children 3f1ee5ff67bb
files mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialLogTemplate.java mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RepoFactory.java
diffstat 2 files changed, 67 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialLogTemplate.java	Tue Feb 25 11:30:28 2014 +0100
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jetbrains.buildServer.buildTriggers.vcs.mercurial;
+
+import jetbrains.buildServer.util.FileUtil;
+import jetbrains.buildServer.vcs.VcsException;
+import org.jetbrains.annotations.NotNull;
+
+import java.io.File;
+import java.io.IOException;
+
+import static com.intellij.openapi.util.io.FileUtil.createTempFile;
+import static com.intellij.openapi.util.io.FileUtil.delete;
+
+/**
+* Created 25.02.14 11:29
+*
+* @author Eugene Petrenko (eugene.petrenko@jetbrains.com)
+*/
+public class MercurialLogTemplate {
+  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;
+    try {
+      copyTemplate();
+      return myFile;
+    } catch (IOException e) {
+      throw new VcsException("Cannot create mercurial log template", e);
+    }
+  }
+
+  public void dispose() {
+    delete(myFile);
+  }
+
+  private void copyTemplate() throws IOException {
+    File template = createTempFile("teamcity", myTmpFileSuffix);
+    FileUtil.copyResource(RepoFactory.class, myResourcePath, template);
+    myFile = template;
+  }
+}
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RepoFactory.java	Mon Feb 24 19:23:01 2014 +0100
+++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RepoFactory.java	Tue Feb 25 11:30:28 2014 +0100
@@ -19,16 +19,12 @@
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.AuthSettings;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandSettingsFactory;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot;
-import jetbrains.buildServer.util.FileUtil;
 import jetbrains.buildServer.vcs.VcsException;
 import org.jetbrains.annotations.NotNull;
 
 import java.io.File;
 import java.io.IOException;
 
-import static com.intellij.openapi.util.io.FileUtil.createTempFile;
-import static com.intellij.openapi.util.io.FileUtil.delete;
-
 /**
  * @author dmitry.neverov
  */
@@ -73,37 +69,4 @@
     myFastLogTemplate.dispose();
   }
 
-  static class MercurialLogTemplate {
-    private final String myResourcePath;
-    private final String myTmpFileSuffix;
-    private File myFile;
-
-    private MercurialLogTemplate(@NotNull String resourcePath, @NotNull String tmpFileSuffix) throws IOException {
-      myResourcePath = resourcePath;
-      myTmpFileSuffix = tmpFileSuffix;
-      copyTemplate();
-    }
-
-    @NotNull
-    public File getTemplate() throws VcsException {
-      if (myFile.isFile() && myFile.exists())
-        return myFile;
-      try {
-        copyTemplate();
-        return myFile;
-      } catch (IOException e) {
-        throw new VcsException("Cannot create mercurial log template", e);
-      }
-    }
-
-    public void dispose() {
-      delete(myFile);
-    }
-
-    private void copyTemplate() throws IOException {
-      File template = createTempFile("teamcity", myTmpFileSuffix);
-      FileUtil.copyResource(RepoFactory.class, myResourcePath, template);
-      myFile = template;
-    }
-  }
 }