# HG changeset patch # User Dmitry Neverov # Date 1336737357 -14400 # Node ID c91c4f1ebd53c943aaee8b799810829d01f5e598 # Parent e33c3e4918f5565dd07b988b5c8840564ee4e8fc Settings -> HgVcsRoot diff -r e33c3e4918f5 -r c91c4f1ebd53 mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentHgPathProvider.java --- a/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentHgPathProvider.java Fri May 11 15:21:35 2012 +0400 +++ b/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentHgPathProvider.java Fri May 11 15:55:57 2012 +0400 @@ -1,7 +1,7 @@ package jetbrains.buildServer.buildTriggers.vcs.mercurial; import jetbrains.buildServer.agent.BuildAgentConfiguration; -import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.Settings; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot; import jetbrains.buildServer.parameters.ProcessingResult; import jetbrains.buildServer.parameters.ValueResolver; import org.jetbrains.annotations.NotNull; @@ -19,8 +19,8 @@ } - public String getHgPath(@NotNull final Settings settings) { - String pathFromRoot = settings.getHgPath(); + public String getHgPath(@NotNull final HgVcsRoot root) { + String pathFromRoot = root.getHgPath(); return resolve(pathFromRoot); } diff -r e33c3e4918f5 -r c91c4f1ebd53 mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentMirrorCleaner.java --- a/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentMirrorCleaner.java Fri May 11 15:21:35 2012 +0400 +++ b/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentMirrorCleaner.java Fri May 11 15:55:57 2012 +0400 @@ -5,7 +5,7 @@ import jetbrains.buildServer.agent.DirectoryCleanersProviderContext; import jetbrains.buildServer.agent.DirectoryCleanersRegistry; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.AuthSettings; -import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.Settings; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot; import jetbrains.buildServer.vcs.VcsRoot; import jetbrains.buildServer.vcs.VcsRootEntry; import org.jetbrains.annotations.NotNull; @@ -53,11 +53,11 @@ Set repositories = new HashSet(); for (VcsRootEntry entry : context.getRunningBuild().getVcsRootEntries()) { VcsRoot root = entry.getVcsRoot(); - Settings s = new Settings(myHgPathProvider, root); - AuthSettings auth = s.getAuthSettings(); - ourLog.debug("Repository " + auth.getRepositoryUrlWithHiddenPassword(s.getRepository()) + + HgVcsRoot hgRoot = new HgVcsRoot(myHgPathProvider, root); + AuthSettings auth = hgRoot.getAuthSettings(); + ourLog.debug("Repository " + auth.getRepositoryUrlWithHiddenPassword(hgRoot.getRepository()) + " is used in the build, its mirror won't be cleaned"); - repositories.add(s.getRepository()); + repositories.add(hgRoot.getRepository()); } return repositories; } diff -r e33c3e4918f5 -r c91c4f1ebd53 mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialIncludeRuleUpdater.java --- a/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialIncludeRuleUpdater.java Fri May 11 15:21:35 2012 +0400 +++ b/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialIncludeRuleUpdater.java Fri May 11 15:55:57 2012 +0400 @@ -4,7 +4,7 @@ import jetbrains.buildServer.agent.BuildProgressLogger; import jetbrains.buildServer.agent.vcs.IncludeRuleUpdater; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.AuthSettings; -import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.Settings; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception.UnrelatedRepositoryException; import jetbrains.buildServer.vcs.IncludeRule; import jetbrains.buildServer.vcs.VcsException; @@ -24,7 +24,7 @@ private final AgentPluginConfig myConfig; private final MirrorManager myMirrorManager; - private final Settings mySettings; + private final HgVcsRoot myRoot; private final AuthSettings myAuthSettings; private final String myHgPath; private final String myToVersion; @@ -40,9 +40,9 @@ @NotNull final AgentRunningBuild build) { myConfig = pluginConfig; myMirrorManager = mirrorManager; - mySettings = new Settings(hgPathProvider, root); - myAuthSettings = mySettings.getAuthSettings(); - myHgPath = mySettings.getHgCommandPath(); + myRoot = new HgVcsRoot(hgPathProvider, root); + myAuthSettings = myRoot.getAuthSettings(); + myHgPath = myRoot.getHgCommandPath(); myToVersion = toVersion; myLogger = build.getBuildLogger(); myUseLocalMirrors = myConfig.isUseLocalMirrors(build); @@ -54,9 +54,9 @@ try { checkRuleIsValid(rule); if (myUseLocalMirrors) - updateLocalMirror(mySettings.getRepository(), myToVersion); + updateLocalMirror(myRoot.getRepository(), myToVersion); updateRepository(workingDir); - updateWorkingDir(workingDir, myToVersion, mySettings.getRepository()); + updateWorkingDir(workingDir, myToVersion, myRoot.getRepository()); } catch (Exception e) { throwVcsException(e); } @@ -76,7 +76,7 @@ mirrorRepo.doClone().fromRepository(repositoryUrl) .setUpdateWorkingDir(false) .setUsePullProtocol(false) - .useUncompressedTransfer(mySettings.isUncompressedTransfer()) + .useUncompressedTransfer(myRoot.isUncompressedTransfer()) .call(); myLogger.message("Clone successfully finished"); } else { @@ -95,7 +95,7 @@ private void updateRepository(@NotNull File workingDir) throws VcsException, IOException { - String repositoryUrl = getDefaultPullUrl(mySettings, myUseLocalMirrors); + String repositoryUrl = getDefaultPullUrl(myRoot, myUseLocalMirrors); HgRepo repo = new HgRepo(workingDir, myHgPath, myAuthSettings); myLogger.message("Update repository " + workingDir.getAbsolutePath()); if (repo.isEmpty()) {//can do clone only in empty dir @@ -103,14 +103,14 @@ repo.doClone().fromRepository(repositoryUrl) .setUsePullProtocol(false) .setUpdateWorkingDir(false) - .useUncompressedTransfer(!myUseLocalMirrors && mySettings.isUncompressedTransfer()) + .useUncompressedTransfer(!myUseLocalMirrors && myRoot.isUncompressedTransfer()) .call(); - repo.setDefaultPath(mySettings.getRepository()); + repo.setDefaultPath(myRoot.getRepository()); myLogger.message("Repository successfully cloned"); } else { if (!repo.isValidRepository()) repo.init().call(); - repo.setDefaultPath(mySettings.getRepository()); + repo.setDefaultPath(myRoot.getRepository()); if (repo.containsRevision(myToVersion)) { myLogger.message("Repository already contains revision " + myToVersion); } else { @@ -190,12 +190,12 @@ } - private String getDefaultPullUrl(Settings settings, boolean useLocalMirror) throws IOException { + private String getDefaultPullUrl(HgVcsRoot root, boolean useLocalMirror) throws IOException { if (useLocalMirror) { - File mirrorDir = myMirrorManager.getMirrorDir(settings.getRepository()); + File mirrorDir = myMirrorManager.getMirrorDir(root.getRepository()); return mirrorDir.getCanonicalPath(); } else { - return settings.getRepository(); + return root.getRepository(); } } diff -r e33c3e4918f5 -r c91c4f1ebd53 mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgPathProvider.java --- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgPathProvider.java Fri May 11 15:21:35 2012 +0400 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgPathProvider.java Fri May 11 15:55:57 2012 +0400 @@ -1,6 +1,6 @@ package jetbrains.buildServer.buildTriggers.vcs.mercurial; -import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.Settings; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot; import org.jetbrains.annotations.NotNull; /** @@ -8,6 +8,6 @@ */ public interface HgPathProvider { - String getHgPath(@NotNull Settings settings); + String getHgPath(@NotNull HgVcsRoot root); } diff -r e33c3e4918f5 -r c91c4f1ebd53 mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/HgVcsRoot.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/HgVcsRoot.java Fri May 11 15:55:57 2012 +0400 @@ -0,0 +1,171 @@ +/* + * Copyright 2000-2011 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.command; + +import jetbrains.buildServer.buildTriggers.vcs.mercurial.Constants; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.HgPathProvider; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.PathUtil; +import jetbrains.buildServer.util.StringUtil; +import jetbrains.buildServer.vcs.VcsRoot; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.io.File; +import java.util.Map; + +/** + * Represents mercurial VCS root + */ +public class HgVcsRoot implements VcsRoot { + + private static final String DEFAULT_BRANCH_NAME = "default"; + + private final HgPathProvider myHgPathProvider; + private final VcsRoot myRoot; + private final String myRepository; + private final String myHgCommandPath; + private final String myBranchName; + private final boolean myUncompressedTransfer; + private final String myCustomClonePath; + private final String myUserForTag; + private final AuthSettings myAuthSettings; + private File myCustomWorkingDir; + + public HgVcsRoot(@NotNull final HgPathProvider hgPathProvider, @NotNull final VcsRoot vcsRoot) { + myHgPathProvider = hgPathProvider; + myRoot = vcsRoot; + myRepository = getProperty(Constants.REPOSITORY_PROP); + myHgCommandPath = getProperty(Constants.HG_COMMAND_PATH_PROP); + myBranchName = getProperty(Constants.BRANCH_NAME_PROP); + myCustomClonePath = getProperty(Constants.SERVER_CLONE_PATH_PROP); + myUncompressedTransfer = "true".equals(getProperty(Constants.UNCOMPRESSED_TRANSFER)); + myUserForTag = getProperty(Constants.USER_FOR_TAG); + myAuthSettings = new AuthSettings(getProperty(Constants.USERNAME), getProperty(Constants.PASSWORD)); + } + + public String getCustomClonePath() { + return myCustomClonePath; + } + + public String getRepository() { + return myRepository; + } + + /** + * Returns name of the branch to use (returns 'default' if no branch specified) + * @return see above + */ + @NotNull + public String getBranchName() { + return StringUtil.isEmpty(myBranchName) ? DEFAULT_BRANCH_NAME : myBranchName; + } + + public boolean isUncompressedTransfer() { + return myUncompressedTransfer; + } + + /** + * @return path to hg command taking into account server-wide/agent-wide settings + */ + @NotNull + public String getHgCommandPath() { + return myHgPathProvider.getHgPath(this); + } + + /** + * @return path to hg command as it is set in VCS root settings + */ + public String getHgPath() { + return myHgCommandPath; + } + + @Nullable + public String getUserForTag() { + return myUserForTag; + } + + public String getRepositoryUrlWithCredentials() { + return myAuthSettings.getRepositoryUrlWithCredentials(myRepository); + } + + /** + * Set custom working dir for vcs root. This option make sence only for server-side checkout + * @param customWorkingDir custom working dir + */ + public void setCustomWorkingDir(@NotNull final File customWorkingDir) { + myCustomWorkingDir = PathUtil.getCanonicalFile(customWorkingDir); + } + + /** + * Returns custom working dir for root or null if default working dir should be used. + * This options make sence only with server-side checkout. + * @return see above + */ + @Nullable + public File getCustomWorkingDir() { + return myCustomWorkingDir; + } + + public AuthSettings getAuthSettings() { + return myAuthSettings; + } + + + + public String getVcsName() { + return myRoot.getVcsName(); + } + + public String getProperty(String propertyName) { + return myRoot.getProperty(propertyName); + } + + public String getProperty(String propertyName, String defaultValue) { + return myRoot.getProperty(propertyName, defaultValue); + } + + public Map getProperties() { + return myRoot.getProperties(); + } + + public String convertToString() { + return myRoot.convertToString(); + } + + public String convertToPresentableString() { + return myRoot.convertToPresentableString(); + } + + public long getPropertiesHash() { + return myRoot.getPropertiesHash(); + } + + public long getVcsRepositoryPropertiesHash() { + return myRoot.getVcsRepositoryPropertiesHash(); + } + + public String getName() { + return myRoot.getName(); + } + + public long getId() { + return myRoot.getId(); + } + + public Map getPublicProperties() { + return myRoot.getPublicProperties(); + } +} diff -r e33c3e4918f5 -r c91c4f1ebd53 mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/Settings.java --- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/Settings.java Fri May 11 15:21:35 2012 +0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,146 +0,0 @@ -/* - * Copyright 2000-2011 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.command; - -import jetbrains.buildServer.buildTriggers.vcs.mercurial.Constants; -import jetbrains.buildServer.buildTriggers.vcs.mercurial.HgPathProvider; -import jetbrains.buildServer.buildTriggers.vcs.mercurial.PathUtil; -import jetbrains.buildServer.util.StringUtil; -import jetbrains.buildServer.vcs.VcsRoot; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.File; - -/** - * Represents Mercurial repository settings - */ -public class Settings { - - private final HgPathProvider myHgPathProvider; - private String myRepository; - private String myHgCommandPath; - private File myCustomWorkingDir; - private String myUsername; - private String myPassword; - private String myBranchName; - private boolean myUncompressedTransfer = false; - private static final String DEFAULT_BRANCH_NAME = "default"; - private String myCustomClonePath; - private final String myUserForTag; - private final AuthSettings myAuthSettings; - - public Settings(@NotNull final HgPathProvider hgPathProvider, @NotNull final VcsRoot vcsRoot) { - myHgPathProvider = hgPathProvider; - myRepository = vcsRoot.getProperty(Constants.REPOSITORY_PROP); - myHgCommandPath = vcsRoot.getProperty(Constants.HG_COMMAND_PATH_PROP); - myBranchName = vcsRoot.getProperty(Constants.BRANCH_NAME_PROP); - myCustomClonePath = vcsRoot.getProperty(Constants.SERVER_CLONE_PATH_PROP); - myUsername = vcsRoot.getProperty(Constants.USERNAME); - myPassword = vcsRoot.getProperty(Constants.PASSWORD); - myUncompressedTransfer = "true".equals(vcsRoot.getProperty(Constants.UNCOMPRESSED_TRANSFER)); - myUserForTag = vcsRoot.getProperty(Constants.USER_FOR_TAG); - myAuthSettings = new AuthSettings(myUsername, myPassword); - } - - public String getCustomClonePath() { - return myCustomClonePath; - } - - public String getRepository() { - return myRepository; - } - - /** - * Returns name of the branch to use (returns 'default' if no branch specified) - * @return see above - */ - @NotNull - public String getBranchName() { - return StringUtil.isEmpty(myBranchName) ? DEFAULT_BRANCH_NAME : myBranchName; - } - - /** - * Returns true if current branch is default branch - * @return see above - */ - public boolean isDefaultBranch() { - return getBranchName().equals(DEFAULT_BRANCH_NAME); - } - - public boolean isUncompressedTransfer() { - return myUncompressedTransfer; - } - - /** - * @return path to hg command taking into account server-wide/agent-wide settings - */ - @NotNull - public String getHgCommandPath() { - return myHgPathProvider.getHgPath(this); - } - - /** - * @return path to hg command as it is set in VCS root settings - */ - public String getHgPath() { - return myHgCommandPath; - } - - public String getUsername() { - return myUsername; - } - - public String getPassword() { - return myPassword; - } - - @Nullable - public String getUserForTag() { - return myUserForTag; - } - - public String getRepositoryUrlWithCredentials() { - return myAuthSettings.getRepositoryUrlWithCredentials(myRepository); - } - - /** - * Set custom working dir for vcs root. This option make sence only for server-side checkout - * @param customWorkingDir custom working dir - */ - public void setCustomWorkingDir(@NotNull final File customWorkingDir) { - myCustomWorkingDir = PathUtil.getCanonicalFile(customWorkingDir); - } - - /** - * Returns custom working dir for root or null if default working dir should be used. - * This options make sence only with server-side checkout. - * @return see above - */ - @Nullable - public File getCustomWorkingDir() { - return myCustomWorkingDir; - } - - public AuthSettings getAuthSettings() { - return myAuthSettings; - } - - public static boolean isValidRepository(File dir) { - // need better way to check that repository copy is ok - return dir.isDirectory() && new File(dir, ".hg").isDirectory(); - } -} diff -r e33c3e4918f5 -r c91c4f1ebd53 mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VersionCommand.java --- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VersionCommand.java Fri May 11 15:21:35 2012 +0400 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VersionCommand.java Fri May 11 15:55:57 2012 +0400 @@ -13,8 +13,8 @@ */ public class VersionCommand extends BaseCommand { - public VersionCommand(@NotNull final Settings settings, @NotNull File workingDir) { - super(settings.getHgCommandPath(), workingDir); + public VersionCommand(@NotNull final HgVcsRoot root, @NotNull File workingDir) { + super(root.getHgCommandPath(), workingDir); } diff -r e33c3e4918f5 -r c91c4f1ebd53 mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Cleanup.java --- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Cleanup.java Fri May 11 15:21:35 2012 +0400 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Cleanup.java Fri May 11 15:55:57 2012 +0400 @@ -1,7 +1,7 @@ package jetbrains.buildServer.buildTriggers.vcs.mercurial; import com.intellij.openapi.diagnostic.Logger; -import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.Settings; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot; import jetbrains.buildServer.serverSide.impl.LogUtil; import jetbrains.buildServer.util.FileUtil; import jetbrains.buildServer.vcs.VcsManager; @@ -75,9 +75,9 @@ return result; } - private String urlOf(VcsRoot root) { - Settings s = new Settings(myHgPathProvider, root); - return s.getRepository(); + private String urlOf(@NotNull VcsRoot root) { + HgVcsRoot hgRoot = new HgVcsRoot(myHgPathProvider, root); + return hgRoot.getRepository(); } private Collection mercurialVcsRoots() { diff -r e33c3e4918f5 -r c91c4f1ebd53 mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ListFilesSupport.java --- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ListFilesSupport.java Fri May 11 15:21:35 2012 +0400 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ListFilesSupport.java Fri May 11 15:55:57 2012 +0400 @@ -1,6 +1,6 @@ package jetbrains.buildServer.buildTriggers.vcs.mercurial; -import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.Settings; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot; import jetbrains.buildServer.vcs.ListDirectChildrenPolicy; import jetbrains.buildServer.vcs.VcsException; import jetbrains.buildServer.vcs.VcsFileData; @@ -17,20 +17,20 @@ public class ListFilesSupport implements ListDirectChildrenPolicy { private final MercurialVcsSupport myVcs; - private final Settings mySettings; + private final HgVcsRoot myRoot; private final HgRepo myRepo; public ListFilesSupport(@NotNull MercurialVcsSupport vcs, - @NotNull Settings settings, + @NotNull HgVcsRoot root, @NotNull HgRepo repo) { myVcs = vcs; - mySettings = settings; + myRoot = root; myRepo = repo; } @NotNull public List listFiles(@NotNull String dir) throws VcsException { - myVcs.syncRepository(mySettings); + myVcs.syncRepository(myRoot); String dirPath = isEmpty(dir) || dir.endsWith("/") ? dir : dir + "/"; return listFilesIn(dirPath); } diff -r e33c3e4918f5 -r c91c4f1ebd53 mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java --- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java Fri May 11 15:21:35 2012 +0400 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java Fri May 11 15:55:57 2012 +0400 @@ -164,9 +164,9 @@ @NotNull public byte[] getContent(@NotNull final String filePath, @NotNull final VcsRoot vcsRoot, @NotNull final String version) throws VcsException { ChangeSet cset = new ChangeSet(version); - Settings settings = createSettings(vcsRoot); - syncRepository(settings, cset); - HgRepo repo = createRepo(settings); + HgVcsRoot root = createHgRoot(vcsRoot); + syncRepository(root, cset); + HgRepo repo = createRepo(root); File parentDir = repo.cat().files(filePath).atRevision(cset).call(); File file = new File(parentDir, filePath); try { @@ -212,14 +212,14 @@ @NotNull public String getCurrentVersion(@NotNull final VcsRoot root) throws VcsException { - Settings settings = createSettings(root); - syncRepository(settings); - HgRepo repo = createRepo(settings); + HgVcsRoot hgRoot = createHgRoot(root); + syncRepository(hgRoot); + HgRepo repo = createRepo(hgRoot); Map result = repo.branches().call(); - if (!result.containsKey(settings.getBranchName())) { - throw new VcsException("Unable to find current version for the branch: " + settings.getBranchName()); + if (!result.containsKey(hgRoot.getBranchName())) { + throw new VcsException("Unable to find current version for the branch: " + hgRoot.getBranchName()); } - return result.get(settings.getBranchName()).getFullVersion(); + return result.get(hgRoot.getBranchName()).getFullVersion(); } public boolean sourcesUpdatePossibleIfChangesNotFound(@NotNull final VcsRoot root) { @@ -235,15 +235,15 @@ public TestConnectionSupport getTestConnectionSupport() { return new TestConnectionSupport() { public String testConnection(@NotNull final VcsRoot vcsRoot) throws VcsException { - Settings settings = createSettings(vcsRoot); - String idResult = createRepo(settings).id() - .repository(settings.getRepository()) - .withAuthSettings(settings.getAuthSettings()) + HgVcsRoot root = createHgRoot(vcsRoot); + String idResult = createRepo(root).id() + .repository(root.getRepository()) + .withAuthSettings(root.getAuthSettings()) .call(); StringBuilder res = new StringBuilder(); - res.append(quoteIfNeeded(settings.getHgCommandPath())); + res.append(quoteIfNeeded(root.getHgCommandPath())); res.append(" identify "); - res.append(quoteIfNeeded(settings.getAuthSettings().getRepositoryUrlWithHiddenPassword(settings.getRepository()))); + res.append(quoteIfNeeded(root.getAuthSettings().getRepositoryUrlWithHiddenPassword(root.getRepository()))); res.append('\n').append(idResult); return res.toString(); } @@ -286,9 +286,13 @@ } // builds patch from version to version - private void buildIncrementalPatch(final Settings settings, @NotNull final ChangeSet fromVer, @NotNull final ChangeSet toVer, final PatchBuilder builder, final CheckoutRules checkoutRules) + private void buildIncrementalPatch(@NotNull final HgVcsRoot root, + @NotNull final ChangeSet fromVer, + @NotNull final ChangeSet toVer, + @NotNull final PatchBuilder builder, + @NotNull final CheckoutRules checkoutRules) throws VcsException, IOException { - HgRepo repo = createRepo(settings); + HgRepo repo = createRepo(root); List modifiedFiles = repo.status().fromRevision(fromVer).toRevision(toVer).call(); List notDeletedFiles = new ArrayList(); for (FileStatus f: modifiedFiles) { @@ -331,25 +335,27 @@ } // builds patch by exporting files using specified version - private void buildFullPatch(final Settings settings, @NotNull final ChangeSet toVer, final PatchBuilder builder, final CheckoutRules checkoutRules) - throws IOException, VcsException { + private void buildFullPatch(@NotNull final HgVcsRoot root, + @NotNull final ChangeSet toVer, + @NotNull final PatchBuilder builder, + @NotNull final CheckoutRules checkoutRules) throws IOException, VcsException { File tempDir = HgFileUtil.createTempDir(); try { - HgRepo repo = createRepo(settings); + HgRepo repo = createRepo(root); if (repo.hasSubreposAtRevision(toVer)) { - Loggers.VCS.debug("Repository '" + settings.getRepository() + "' has submodules at revision " + toVer.getId() + ", use 'hg clone' to build clean patch"); - File mirrorDir = getWorkingDir(settings); - HgRepo cloneOfTheMirror = createRepo(settings, tempDir); + Loggers.VCS.debug("Repository '" + root.getRepository() + "' has submodules at revision " + toVer.getId() + ", use 'hg clone' to build clean patch"); + File mirrorDir = getWorkingDir(root); + HgRepo cloneOfTheMirror = createRepo(root, tempDir); cloneOfTheMirror.doClone().fromRepository(mirrorDir) .setUpdateWorkingDir(false) .setUsePullProtocol(false) .useUncompressedTransfer(false) .call(); - cloneOfTheMirror.setDefaultPath(settings.getRepository()); + cloneOfTheMirror.setDefaultPath(root.getRepository()); cloneOfTheMirror.update().toRevision(toVer).call(); buildPatchFromDirectory(builder, tempDir, checkoutRules, myIgnoreDotHgFilter); } else { - Loggers.VCS.debug("Repository '" + settings.getRepository() + "' doesn't have submodules at revision " + toVer.getId() + ", use 'hg archive' to build clean patch"); + Loggers.VCS.debug("Repository '" + root.getRepository() + "' doesn't have submodules at revision " + toVer.getId() + ", use 'hg archive' to build clean patch"); repo.archive().revision(toVer).toDir(tempDir).call(); buildPatchFromDirectory(builder, tempDir, checkoutRules, myAcceptAllFilter); } @@ -391,56 +397,56 @@ } /* clone the repo if it doesn't exist, pull the repo if it doesn't contain specified changeSet */ - private void syncRepository(final Settings settings, final ChangeSet cset) throws VcsException { - File workingDir = getWorkingDir(settings); + private void syncRepository(@NotNull final HgVcsRoot root, @NotNull final ChangeSet cset) throws VcsException { + File workingDir = getWorkingDir(root); lockWorkDir(workingDir); - HgRepo repo = createRepo(settings); + HgRepo repo = createRepo(root); try { if (repo.isValidRepository()) { if (repo.containsRevision(cset)) return; try { - repo.pull().fromRepository(settings.getRepository()) + repo.pull().fromRepository(root.getRepository()) .withTimeout(myConfig.getPullTimeout()) .call(); } catch (UnrelatedRepositoryException e) { - Loggers.VCS.warn("Repository at " + settings.getRepository() + " is unrelated, clone it again"); + Loggers.VCS.warn("Repository at " + root.getRepository() + " is unrelated, clone it again"); myMirrorManager.forgetDir(workingDir); - syncRepository(settings, cset); + syncRepository(root, cset); } } else { - repo.doClone().fromRepository(settings.getRepository()) - .useUncompressedTransfer(settings.isUncompressedTransfer()) + repo.doClone().fromRepository(root.getRepository()) + .useUncompressedTransfer(root.isUncompressedTransfer()) .setUpdateWorkingDir(false) .call(); - repo.setDefaultPath(settings.getRepository()); + repo.setDefaultPath(root.getRepository()); } } finally { unlockWorkDir(workingDir); } } - public void syncRepository(final Settings settings) throws VcsException { - File workingDir = getWorkingDir(settings); + public void syncRepository(@NotNull final HgVcsRoot root) throws VcsException { + File workingDir = getWorkingDir(root); lockWorkDir(workingDir); - HgRepo repo = createRepo(settings); + HgRepo repo = createRepo(root); try { if (repo.isValidRepository()) { try { - repo.pull().fromRepository(settings.getRepository()) + repo.pull().fromRepository(root.getRepository()) .withTimeout(myConfig.getPullTimeout()) .call(); } catch (UnrelatedRepositoryException e) { - Loggers.VCS.warn("Repository at " + settings.getRepository() + " is unrelated, clone it again"); + Loggers.VCS.warn("Repository at " + root.getRepository() + " is unrelated, clone it again"); myMirrorManager.forgetDir(workingDir); - syncRepository(settings); + syncRepository(root); } } else { - repo.doClone().fromRepository(settings.getRepository()) + repo.doClone().fromRepository(root.getRepository()) .setUpdateWorkingDir(false) - .useUncompressedTransfer(settings.isUncompressedTransfer()) + .useUncompressedTransfer(root.isUncompressedTransfer()) .call(); - repo.setDefaultPath(settings.getRepository()); + repo.setDefaultPath(root.getRepository()); } } finally { unlockWorkDir(workingDir); @@ -469,9 +475,9 @@ @NotNull private Map getBranchesRevisions(@NotNull VcsRoot root) throws VcsException { - Settings settings = createSettings(root); - syncRepository(settings); - HgRepo repo = createRepo(settings); + HgVcsRoot hgRoot = createHgRoot(root); + syncRepository(hgRoot); + HgRepo repo = createRepo(hgRoot); Map result = new HashMap(); for (Map.Entry entry : repo.branches().call().entrySet()) { result.put(entry.getKey(), entry.getValue().getId()); @@ -489,16 +495,16 @@ @Nullable public PersonalBranchDescription getPersonalBranchDescription(@NotNull VcsRoot root, @NotNull String branchName) throws VcsException { - Settings settings = createSettings(root); + HgVcsRoot hgRoot = createHgRoot(root); VcsRoot branchRoot = createBranchRoot(root, branchName); String baseVersion = getCurrentVersion(root); String branchVersion = getCurrentVersion(branchRoot); - String mergeBase = getMergeBase(settings, baseVersion, branchVersion); + String mergeBase = getMergeBase(hgRoot, baseVersion, branchVersion); if (mergeBase == null) return null; - List changeSets = createRepo(settings).log() + List changeSets = createRepo(hgRoot).log() .fromRevision(mergeBase) .toRevision(branchVersion) .showCommitsFromAllBranches() @@ -523,10 +529,10 @@ public List collectChanges(@NotNull VcsRoot fromRoot, @NotNull String fromRootRevision, @NotNull VcsRoot toRoot, @Nullable String toRootRevision, @NotNull CheckoutRules checkoutRules) throws VcsException { - Settings settings = createSettings(toRoot); - syncRepository(settings); + HgVcsRoot hgRoot = createHgRoot(toRoot); + syncRepository(hgRoot); String toRevision = toRootRevision != null ? toRootRevision : getCurrentVersion(toRoot); - String mergeBase = getMergeBase(settings, fromRootRevision, toRevision); + String mergeBase = getMergeBase(hgRoot, fromRootRevision, toRevision); if (mergeBase == null) return Collections.emptyList(); return collectChanges(toRoot, mergeBase, toRootRevision, checkoutRules); @@ -534,22 +540,22 @@ @Nullable - private String getMergeBase(@NotNull Settings settings, @NotNull String revision1, @NotNull String revision2) throws VcsException { - String result = createRepo(settings).mergeBase() + private String getMergeBase(@NotNull HgVcsRoot root, @NotNull String revision1, @NotNull String revision2) throws VcsException { + String result = createRepo(root).mergeBase() .revision1(revision1) .revision2(revision2) .call(); if (result == null) - result = getMinusNthCommit(settings, 10); + result = getMinusNthCommit(root, 10); return result; } @Nullable - private String getMinusNthCommit(@NotNull Settings settings, int n) throws VcsException { - LogCommand log = createRepo(settings).log() - .inBranch(settings.getBranchName()) - .toNamedRevision(settings.getBranchName()); + private String getMinusNthCommit(@NotNull HgVcsRoot root, int n) throws VcsException { + LogCommand log = createRepo(root).log() + .inBranch(root.getBranchName()) + .toNamedRevision(root.getBranchName()); if (n > 0) log.setLimit(n); List changeSets = log.call(); @@ -565,10 +571,10 @@ } public List collectChanges(@NotNull VcsRoot root, @NotNull String fromVersion, @Nullable String currentVersion, @NotNull CheckoutRules checkoutRules) throws VcsException { - Settings settings = createSettings(root); - syncRepository(settings); + HgVcsRoot hgRoot = createHgRoot(root); + syncRepository(hgRoot); List result = new ArrayList(); - for (ChangeSet cset : getChangesets(settings, fromVersion, currentVersion)) { + for (ChangeSet cset : getChangesets(hgRoot, fromVersion, currentVersion)) { result.add(createModificationData(cset, root, checkoutRules)); } return result; @@ -591,13 +597,13 @@ @NotNull - private List getChangesets(@NotNull final Settings settings, @NotNull final String fromVersion, @Nullable final String toVersion) throws VcsException { + private List getChangesets(@NotNull final HgVcsRoot root, @NotNull final String fromVersion, @Nullable final String toVersion) throws VcsException { if (toVersion == null) return Collections.emptyList(); String fromCommit = new ChangeSetRevision(fromVersion).getId(); String toCommit = new ChangeSetRevision(toVersion).getId(); try { - List changesets = createRepo(settings).collectChanges() + List changesets = createRepo(root).collectChanges() .fromRevision(fromCommit) .toRevision(toCommit) .call(); @@ -621,20 +627,20 @@ } public void buildPatch(@NotNull VcsRoot root, @Nullable String fromVersion, @NotNull String toVersion, @NotNull PatchBuilder builder, @NotNull CheckoutRules checkoutRules) throws IOException, VcsException { - Settings settings = createSettings(root); - syncRepository(settings); + HgVcsRoot hgRoot = createHgRoot(root); + syncRepository(hgRoot); ChangeSet to = new ChangeSet(toVersion); if (fromVersion == null) { - buildFullPatch(settings, new ChangeSet(toVersion), builder, checkoutRules); + buildFullPatch(hgRoot, new ChangeSet(toVersion), builder, checkoutRules); } else { ChangeSet from = new ChangeSet(fromVersion); - HgRepo repo = createRepo(settings); + HgRepo repo = createRepo(hgRoot); if (!repo.containsRevision(from)) { - Loggers.VCS.info("Cannot find revision " + fromVersion + " in repository " + settings.getRepository() + ", will build a full patch"); + Loggers.VCS.info("Cannot find revision " + fromVersion + " in repository " + hgRoot.getRepository() + ", will build a full patch"); cleanCheckoutDir(builder, checkoutRules); - buildFullPatch(settings, to, builder, checkoutRules); + buildFullPatch(hgRoot, to, builder, checkoutRules); } else { - buildIncrementalPatch(settings, new ChangeSet(fromVersion), new ChangeSet(toVersion), builder, checkoutRules); + buildIncrementalPatch(hgRoot, new ChangeSet(fromVersion), new ChangeSet(toVersion), builder, checkoutRules); } } } @@ -662,19 +668,19 @@ File tmpDir = null; try { tmpDir = createLabelingTmpDir(); - Settings settings = createSettings(root); - settings.setCustomWorkingDir(tmpDir); - syncRepository(settings); - HgRepo repo = createRepo(settings); - repo.update().branch(settings.getBranchName()).call(); + HgVcsRoot hgRoot = createHgRoot(root); + hgRoot.setCustomWorkingDir(tmpDir); + syncRepository(hgRoot); + HgRepo repo = createRepo(hgRoot); + repo.update().branch(hgRoot.getBranchName()).call(); String fixedTagname = fixTagName(label); repo.tag().revision(version) .tagName(fixedTagname) - .byUser(settings.getUserForTag()) + .byUser(hgRoot.getUserForTag()) .call(); - repo.push().toRepository(settings.getRepository()).call(); + repo.push().toRepository(hgRoot.getRepository()).call(); return fixedTagname; } finally { if (tmpDir != null) @@ -692,29 +698,29 @@ return label.replace(':', '_').replace('\r', '_').replace('\n', '_'); } - private File getWorkingDir(Settings s) { - File customDir = s.getCustomWorkingDir(); - return customDir != null ? customDir : myMirrorManager.getMirrorDir(s.getRepository()); + private File getWorkingDir(HgVcsRoot root) { + File customDir = root.getCustomWorkingDir(); + return customDir != null ? customDir : myMirrorManager.getMirrorDir(root.getRepository()); } - private Settings createSettings(final VcsRoot root) throws VcsException { - Settings settings = new Settings(myHgPathProvider, root); - String customClonePath = settings.getCustomClonePath(); + private HgVcsRoot createHgRoot(@NotNull VcsRoot root) throws VcsException { + HgVcsRoot hgRoot = new HgVcsRoot(myHgPathProvider, root); + String customClonePath = hgRoot.getCustomClonePath(); if (!StringUtil.isEmptyOrSpaces(customClonePath) && !myDefaultWorkFolderParent.equals(new File(customClonePath).getAbsoluteFile())) { File parentDir = new File(customClonePath); createClonedRepositoryParentDir(parentDir); // take last part of repository path - String repPath = settings.getRepositoryUrlWithCredentials(); + String repPath = hgRoot.getRepositoryUrlWithCredentials(); String[] splitted = repPath.split("[/\\\\]"); if (splitted.length > 0) { repPath = splitted[splitted.length-1]; } File customWorkingDir = new File(parentDir, repPath); - settings.setCustomWorkingDir(customWorkingDir); + hgRoot.setCustomWorkingDir(customWorkingDir); } - return settings; + return hgRoot; } private void createClonedRepositoryParentDir(final File parentDir) throws VcsException { @@ -760,19 +766,19 @@ } } - private ServerHgRepo createRepo(@NotNull Settings s) throws VcsException { - return myRepoFactory.create(getWorkingDir(s), s.getHgCommandPath(), s.getAuthSettings()); + private ServerHgRepo createRepo(@NotNull HgVcsRoot root) throws VcsException { + return myRepoFactory.create(getWorkingDir(root), root.getHgCommandPath(), root.getAuthSettings()); } - private HgRepo createRepo(@NotNull Settings s, @NotNull File customDir) throws VcsException { - return myRepoFactory.create(customDir, s.getHgCommandPath(), s.getAuthSettings()); + private HgRepo createRepo(@NotNull HgVcsRoot root, @NotNull File customDir) throws VcsException { + return myRepoFactory.create(customDir, root.getHgCommandPath(), root.getAuthSettings()); } @NotNull public String getBranchName(@NotNull final VcsRoot root) { try { - Settings s = createSettings(root); - return s.getBranchName(); + HgVcsRoot hgRoot = createHgRoot(root); + return hgRoot.getBranchName(); } catch (VcsException e) { return "default"; } @@ -791,9 +797,9 @@ @Override public ListFilesPolicy getListFilesPolicy(@NotNull VcsRoot root) { try { - Settings settings = createSettings(root); - HgRepo repo = createRepo(settings); - return new ListFilesSupport(this, settings, repo); + HgVcsRoot hgRoot = createHgRoot(root); + HgRepo repo = createRepo(hgRoot); + return new ListFilesSupport(this, hgRoot, repo); } catch (VcsException e) { return null; } diff -r e33c3e4918f5 -r c91c4f1ebd53 mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerHgPathProvider.java --- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerHgPathProvider.java Fri May 11 15:21:35 2012 +0400 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerHgPathProvider.java Fri May 11 15:55:57 2012 +0400 @@ -1,6 +1,6 @@ package jetbrains.buildServer.buildTriggers.vcs.mercurial; -import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.Settings; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot; import org.jetbrains.annotations.NotNull; /** @@ -16,12 +16,12 @@ } - public String getHgPath(@NotNull final Settings settings) { + public String getHgPath(@NotNull final HgVcsRoot root) { String serverWideHgPath = myConfig.getHgPath(); if (serverWideHgPath != null) { return serverWideHgPath; } else { - String pathFromRoot = settings.getHgPath(); + String pathFromRoot = root.getHgPath(); if (pathFromRoot.equals(unresolvedAgentHgPath())) { //try to use hg from the PATH: return "hg"; diff -r e33c3e4918f5 -r c91c4f1ebd53 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java --- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java Fri May 11 15:21:35 2012 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java Fri May 11 15:55:57 2012 +0400 @@ -18,7 +18,7 @@ import com.intellij.execution.configurations.GeneralCommandLine; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandResult; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandUtil; -import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.Settings; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot; import jetbrains.buildServer.vcs.*; import jetbrains.buildServer.vcs.impl.VcsRootImpl; import jetbrains.buildServer.vcs.patches.PatchBuilderImpl; @@ -365,16 +365,16 @@ VcsRootImpl vcsRoot = createVcsRoot(simpleRepo()); String repPath = vcsRoot.getProperty(Constants.REPOSITORY_PROP); vcsRoot.addProperty(Constants.REPOSITORY_PROP, repPath + "#test_branch"); - Settings settings = new Settings(new ServerHgPathProvider(myPluginConfig), vcsRoot); - assertEquals("test_branch", settings.getBranchName()); + HgVcsRoot hgRoot = new HgVcsRoot(new ServerHgPathProvider(myPluginConfig), vcsRoot); + assertEquals("test_branch", hgRoot.getBranchName()); vcsRoot.addProperty(Constants.REPOSITORY_PROP, repPath + "#"); - settings = new Settings(new ServerHgPathProvider(myPluginConfig), vcsRoot); - assertEquals("default", settings.getBranchName()); + hgRoot = new HgVcsRoot(new ServerHgPathProvider(myPluginConfig), vcsRoot); + assertEquals("default", hgRoot.getBranchName()); vcsRoot.addProperty(Constants.REPOSITORY_PROP, repPath); - settings = new Settings(new ServerHgPathProvider(myPluginConfig), vcsRoot); - assertEquals("default", settings.getBranchName()); + hgRoot = new HgVcsRoot(new ServerHgPathProvider(myPluginConfig), vcsRoot); + assertEquals("default", hgRoot.getBranchName()); } public void build_patch_using_custom_clone_path() throws IOException, VcsException { @@ -485,8 +485,8 @@ VcsRootImpl root = new VcsRootImpl(1, Constants.VCS_NAME); root.addAllProperties(myVcs.getDefaultVcsProperties()); root.addProperty(Constants.REPOSITORY_PROP, "http://host.com/path"); - Settings settings = new Settings(new ServerHgPathProvider(myPluginConfig), root); - assertFalse(settings.isUncompressedTransfer()); + HgVcsRoot hgRoot = new HgVcsRoot(new ServerHgPathProvider(myPluginConfig), root); + assertFalse(hgRoot.isUncompressedTransfer()); } diff -r e33c3e4918f5 -r c91c4f1ebd53 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerHgPathProviderTest.java --- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerHgPathProviderTest.java Fri May 11 15:21:35 2012 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerHgPathProviderTest.java Fri May 11 15:55:57 2012 +0400 @@ -1,6 +1,6 @@ package jetbrains.buildServer.buildTriggers.vcs.mercurial; -import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.Settings; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot; import jetbrains.buildServer.vcs.impl.VcsRootImpl; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -27,16 +27,16 @@ public void server_should_use_settings_from_vcs_root_if_server_wide_path_is_not_set() throws Exception { myServerWideHgPath = null; HgPathProvider provider = createHgPathProvider(); - Settings settings = createSettings(provider); - assertEquals(myVcsRootHgPath, provider.getHgPath(settings)); + HgVcsRoot hgRoot = createSettings(provider); + assertEquals(myVcsRootHgPath, provider.getHgPath(hgRoot)); } public void server_should_use_server_wide_path_if_it_is_set() throws Exception { myServerWideHgPath = "/server-wide/hg/path"; HgPathProvider provider = createHgPathProvider(); - Settings settings = createSettings(provider); - assertEquals(myServerWideHgPath, provider.getHgPath(settings)); + HgVcsRoot hgRoot = createSettings(provider); + assertEquals(myServerWideHgPath, provider.getHgPath(hgRoot)); } @@ -46,9 +46,9 @@ } - private Settings createSettings(HgPathProvider hgPathProvider) throws Exception { + private HgVcsRoot createSettings(HgPathProvider hgPathProvider) throws Exception { VcsRootImpl root = new VcsRootBuilder().withHgPath(myVcsRootHgPath).build(); - return new Settings(hgPathProvider, root); + return new HgVcsRoot(hgPathProvider, root); } } diff -r e33c3e4918f5 -r c91c4f1ebd53 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SettingsTest.java --- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SettingsTest.java Fri May 11 15:21:35 2012 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SettingsTest.java Fri May 11 15:55:57 2012 +0400 @@ -15,7 +15,7 @@ */ package jetbrains.buildServer.buildTriggers.vcs.mercurial; -import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.Settings; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot; import jetbrains.buildServer.vcs.VcsRoot; import jetbrains.buildServer.vcs.impl.VcsRootImpl; import junit.framework.TestCase; @@ -30,79 +30,79 @@ public void test_url_without_credentials() { VcsRootImpl vcsRoot = createVcsRoot("http://host.com/path"); - Settings settings = createSettings(vcsRoot); - assertEquals("http://user:pwd@host.com/path", settings.getRepositoryUrlWithCredentials()); + HgVcsRoot root = createHgRoot(vcsRoot); + assertEquals("http://user:pwd@host.com/path", root.getRepositoryUrlWithCredentials()); } public void test_url_with_credentials() { VcsRootImpl vcsRoot = createVcsRoot("http://user:pwd@host.com/path"); - Settings settings = createSettings(vcsRoot); - assertEquals("http://user:pwd@host.com/path", settings.getRepositoryUrlWithCredentials()); + HgVcsRoot root = createHgRoot(vcsRoot); + assertEquals("http://user:pwd@host.com/path", root.getRepositoryUrlWithCredentials()); } public void test_url_with_username() { VcsRootImpl vcsRoot = createVcsRoot("http://user@host.com/path"); - Settings settings = createSettings(vcsRoot); - assertEquals("http://user:pwd@host.com/path", settings.getRepositoryUrlWithCredentials()); + HgVcsRoot root = createHgRoot(vcsRoot); + assertEquals("http://user:pwd@host.com/path", root.getRepositoryUrlWithCredentials()); } public void test_url_with_at_after_slash() { VcsRootImpl vcsRoot = createVcsRoot("http://host.com/path@"); - Settings settings = createSettings(vcsRoot); - assertEquals("http://user:pwd@host.com/path@", settings.getRepositoryUrlWithCredentials()); + HgVcsRoot root = createHgRoot(vcsRoot); + assertEquals("http://user:pwd@host.com/path@", root.getRepositoryUrlWithCredentials()); } public void test_url_with_at_in_username() { VcsRootImpl vcsRoot = createVcsRoot("http://host.com/path", "my.name@gmail.com", "1234"); - Settings settings = createSettings(vcsRoot); - assertEquals("http://my.name%40gmail.com:1234@host.com/path", settings.getRepositoryUrlWithCredentials()); + HgVcsRoot root = createHgRoot(vcsRoot); + assertEquals("http://my.name%40gmail.com:1234@host.com/path", root.getRepositoryUrlWithCredentials()); } /** TW-13768 */ public void test_underscore_in_host() { VcsRootImpl vcsRoot = createVcsRoot("http://Klekovkin.SDK_GARANT:8000/", "my.name@gmail.com", "1234"); - Settings settings = createSettings(vcsRoot); - assertEquals("http://my.name%40gmail.com:1234@Klekovkin.SDK_GARANT:8000/", settings.getRepositoryUrlWithCredentials()); + HgVcsRoot root = createHgRoot(vcsRoot); + assertEquals("http://my.name%40gmail.com:1234@Klekovkin.SDK_GARANT:8000/", root.getRepositoryUrlWithCredentials()); } /** TW-13768 */ public void test_underscore_in_host_with_credentials_in_url() { VcsRootImpl vcsRoot = createVcsRoot("http://me:mypass@Klekovkin.SDK_GARANT:8000/"); - Settings settings = createSettings(vcsRoot); - assertEquals("http://me:mypass@Klekovkin.SDK_GARANT:8000/", settings.getRepositoryUrlWithCredentials()); + HgVcsRoot root = createHgRoot(vcsRoot); + assertEquals("http://me:mypass@Klekovkin.SDK_GARANT:8000/", root.getRepositoryUrlWithCredentials()); } public void test_windows_path() throws Exception { VcsRootImpl vcsRoot = createVcsRoot("c:\\windows\\path"); - Settings settings = createSettings(vcsRoot); - assertEquals("c:\\windows\\path", settings.getRepositoryUrlWithCredentials()); + HgVcsRoot root = createHgRoot(vcsRoot); + assertEquals("c:\\windows\\path", root.getRepositoryUrlWithCredentials()); } public void test_file_scheme_has_no_credentials() { VcsRootImpl vcsRoot = createVcsRoot("file:///path/to/repo", "my.name@gmail.com", "1234"); - Settings settings = createSettings(vcsRoot); - assertEquals("file:///path/to/repo", settings.getRepositoryUrlWithCredentials()); + HgVcsRoot root = createHgRoot(vcsRoot); + assertEquals("file:///path/to/repo", root.getRepositoryUrlWithCredentials()); } public void uncompressed_transfer() { - VcsRootImpl root = createVcsRoot("http://host.com/path"); - root.addProperty(Constants.UNCOMPRESSED_TRANSFER, "true"); - Settings settings = createSettings(root); - assertTrue(settings.isUncompressedTransfer()); + VcsRootImpl vcsRoot = createVcsRoot("http://host.com/path"); + vcsRoot.addProperty(Constants.UNCOMPRESSED_TRANSFER, "true"); + HgVcsRoot root = createHgRoot(vcsRoot); + assertTrue(root.isUncompressedTransfer()); } //TW-18262 public void ampersand_in_password() { VcsRootImpl vcsRoot = createVcsRoot("http://some.org/path", "user", "m&n"); - Settings settings = createSettings(vcsRoot); - assertEquals("http://user:m%26n@some.org/path", settings.getRepositoryUrlWithCredentials()); + HgVcsRoot root = createHgRoot(vcsRoot); + assertEquals("http://user:m%26n@some.org/path", root.getRepositoryUrlWithCredentials()); } //TW-18835 public void test_ssh() { VcsRootImpl vcsRoot = createVcsRoot("ssh://ourserver.com/mercurialrepo/", "user", "pwd"); - Settings settings = createSettings(vcsRoot); - assertEquals("ssh://user:pwd@ourserver.com/mercurialrepo/", settings.getRepositoryUrlWithCredentials()); + HgVcsRoot root = createHgRoot(vcsRoot); + assertEquals("ssh://user:pwd@ourserver.com/mercurialrepo/", root.getRepositoryUrlWithCredentials()); } private VcsRootImpl createVcsRoot(String url) { @@ -118,8 +118,8 @@ return vcsRoot; } - private Settings createSettings(@NotNull final VcsRoot root) { + private HgVcsRoot createHgRoot(@NotNull final VcsRoot root) { ServerPluginConfig config = new ServerPluginConfigBuilder().build(); - return new Settings(new ServerHgPathProvider(config), root); + return new HgVcsRoot(new ServerHgPathProvider(config), root); } } diff -r e33c3e4918f5 -r c91c4f1ebd53 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommandTestCase.java --- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommandTestCase.java Fri May 11 15:21:35 2012 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommandTestCase.java Fri May 11 15:55:57 2012 +0400 @@ -72,21 +72,21 @@ VcsRoot vcsRoot = new VcsRootImpl(1, vcsRootProps); ServerPluginConfig config = new ServerPluginConfigBuilder().cachesDir(tf.createTempDir()).build(); MirrorManager mirrorManager = new MirrorManagerImpl(config); - Settings settings = new Settings(new ServerHgPathProvider(config), vcsRoot); - final File workingDir = mirrorManager.getMirrorDir(settings.getRepository()); - settings.setCustomWorkingDir(workingDir); + HgVcsRoot root = new HgVcsRoot(new ServerHgPathProvider(config), vcsRoot); + final File workingDir = mirrorManager.getMirrorDir(root.getRepository()); + root.setCustomWorkingDir(workingDir); try { if (myCloneRequired) { - new HgRepo(workingDir, settings.getHgCommandPath(), settings.getAuthSettings()).doClone().fromRepository(settings.getRepository()).call(); + new HgRepo(workingDir, root.getHgCommandPath(), root.getAuthSettings()).doClone().fromRepository(root.getRepository()).call(); } - return executor.execute(settings, workingDir); + return executor.execute(root, workingDir); } finally { tf.cleanup(); } } public interface CommandExecutor { - T execute(@NotNull Settings settings, File workingDir) throws VcsException; + T execute(@NotNull HgVcsRoot root, File workingDir) throws VcsException; } } diff -r e33c3e4918f5 -r c91c4f1ebd53 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CatCommandTest.java --- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CatCommandTest.java Fri May 11 15:21:35 2012 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CatCommandTest.java Fri May 11 15:55:57 2012 +0400 @@ -38,8 +38,8 @@ cleanCatResultDirs(); setRepository("mercurial-tests/testData/rep1", true); runCommand(new CommandExecutor() { - public File execute(@NotNull final Settings settings, @NotNull final File workingDir) throws VcsException { - return new CatCommand(settings.getHgCommandPath(), workingDir, settings.getAuthSettings()).files("/non/existing/path").checkForFailure(false).call(); + public File execute(@NotNull final HgVcsRoot root, @NotNull final File workingDir) throws VcsException { + return new CatCommand(root.getHgCommandPath(), workingDir, root.getAuthSettings()).files("/non/existing/path").checkForFailure(false).call(); } }); } @@ -65,8 +65,8 @@ private File runCat(@NotNull final List paths) throws IOException, VcsException { return runCommand(new CommandExecutor() { - public File execute(@NotNull final Settings settings, @NotNull final File workingDir) throws VcsException { - CatCommand cat = new CatCommand(settings.getHgCommandPath(), workingDir, settings.getAuthSettings()); + public File execute(@NotNull final HgVcsRoot root, @NotNull final File workingDir) throws VcsException { + CatCommand cat = new CatCommand(root.getHgCommandPath(), workingDir, root.getAuthSettings()); return cat.execute(paths); } }); diff -r e33c3e4918f5 -r c91c4f1ebd53 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommandTest.java --- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommandTest.java Fri May 11 15:21:35 2012 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommandTest.java Fri May 11 15:55:57 2012 +0400 @@ -43,10 +43,10 @@ File workingDir = myTempFiles.createTempDir(); ServerPluginConfig config = new ServerPluginConfigBuilder().cachesDir(myTempFiles.createTempDir()).build(); - Settings settings = new Settings(new ServerHgPathProvider(config), root); - settings.setCustomWorkingDir(workingDir); + HgVcsRoot hgRoot = new HgVcsRoot(new ServerHgPathProvider(config), root); + hgRoot.setCustomWorkingDir(workingDir); - new CloneCommand(settings.getHgCommandPath(), workingDir, settings.getAuthSettings()).fromRepository(settings.getRepository()).call(); + new CloneCommand(hgRoot.getHgCommandPath(), workingDir, hgRoot.getAuthSettings()).fromRepository(hgRoot.getRepository()).call(); String[] files = new String[] {".hg", "dir1", "dir with space", "file.txt"}; for (String f : files) { diff -r e33c3e4918f5 -r c91c4f1ebd53 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/IdentifyCommandTest.java --- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/IdentifyCommandTest.java Fri May 11 15:21:35 2012 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/IdentifyCommandTest.java Fri May 11 15:55:57 2012 +0400 @@ -36,8 +36,8 @@ private Void runIdentify(final ChangeSet cset) throws IOException, VcsException { return runCommand(new CommandExecutor() { - public Void execute(@NotNull final Settings settings, File workingDir) throws VcsException { - new IdentifyCommand(settings.getHgCommandPath(), workingDir, settings.getAuthSettings()) + public Void execute(@NotNull final HgVcsRoot root, File workingDir) throws VcsException { + new IdentifyCommand(root.getHgCommandPath(), workingDir, root.getAuthSettings()) .revision(cset) .inLocalRepository() .call(); diff -r e33c3e4918f5 -r c91c4f1ebd53 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommandTest.java --- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommandTest.java Fri May 11 15:21:35 2012 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommandTest.java Fri May 11 15:55:57 2012 +0400 @@ -173,9 +173,9 @@ private List runLog(final String fromId, final String toId) throws IOException, VcsException { return runCommand(new CommandExecutor>() { - public List execute(@NotNull final Settings settings, @NotNull File workingDir) throws VcsException { - return new LogCommand(settings.getHgCommandPath(), workingDir, settings.getAuthSettings()) - .inBranch(settings.getBranchName()) + public List execute(@NotNull final HgVcsRoot root, @NotNull File workingDir) throws VcsException { + return new LogCommand(root.getHgCommandPath(), workingDir, root.getAuthSettings()) + .inBranch(root.getBranchName()) .withTemplate(myTemplateFile) .fromRevision(fromId) .toRevision(toId) diff -r e33c3e4918f5 -r c91c4f1ebd53 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PushCommandTest.java --- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PushCommandTest.java Fri May 11 15:21:35 2012 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PushCommandTest.java Fri May 11 15:55:57 2012 +0400 @@ -35,8 +35,8 @@ try { runCommand(new CommandExecutor() { - public Boolean execute(@NotNull final Settings settings, @NotNull File workingDir) throws VcsException { - new PushCommand(settings.getHgCommandPath(), workingDir, settings.getAuthSettings()).toRepository(settings.getRepository()).call(); + public Boolean execute(@NotNull final HgVcsRoot root, @NotNull File workingDir) throws VcsException { + new PushCommand(root.getHgCommandPath(), workingDir, root.getAuthSettings()).toRepository(root.getRepository()).call(); return null; } }); diff -r e33c3e4918f5 -r c91c4f1ebd53 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/StatusCommandTest.java --- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/StatusCommandTest.java Fri May 11 15:21:35 2012 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/StatusCommandTest.java Fri May 11 15:55:57 2012 +0400 @@ -54,8 +54,8 @@ private List runStatus(final String fromId, final String toId) throws IOException, VcsException { return runCommand(new CommandExecutor>() { - public List execute(@NotNull final Settings settings, @NotNull final File workingDir) throws VcsException { - return new StatusCommand(settings.getHgCommandPath(), workingDir, settings.getAuthSettings()) + public List execute(@NotNull final HgVcsRoot root, @NotNull final File workingDir) throws VcsException { + return new StatusCommand(root.getHgCommandPath(), workingDir, root.getAuthSettings()) .fromRevision(fromId) .toRevision(toId) .call(); diff -r e33c3e4918f5 -r c91c4f1ebd53 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VersionCommandTest.java --- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VersionCommandTest.java Fri May 11 15:21:35 2012 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VersionCommandTest.java Fri May 11 15:55:57 2012 +0400 @@ -16,8 +16,8 @@ public void test() throws Exception { VcsRootImpl root = new VcsRootBuilder().withUrl("some/repository").build(); ServerPluginConfig config = new ServerPluginConfigBuilder().build(); - Settings settings = new Settings(new ServerHgPathProvider(config), root); - VersionCommand versionCommand = new VersionCommand(settings, new File("..")); + HgVcsRoot hgRoot = new HgVcsRoot(new ServerHgPathProvider(config), root); + VersionCommand versionCommand = new VersionCommand(hgRoot, new File("..")); HgVersion version = versionCommand.call(); assertNotNull(version); }