changeset 757:b7deb8f24278

replace bare File with MercurialLogTemplate
author eugene.petrenko@jetbrains.com
date Tue, 25 Feb 2014 11:36:50 +0100
parents b0d6b9c1123b
children 090a7e5e157e
files mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LoadDagCommand.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommand.java mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RepoFactory.java mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerHgRepo.java mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CollectChangesNoRevsets.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubrepoChangesTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommandTest.java
diffstat 7 files changed, 31 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LoadDagCommand.java	Tue Feb 25 11:33:12 2014 +0100
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LoadDagCommand.java	Tue Feb 25 11:36:50 2014 +0100
@@ -17,6 +17,7 @@
 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
 
 import com.intellij.openapi.util.Pair;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialLogTemplate;
 import jetbrains.buildServer.util.StringUtil;
 import jetbrains.buildServer.vcs.VcsException;
 import org.jetbrains.annotations.NotNull;
@@ -27,14 +28,14 @@
 
 public class LoadDagCommand extends VcsRootCommand {
 
-  private final File myDagLogTemplate;
+  private final MercurialLogTemplate myDagLogTemplate;
   private int myMaxDagNodesCount;
 
   public LoadDagCommand(@NotNull CommandSettings commandSettings,
                         @NotNull String hgPath,
                         @NotNull File workingDir,
                         @NotNull AuthSettings authSettings,
-                        @NotNull File dagLogTemplate) {
+                        @NotNull MercurialLogTemplate dagLogTemplate) {
     super(commandSettings, hgPath, workingDir, authSettings);
     myDagLogTemplate = dagLogTemplate;
   }
@@ -48,7 +49,7 @@
     List<Pair<String, String>> edges = new ArrayList<Pair<String, String>>();
     MercurialCommandLine cli = createCommandLine();
     cli.addParameter("log");
-    cli.addParameter("--style=" + myDagLogTemplate.getAbsolutePath());
+    cli.addParameter("--style=" + myDagLogTemplate.getTemplate().getAbsolutePath());
     if (myMaxDagNodesCount > 0)
       cli.addParameters("--limit", String.valueOf(myMaxDagNodesCount));
     CommandResult res = runCommand(cli);
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommand.java	Tue Feb 25 11:33:12 2014 +0100
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommand.java	Tue Feb 25 11:36:50 2014 +0100
@@ -16,6 +16,7 @@
 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
 
 import com.intellij.openapi.diagnostic.Logger;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialLogTemplate;
 import jetbrains.buildServer.vcs.VcsException;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -43,7 +44,7 @@
   private String myBranchName;
   private boolean myCalculateParents = true;
   private String myRevsets;
-  private File myTemplate;
+  private MercurialLogTemplate myTemplate;
   private List<String> myFiles = new ArrayList<String>();
 
   public LogCommand(@NotNull CommandSettings commandSettings,
@@ -53,7 +54,7 @@
     super(commandSettings, hgPath, workingDir, authSettings);
   }
 
-  public LogCommand withTemplate(@NotNull File template) {
+  public LogCommand withTemplate(@NotNull MercurialLogTemplate template) {
     myTemplate = template;
     return this;
   }
@@ -110,7 +111,7 @@
     cli.addParameter("log");
     cli.addParameter("-v");
     if (myTemplate != null)
-      cli.addParameter("--style=" + myTemplate.getAbsolutePath());
+      cli.addParameter("--style=" + myTemplate.getTemplate().getAbsolutePath());
     if (myBranchName != null) {
       cli.addParameter("-b");
       cli.addParameter(myBranchName);
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RepoFactory.java	Tue Feb 25 11:33:12 2014 +0100
+++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RepoFactory.java	Tue Feb 25 11:36:50 2014 +0100
@@ -52,10 +52,10 @@
                              @NotNull String hgPath,
                              @NotNull AuthSettings authSettings) throws VcsException {
     return new ServerHgRepo(myCommandSettingsFactory, myConfig, workingDir, hgPath, authSettings)
-            .withLogTemplates(myLogTemplate.getTemplate(),
-                    myLogNoFilesTemplate.getTemplate(),
-                    myDagTemplate.getTemplate(),
-                    myFastLogTemplate.getTemplate());
+            .withLogTemplates(myLogTemplate,
+                    myLogNoFilesTemplate,
+                    myDagTemplate,
+                    myFastLogTemplate);
   }
 
   public HgRepo createRepo(@NotNull HgVcsRoot root, @NotNull File workingDir) throws VcsException {
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerHgRepo.java	Tue Feb 25 11:33:12 2014 +0100
+++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerHgRepo.java	Tue Feb 25 11:36:50 2014 +0100
@@ -39,10 +39,10 @@
   private final static HgVersion REVSET_HG_VERSION = new HgVersion(1, 7, 0);
   private final CommandSettingsFactory myCommandSettingsFactory;
   private final ServerPluginConfig myConfig;
-  private File myLogTemplate;
-  private File myLogNoFilesTemplate;
-  private File myDagTemplate;
-  private File myFastLogTemplate;
+  private MercurialLogTemplate myLogTemplate;
+  private MercurialLogTemplate myLogNoFilesTemplate;
+  private MercurialLogTemplate myDagTemplate;
+  private MercurialLogTemplate myFastLogTemplate;
   private OperationContext myContext;
 
   public ServerHgRepo(@NotNull CommandSettingsFactory commandSettingsFactory,
@@ -59,10 +59,10 @@
     myContext = context;
   }
 
-  public ServerHgRepo withLogTemplates(@NotNull File logTemplate,
-                                       @NotNull File logNoFilesTemplate,
-                                       @NotNull File dagTemplate,
-                                       @NotNull File fastLogTemplate) {
+  public ServerHgRepo withLogTemplates(@NotNull MercurialLogTemplate logTemplate,
+                                       @NotNull MercurialLogTemplate logNoFilesTemplate,
+                                       @NotNull MercurialLogTemplate dagTemplate,
+                                       @NotNull MercurialLogTemplate fastLogTemplate) {
     myLogTemplate = logTemplate;
     myLogNoFilesTemplate = logNoFilesTemplate;
     myDagTemplate = dagTemplate;
@@ -80,7 +80,7 @@
   }
 
   public LogCommand log(@NotNull HgVcsRoot root) {
-    File template = root.isSubrepo() && !myConfig.reportSubrepoChangesFileStatus() ? myFastLogTemplate : myLogTemplate;
+    final MercurialLogTemplate template = root.isSubrepo() && !myConfig.reportSubrepoChangesFileStatus() ? myFastLogTemplate : myLogTemplate;
     return new LogCommand(myCommandSettingsFactory.create(), myHgPath, myWorkingDir, myAuthSettings).withTemplate(template);
   }
 
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CollectChangesNoRevsets.java	Tue Feb 25 11:33:12 2014 +0100
+++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CollectChangesNoRevsets.java	Tue Feb 25 11:36:50 2014 +0100
@@ -17,6 +17,7 @@
 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
 
 import com.intellij.openapi.util.Pair;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialLogTemplate;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.ServerHgRepo;
 import jetbrains.buildServer.util.graph.DAG;
 import jetbrains.buildServer.util.graph.DAGIterator;
@@ -24,7 +25,6 @@
 import jetbrains.buildServer.vcs.VcsException;
 import org.jetbrains.annotations.NotNull;
 
-import java.io.File;
 import java.util.*;
 
 /**
@@ -34,9 +34,9 @@
 
   private final HgVcsRoot myRoot;
   private final ServerHgRepo myRepo;
-  private final File myLogNoFilesTemplate;
+  private final MercurialLogTemplate myLogNoFilesTemplate;
 
-  public CollectChangesNoRevsets(@NotNull HgVcsRoot root, @NotNull ServerHgRepo repo, @NotNull File logNoFilesTemplate) {
+  public CollectChangesNoRevsets(@NotNull HgVcsRoot root, @NotNull ServerHgRepo repo, @NotNull MercurialLogTemplate logNoFilesTemplate) {
     myRoot = root;
     myRepo = repo;
     myLogNoFilesTemplate = logNoFilesTemplate;
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubrepoChangesTest.java	Tue Feb 25 11:33:12 2014 +0100
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubrepoChangesTest.java	Tue Feb 25 11:36:50 2014 +0100
@@ -235,10 +235,10 @@
       @Override
       public ServerHgRepo create(@NotNull File workingDir, @NotNull String hgPath, @NotNull AuthSettings authSettings) throws VcsException {
         return new CountingServerHgRepo(myCommandSettingsFactory, myConfig, workingDir, hgPath, authSettings, catCallCounter)
-                .withLogTemplates(myLogTemplate.getTemplate(),
-                        myLogNoFilesTemplate.getTemplate(),
-                        myDagTemplate.getTemplate(),
-                        myFastLogTemplate.getTemplate());
+                .withLogTemplates(myLogTemplate,
+                        myLogNoFilesTemplate,
+                        myDagTemplate,
+                        myFastLogTemplate);
       }
     };
 
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommandTest.java	Tue Feb 25 11:33:12 2014 +0100
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommandTest.java	Tue Feb 25 11:36:50 2014 +0100
@@ -17,8 +17,7 @@
 
 import jetbrains.buildServer.TempFiles;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.HgPathProvider;
-import jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialVcsSupport;
-import jetbrains.buildServer.util.FileUtil;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialLogTemplate;
 import jetbrains.buildServer.vcs.VcsException;
 import org.jetbrains.annotations.NotNull;
 import org.testng.annotations.AfterMethod;
@@ -35,7 +34,7 @@
 public class LogCommandTest extends BaseCommandTestCase {
 
   private TempFiles myTempFiles = new TempFiles();
-  private File myTemplateFile;
+  private MercurialLogTemplate myTemplateFile;
 
 
   @BeforeMethod
@@ -43,8 +42,7 @@
   protected void setUp() throws Exception {
     super.setUp();
     setRepository("mercurial-tests/testData/rep1", true);
-    myTemplateFile = myTempFiles.createTempFile();
-    FileUtil.copyResource(MercurialVcsSupport.class, "/buildServerResources/log.template", myTemplateFile);
+    myTemplateFile = new MercurialLogTemplate("/buildServerResources/log.template", myTempFiles.createTempDir().getAbsolutePath()) {};
   }