Mercurial > hg > mercurial
changeset 761:196f62e515db
extract superclass
line wrap: on
line diff
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialLogTemplate.java Tue Feb 25 11:48:56 2014 +0100 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialLogTemplate.java Tue Feb 25 11:53:50 2014 +0100 @@ -31,7 +31,7 @@ * * @author Eugene Petrenko (eugene.petrenko@jetbrains.com) */ -public class MercurialLogTemplate { +public class MercurialLogTemplate implements MercurialTemplate { private final String myResourcePath; private final String myTmpFileSuffix; private File myFile; @@ -55,11 +55,6 @@ } } - public interface WithTemplate<T> { - @NotNull - T action(@NotNull final File template) throws VcsException; - } - @NotNull public <T> T withTemplate(@NotNull final WithTemplate<T> action) throws VcsException { return action.action(getTemplate());
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialTemplate.java Tue Feb 25 11:53:50 2014 +0100 @@ -0,0 +1,37 @@ +/* + * 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.vcs.VcsException; +import org.jetbrains.annotations.NotNull; + +import java.io.File; + +/** + * Created 25.02.14 11:51 + * + * @author Eugene Petrenko (eugene.petrenko@jetbrains.com) + */ +public interface MercurialTemplate { + @NotNull + <T> T withTemplate(@NotNull WithTemplate<T> action) throws VcsException; + + interface WithTemplate<T> { + @NotNull + T action(@NotNull final File template) throws VcsException; + } +}
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LoadDagCommand.java Tue Feb 25 11:48:56 2014 +0100 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LoadDagCommand.java Tue Feb 25 11:53:50 2014 +0100 @@ -17,7 +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.MercurialTemplate; import jetbrains.buildServer.util.StringUtil; import jetbrains.buildServer.vcs.VcsException; import org.jetbrains.annotations.NotNull; @@ -28,14 +28,14 @@ public class LoadDagCommand extends VcsRootCommand { - private final MercurialLogTemplate myDagLogTemplate; + private final MercurialTemplate myDagLogTemplate; private int myMaxDagNodesCount; public LoadDagCommand(@NotNull CommandSettings commandSettings, @NotNull String hgPath, @NotNull File workingDir, @NotNull AuthSettings authSettings, - @NotNull MercurialLogTemplate dagLogTemplate) { + @NotNull MercurialTemplate dagLogTemplate) { super(commandSettings, hgPath, workingDir, authSettings); myDagLogTemplate = dagLogTemplate; } @@ -46,7 +46,7 @@ @NotNull public List<Pair<String, String>> call() throws VcsException { - return myDagLogTemplate.withTemplate(new MercurialLogTemplate.WithTemplate<List<Pair<String, String>>>() { + return myDagLogTemplate.withTemplate(new MercurialTemplate.WithTemplate<List<Pair<String, String>>>() { @NotNull public List<Pair<String, String>> action(@NotNull File template) throws VcsException { final List<Pair<String, String>> edges = new ArrayList<Pair<String, String>>();
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommand.java Tue Feb 25 11:48:56 2014 +0100 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommand.java Tue Feb 25 11:53:50 2014 +0100 @@ -16,7 +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.buildTriggers.vcs.mercurial.MercurialTemplate; import jetbrains.buildServer.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -44,7 +44,7 @@ private String myBranchName; private boolean myCalculateParents = true; private String myRevsets; - private MercurialLogTemplate myTemplate; + private MercurialTemplate myTemplate; private List<String> myFiles = new ArrayList<String>(); public LogCommand(@NotNull CommandSettings commandSettings, @@ -54,7 +54,7 @@ super(commandSettings, hgPath, workingDir, authSettings); } - public LogCommand withTemplate(@NotNull MercurialLogTemplate template) { + public LogCommand withTemplate(@NotNull MercurialTemplate template) { myTemplate = template; return this; } @@ -106,7 +106,7 @@ @NotNull public List<ChangeSet> call() throws VcsException { - return myTemplate.withTemplate(new MercurialLogTemplate.WithTemplate<List<ChangeSet>>() { + return myTemplate.withTemplate(new MercurialTemplate.WithTemplate<List<ChangeSet>>() { @NotNull public List<ChangeSet> action(@NotNull File template) throws VcsException { final MercurialCommandLine cli = createCommandLine();
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerHgRepo.java Tue Feb 25 11:48:56 2014 +0100 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerHgRepo.java Tue Feb 25 11:53: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 MercurialLogTemplate myLogTemplate; - private MercurialLogTemplate myLogNoFilesTemplate; - private MercurialLogTemplate myDagTemplate; - private MercurialLogTemplate myFastLogTemplate; + private MercurialTemplate myLogTemplate; + private MercurialTemplate myLogNoFilesTemplate; + private MercurialTemplate myDagTemplate; + private MercurialTemplate myFastLogTemplate; private OperationContext myContext; public ServerHgRepo(@NotNull CommandSettingsFactory commandSettingsFactory, @@ -59,10 +59,10 @@ myContext = context; } - public ServerHgRepo withLogTemplates(@NotNull MercurialLogTemplate logTemplate, - @NotNull MercurialLogTemplate logNoFilesTemplate, - @NotNull MercurialLogTemplate dagTemplate, - @NotNull MercurialLogTemplate fastLogTemplate) { + public ServerHgRepo withLogTemplates(@NotNull MercurialTemplate logTemplate, + @NotNull MercurialTemplate logNoFilesTemplate, + @NotNull MercurialTemplate dagTemplate, + @NotNull MercurialTemplate fastLogTemplate) { myLogTemplate = logTemplate; myLogNoFilesTemplate = logNoFilesTemplate; myDagTemplate = dagTemplate; @@ -80,7 +80,7 @@ } public LogCommand log(@NotNull HgVcsRoot root) { - final MercurialLogTemplate template = root.isSubrepo() && !myConfig.reportSubrepoChangesFileStatus() ? myFastLogTemplate : myLogTemplate; + final MercurialTemplate 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:48:56 2014 +0100 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CollectChangesNoRevsets.java Tue Feb 25 11:53:50 2014 +0100 @@ -17,7 +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.MercurialTemplate; import jetbrains.buildServer.buildTriggers.vcs.mercurial.ServerHgRepo; import jetbrains.buildServer.util.graph.DAG; import jetbrains.buildServer.util.graph.DAGIterator; @@ -34,9 +34,9 @@ private final HgVcsRoot myRoot; private final ServerHgRepo myRepo; - private final MercurialLogTemplate myLogNoFilesTemplate; + private final MercurialTemplate myLogNoFilesTemplate; - public CollectChangesNoRevsets(@NotNull HgVcsRoot root, @NotNull ServerHgRepo repo, @NotNull MercurialLogTemplate logNoFilesTemplate) { + public CollectChangesNoRevsets(@NotNull HgVcsRoot root, @NotNull ServerHgRepo repo, @NotNull MercurialTemplate logNoFilesTemplate) { myRoot = root; myRepo = repo; myLogNoFilesTemplate = logNoFilesTemplate;
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommandTest.java Tue Feb 25 11:48:56 2014 +0100 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommandTest.java Tue Feb 25 11:53:50 2014 +0100 @@ -18,6 +18,7 @@ import jetbrains.buildServer.TempFiles; import jetbrains.buildServer.buildTriggers.vcs.mercurial.HgPathProvider; import jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialLogTemplate; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialTemplate; import jetbrains.buildServer.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.testng.annotations.AfterMethod; @@ -34,7 +35,7 @@ public class LogCommandTest extends BaseCommandTestCase { private TempFiles myTempFiles = new TempFiles(); - private MercurialLogTemplate myTemplateFile; + private MercurialTemplate myTemplateFile; @BeforeMethod