Mercurial > hg > mercurial
view mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialSupportBuilder.java @ 715:be86907926ae
new approach: remember hg sub-state file hash per commit,
dump hash -> file, and log with refs
author | eugene.petrenko@jetbrains.com |
---|---|
date | Mon, 13 Jan 2014 18:51:13 +0100 |
parents | 32d2a04206c8 |
children | 31a1aca3305c |
line wrap: on
line source
package jetbrains.buildServer.buildTriggers.vcs.mercurial; 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.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 TestCommandSettingsFactory(), 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(dispatcher, resetCacheManager, myConfig, myHgPathProvider, 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; } }