Mercurial > hg > mercurial
view mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialSupportBuilder.java @ 888:207c4ec46d54
CommitSupport: return CommitResult instead of revision
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Mon, 03 Nov 2014 12:53:47 +0100 |
parents | 45311425ee3c |
children | 7bf4d943d5bb |
line wrap: on
line source
/* * 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.buildTriggers.vcs.mercurial.command.CommandSettingsForRootImpl; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandlineViaFileWrapperWeaver; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.ExtensionsWeaver; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.TestCommandSettingsFactory; import jetbrains.buildServer.serverSide.ServerListener; import jetbrains.buildServer.util.EventDispatcher; import jetbrains.buildServer.util.cache.ResetCacheHandler; import jetbrains.buildServer.util.cache.ResetCacheRegister; import jetbrains.buildServer.vcs.MockVcsOperationProgressProvider; import jetbrains.buildServer.vcs.SubrepoCheckoutRulesProviderImpl; import org.jetbrains.annotations.NotNull; import org.jmock.Expectations; import org.jmock.Mockery; import java.io.IOException; import java.util.ArrayList; import java.util.List; public class MercurialSupportBuilder { private Mockery myContext; private ServerPluginConfig myConfig; private List<MercurialServerExtension> myExtensions = new ArrayList<MercurialServerExtension>(); private HgVcsRootFactory myHgRootFactory; private RepoFactory myRepoFactory; private ServerHgPathProvider myHgPathProvider; public static MercurialSupportBuilder mercurialSupport() { return new MercurialSupportBuilder(); } @NotNull public MercurialVcsSupport build() throws IOException { if (myContext == null) myContext = new Mockery(); EventDispatcher<ServerListener> dispatcher = EventDispatcher.create(ServerListener.class); myHgRootFactory = new HgVcsRootFactory(myConfig); MirrorManagerImpl mirrorManager = new MirrorManagerImpl(myConfig); myHgPathProvider = new ServerHgPathProvider(myConfig); if (myRepoFactory == null) myRepoFactory = new RepoFactory(myConfig, new CommandSettingsForRootImpl(new TestCommandSettingsFactory(), new ExtensionsWeaver(), new CommandlineViaFileWrapperWeaver()), myHgPathProvider); HgTestConnectionSupport testConnection = new HgTestConnectionSupport(myHgRootFactory, myRepoFactory, mirrorManager, myHgPathProvider); final ResetCacheRegister resetCacheManager = myContext.mock(ResetCacheRegister.class); myContext.checking(new Expectations() {{ allowing(resetCacheManager).registerHandler(with(any(ResetCacheHandler.class))); }}); MercurialVcsSupport vcs = new MercurialVcsSupport(new MockVcsOperationProgressProvider(), dispatcher, resetCacheManager, myConfig, myRepoFactory, mirrorManager, myHgRootFactory, testConnection, new SubrepoCheckoutRulesProviderImpl()); vcs.addExtensions(myExtensions); return vcs; } public MercurialSupportBuilder withConfig(@NotNull ServerPluginConfig config) { myConfig = config; return this; } public MercurialSupportBuilder withRepoFactory(@NotNull RepoFactory repoFactory) { myRepoFactory = repoFactory; return this; } public HgVcsRootFactory getHgRootFactory() { return myHgRootFactory; } public RepoFactory getHgRepoFactory() { return myRepoFactory; } public ServerHgPathProvider getHgPathProvider() { return myHgPathProvider; } }