Mercurial > hg > mercurial
changeset 641:da9ab34663d8
Do not implement VcsRoot
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Fri, 23 Aug 2013 12:27:35 +0400 |
parents | 22bf770c2c85 |
children | 4d76b4b8b814 |
files | mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/HgVcsRoot.java mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgVcsRootFactory.java mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialCollectChangesPolicy.java mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/OperationContext.java |
diffstat | 5 files changed, 30 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/HgVcsRoot.java Thu Aug 22 17:04:04 2013 +0200 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/HgVcsRoot.java Fri Aug 23 12:27:35 2013 +0400 @@ -23,16 +23,17 @@ import org.jetbrains.annotations.Nullable; import java.io.File; +import java.util.HashMap; import java.util.Map; /** * Represents mercurial VCS root */ -public class HgVcsRoot implements VcsRoot { +public class HgVcsRoot { private static final String DEFAULT_BRANCH_NAME = "default"; - private final VcsRoot myRoot; + private final Map<String, String> myVcsRootProperties; private final String myRepository; private final String myHgCommandPath; private final String myBranchName; @@ -44,12 +45,12 @@ private final boolean myDetectSubrepoChanges; public HgVcsRoot(@NotNull final VcsRoot vcsRoot) { - this(vcsRoot, vcsRoot.getProperty(Constants.REPOSITORY_PROP)); + this(vcsRoot.getProperties()); } - public HgVcsRoot(@NotNull VcsRoot vcsRoot, @NotNull String repository) { - myRoot = vcsRoot; - myRepository = repository; + public HgVcsRoot(@NotNull Map<String, String> vcsRootProperties) { + myVcsRootProperties = vcsRootProperties; + 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); @@ -59,6 +60,12 @@ myDetectSubrepoChanges = Boolean.parseBoolean(getProperty(Constants.DETECT_SUBREPO_CHANGES)); } + public HgVcsRoot withUrl(@NotNull String repositoryUrl) { + Map<String, String> customUrlProperties = new HashMap<String, String>(getProperties()); + customUrlProperties.put(Constants.REPOSITORY_PROP, repositoryUrl); + return new HgVcsRoot(customUrlProperties); + } + public String getCustomClonePath() { return myCustomClonePath; } @@ -67,10 +74,6 @@ return myRepository; } - public HgVcsRoot withUrl(@NotNull String repositoryUrl) { - return new HgVcsRoot(this, repositoryUrl); - } - /** * Returns name of the branch to use (returns 'default' if no branch specified) * @return see above @@ -145,37 +148,12 @@ return mySubrepoPath + subrepoPath; } - @NotNull - public String getVcsName() { - return myRoot.getVcsName(); - } - public String getProperty(@NotNull String propertyName) { - if (Constants.REPOSITORY_PROP.equals(propertyName) && myRepository != null) - return myRepository; - return myRoot.getProperty(propertyName); - } - - public String getProperty(@NotNull String propertyName, String defaultValue) { - return myRoot.getProperty(propertyName, defaultValue); + return myVcsRootProperties.get(propertyName); } @NotNull public Map<String, String> getProperties() { - return myRoot.getProperties(); - } - - @NotNull - public String getName() { - return myRoot.getName(); - } - - public long getId() { - return myRoot.getId(); - } - - @NotNull - public String describe(final boolean verbose) { - return myRoot.describe(verbose); + return myVcsRootProperties; } }
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgVcsRootFactory.java Thu Aug 22 17:04:04 2013 +0200 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgVcsRootFactory.java Fri Aug 23 12:27:35 2013 +0400 @@ -21,6 +21,7 @@ } + @NotNull public HgVcsRoot createHgRoot(@NotNull VcsRoot root) throws VcsException { HgVcsRoot hgRoot = new HgVcsRoot(root); String customClonePath = hgRoot.getCustomClonePath();
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialCollectChangesPolicy.java Thu Aug 22 17:04:04 2013 +0200 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialCollectChangesPolicy.java Fri Aug 23 12:27:35 2013 +0400 @@ -392,7 +392,7 @@ ServerHgRepo repo = myVcs.createRepo(ctx, root); SubrepoRevisionAttributesBuilder attrBuilder = new SubrepoRevisionAttributesBuilder(); for (SubRepo s : repo.getSubrepositories(m).values()) { - attrBuilder.addSubrepo(new SubrepoConfig(root) + attrBuilder.addSubrepo(new SubrepoConfig(mainRoot) .setSubrepoPath(ctx.getStringFromPool(root.expandSubrepoPath(s.path()))) .setSubrepoRootParamDiff(Constants.REPOSITORY_PROP, ctx.getStringFromPool(s.resolveUrl(root.getRepository()))) .setSubrepoRootParamDiff("teamcity.internal.subrepo", "true")
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java Thu Aug 22 17:04:04 2013 +0200 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java Fri Aug 23 12:27:35 2013 +0400 @@ -502,6 +502,14 @@ public void buildPatch(@NotNull VcsRoot root, @Nullable String fromVersion, @NotNull String toVersion, @NotNull PatchBuilder builder, @NotNull CheckoutRules checkoutRules) throws IOException, VcsException { HgVcsRoot hgRoot = myHgVcsRootFactory.createHgRoot(root); + buildPatch(hgRoot, fromVersion, toVersion, builder, checkoutRules); + } + + public void buildPatch(@NotNull HgVcsRoot hgRoot, + @Nullable String fromVersion, + @NotNull String toVersion, + @NotNull PatchBuilder builder, + @NotNull CheckoutRules checkoutRules) throws IOException, VcsException { syncRepository(hgRoot); ChangeSet to = new ChangeSet(toVersion); if (fromVersion == null) { @@ -627,7 +635,7 @@ } - private HgRepo createRepo(@NotNull HgVcsRoot root, @NotNull File customDir) throws VcsException { + public HgRepo createRepo(@NotNull HgVcsRoot root, @NotNull File customDir) throws VcsException { return myRepoFactory.create(customDir, myHgPathProvider.getHgPath(root), root.getAuthSettings()); }
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/OperationContext.java Thu Aug 22 17:04:04 2013 +0200 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/OperationContext.java Fri Aug 23 12:27:35 2013 +0400 @@ -224,6 +224,10 @@ super(repositoryUrl, subrepoPath); } + private static VcsRootKey create(@NotNull HgVcsRoot root) { + return new VcsRootKey(root.getProperty(Constants.REPOSITORY_PROP), root.getProperty("teamcity.internal.subrepo.path")); + } + private static VcsRootKey create(@NotNull VcsRoot root) { return new VcsRootKey(root.getProperty(Constants.REPOSITORY_PROP), root.getProperty("teamcity.internal.subrepo.path")); }