Mercurial > hg > mercurial
changeset 730:ae1358e79ee1
Merge
author | eugene.petrenko@jetbrains.com |
---|---|
date | Tue, 14 Jan 2014 11:36:24 +0100 |
parents | 785ab04c78da (current diff) d1469a7cc038 (diff) |
children | 5becb1dfecbd |
files | mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgRepo.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubRepo.java |
diffstat | 9 files changed, 70 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialIncludeRuleUpdater.java Mon Jan 13 20:29:59 2014 +0100 +++ b/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialIncludeRuleUpdater.java Tue Jan 14 11:36:24 2014 +0100 @@ -6,6 +6,7 @@ import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.AuthSettings; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception.UnrelatedRepositoryException; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception.WrongSubrepoUrlException; import jetbrains.buildServer.vcs.IncludeRule; import jetbrains.buildServer.vcs.VcsException; import jetbrains.buildServer.vcs.VcsRoot; @@ -13,7 +14,6 @@ import java.io.File; import java.io.IOException; -import java.net.URISyntaxException; import java.util.Map; import static com.intellij.openapi.util.io.FileUtil.delete; @@ -161,7 +161,7 @@ subrepoUrl = subrepoConfig.resolveUrl(parentRepositoryUrl); if (myUseLocalMirrors && subrepoConfig.vcsType() == SubRepo.VcsType.hg && !isRelativeUrl(subrepoUrl)) syncSubrepo(subrepository, subrepoUrl, subrepoConfig.revision()); - } catch (URISyntaxException e) { + } catch (WrongSubrepoUrlException e) { myLogger.warning("Failed to resolve subrepo url '" + subrepoConfig.url() + "': " + e.getMessage()); subrepoUrl = subrepoConfig.url(); }
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgRepo.java Mon Jan 13 20:29:59 2014 +0100 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgRepo.java Tue Jan 14 11:36:24 2014 +0100 @@ -237,11 +237,12 @@ for (String parentRevision : parentRevisions) { prevSubrepos.add(getSubrepositories(parentRevision)); } - return getSubrepoConfigChanges(prevSubrepos, curSubrepos); + return getSubrepoConfigChanges(revision, prevSubrepos, curSubrepos); } - private List<HgSubrepoConfigChange> getSubrepoConfigChanges(@NotNull List<Map<String, SubRepo>> prevSubrepos, + private List<HgSubrepoConfigChange> getSubrepoConfigChanges(@NotNull String mainRepoRevision, + @NotNull List<Map<String, SubRepo>> prevSubrepos, @NotNull Map<String, SubRepo> curSubrepos) { List<HgSubrepoConfigChange> configChanges = new ArrayList<HgSubrepoConfigChange>(); for (Map.Entry<String, SubRepo> e : curSubrepos.entrySet()) { @@ -256,11 +257,11 @@ continue; prevs.add(prevSubrepo); } - configChanges.add(new HgSubrepoConfigChange(e.getKey(), prevs, curSubrepo)); + configChanges.add(new HgSubrepoConfigChange(mainRepoRevision, e.getKey(), prevs, curSubrepo)); } for (Map<String, SubRepo> prev : prevSubrepos) { for (Map.Entry<String, SubRepo> e : prev.entrySet()) { - configChanges.add(new HgSubrepoConfigChange(e.getKey(), e.getValue(), null)); + configChanges.add(new HgSubrepoConfigChange(mainRepoRevision, e.getKey(), e.getValue(), null)); } } return configChanges;
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgSubrepoConfigChange.java Mon Jan 13 20:29:59 2014 +0100 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgSubrepoConfigChange.java Tue Jan 14 11:36:24 2014 +0100 @@ -13,25 +13,34 @@ */ public class HgSubrepoConfigChange { + private final String myMainRepoRevision; private final String myPath; private final SubRepo myCurrent; private final List<SubRepo> myPrevious; - public HgSubrepoConfigChange(@NotNull String path, + public HgSubrepoConfigChange(@NotNull String mainRepoRevision, + @NotNull String path, @Nullable SubRepo previous, @Nullable SubRepo current) { - this(path, previous != null ? asList(previous) : new ArrayList<SubRepo>(), current); + this(mainRepoRevision, path, previous != null ? asList(previous) : new ArrayList<SubRepo>(), current); } - public HgSubrepoConfigChange(@NotNull String path, + public HgSubrepoConfigChange(@NotNull String mainRepoRevision, + @NotNull String path, @NotNull List<SubRepo> previous, @Nullable SubRepo current) { + myMainRepoRevision = mainRepoRevision; myPath = path; myPrevious = previous; myCurrent = current; } @NotNull + public String getMainRepoRevision() { + return myMainRepoRevision; + } + + @NotNull public String getPath() { return myPath; }
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubRepo.java Mon Jan 13 20:29:59 2014 +0100 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubRepo.java Tue Jan 14 11:36:24 2014 +0100 @@ -1,5 +1,6 @@ package jetbrains.buildServer.buildTriggers.vcs.mercurial; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception.WrongSubrepoUrlException; import org.jetbrains.annotations.NotNull; import java.net.URI; @@ -55,7 +56,8 @@ } @NotNull - public String resolveUrl(@NotNull String parentRepoUrl) throws URISyntaxException { + public String resolveUrl(@NotNull String parentRepoUrl) throws WrongSubrepoUrlException { + //TODO: Handle paths on windows. Those paths are not papable for URL if (!parentRepoUrl.endsWith("/")) parentRepoUrl = parentRepoUrl + "/"; try { @@ -64,10 +66,8 @@ if (isSsh(subrepoAbsUrl) && isPathFromRoot(parentURI)) return getUrlWithPathFromRoot(subrepoAbsUrl); return subrepoAbsUrl.toString(); - } catch (URISyntaxException e) { - return parentRepoUrl + url(); - } catch (IllegalArgumentException e) { - return url(); + } catch (Exception e) { + throw new WrongSubrepoUrlException(parentRepoUrl, url(), e); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/exception/WrongSubrepoUrlException.java Tue Jan 14 11:36:24 2014 +0100 @@ -0,0 +1,11 @@ +package jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception; + +import org.jetbrains.annotations.NotNull; + +public class WrongSubrepoUrlException extends Exception { + + public WrongSubrepoUrlException(@NotNull String parentRepoUrl, @NotNull String subrepoUrl, Throwable cause) { + super("Parent repository " + parentRepoUrl + ", subrepo " + subrepoUrl, cause); + } + +}
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/CheckoutRepository.java Mon Jan 13 20:29:59 2014 +0100 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/CheckoutRepository.java Tue Jan 14 11:36:24 2014 +0100 @@ -1,13 +1,13 @@ package jetbrains.buildServer.buildTriggers.vcs.mercurial; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception.WrongSubrepoUrlException; import jetbrains.buildServer.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.File; import java.io.IOException; -import java.net.URISyntaxException; import java.util.Map; import static jetbrains.buildServer.util.FileUtil.delete; @@ -128,7 +128,7 @@ HgVcsRoot subrepoRoot = root.withUrl(subrepoUrl); updateRepository(subrepoRoot, subrepoDir, subrepoConfig.revision()); } - } catch (URISyntaxException e) { + } catch (WrongSubrepoUrlException e) { subrepoUrl = subrepoConfig.url(); }
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialCollectChangesPolicy.java Mon Jan 13 20:29:59 2014 +0100 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialCollectChangesPolicy.java Tue Jan 14 11:36:24 2014 +0100 @@ -1,14 +1,17 @@ package jetbrains.buildServer.buildTriggers.vcs.mercurial; -import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.*; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.ChangeSet; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.ChangeSetRevision; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.LogCommand; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception.UnknownRevisionException; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception.WrongSubrepoUrlException; import jetbrains.buildServer.log.Loggers; import jetbrains.buildServer.vcs.*; import jetbrains.buildServer.vcs.impl.VcsRootImpl; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.net.URISyntaxException; import java.util.*; import static java.util.Arrays.asList; @@ -251,14 +254,22 @@ VcsRootImpl subrepo = new VcsRootImpl(root.getId(), subrepoParams); if (ctx.isProcessedSubrepoChanges(subrepo, prevRevisions, curRevision)) continue; - List<ModificationData> subChanges = collectChanges(ctx, subrepo, prevRevisions, curRevision, CheckoutRules.DEFAULT); - for (ModificationData m : subChanges) { - if (!ctx.isReportedModification(m)) { - subrepoChanges.add(m); - ctx.markAsReported(m); + try { + List<ModificationData> subChanges = collectChanges(ctx, subrepo, prevRevisions, curRevision, CheckoutRules.DEFAULT); + for (ModificationData m : subChanges) { + if (!ctx.isReportedModification(m)) { + subrepoChanges.add(m); + ctx.markAsReported(m); + } } + ctx.markProcessedSubrepoChanges(subrepo, prevRevisions, curRevision); + } catch (VcsException e) { + Loggers.VCS.warn("Error while collecting subrepo changes, repository: " + hgRoot.getRepository() + + ", revision: " + configChange.getMainRepoRevision() + + ", subrepo: " + subrepoUrl + " at " + configChange.getPath() + + ", subrepo revisions interval: [" + prevRevisions + ", " + curRevision + "] "+ + "skip collecting subrepo changes in this interval", e); } - ctx.markProcessedSubrepoChanges(subrepo, prevRevisions, curRevision); } List<ModificationData> subSubrepoChanges = getSubrepoChanges(ctx, root, subrepoChanges); @@ -300,9 +311,10 @@ for (SubRepo prevSubrepo : c.getPrevious()) { prevSubrepos.add(new SubRepo(path, subrepoUrl, ctx.getStringFromPool(prevSubrepo.revision()))); } - configChanges.add(new HgSubrepoConfigChange(path, prevSubrepos, new SubRepo(path, subrepoUrl, curRevision))); - } catch (URISyntaxException e) { - throw new VcsException(e); + configChanges.add(new HgSubrepoConfigChange(m.getVersion(), path, prevSubrepos, new SubRepo(path, subrepoUrl, curRevision))); + } catch (WrongSubrepoUrlException e) { + Loggers.VCS.warn("Error while collecting subrepo config changes, repository: " + mainRoot.getRepository() + +", commit: " + m.getVersion() + ", skip subrepo changes in this commit", e); } } }
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java Mon Jan 13 20:29:59 2014 +0100 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java Tue Jan 14 11:36:24 2014 +0100 @@ -21,6 +21,7 @@ import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.*; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception.AbandonedTransactionFound; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception.UnrelatedRepositoryException; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception.WrongSubrepoUrlException; import jetbrains.buildServer.log.Loggers; import jetbrains.buildServer.serverSide.InvalidProperty; import jetbrains.buildServer.serverSide.PropertiesProcessor; @@ -41,7 +42,6 @@ import java.io.FileFilter; import java.io.FileInputStream; import java.io.IOException; -import java.net.URISyntaxException; import java.util.*; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.HgFileUtil.deleteDir; @@ -304,7 +304,7 @@ CheckoutRules subrepoRules = mySubrepoCheckoutRulesProvider.getSubrepoRules(mainRootRules, subrepoPath); buildPatch(subrepoRoot, subrepoFromRevision, subrepoToRevision, builder, subrepoRules); } - } catch (URISyntaxException e) { + } catch (WrongSubrepoUrlException e) { throw new VcsException("Error while resolving subrepo url", e); } } @@ -395,7 +395,7 @@ Map<String, SubRepo> subSubrepos = subrepo.getSubrepositories(subrepoConfig.revision()); if (!subSubrepos.isEmpty()) cloneSubrepos(subrepoRoot, subrepoDir, subSubrepos); - } catch (URISyntaxException error) { + } catch (WrongSubrepoUrlException error) { //ignore it, will try to clone from network during main repository update } }
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubRepoTest.java Mon Jan 13 20:29:59 2014 +0100 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubRepoTest.java Tue Jan 14 11:36:24 2014 +0100 @@ -1,9 +1,11 @@ package jetbrains.buildServer.buildTriggers.vcs.mercurial; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception.WrongSubrepoUrlException; import org.jetbrains.annotations.NotNull; import org.testng.annotations.Test; import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.fail; @Test public class SubRepoTest { @@ -15,7 +17,11 @@ assertEquals("http://acme.org/mainrepo/subrepo", subrepoWithUrl("subrepo").resolveUrl("http://acme.org/mainrepo")); assertEquals("http://some.org/subrepo", subrepoWithUrl("http://some.org/subrepo").resolveUrl("http://acme.org/mainrepo")); assertEquals("c:/subrepo", subrepoWithUrl("c:/subrepo").resolveUrl("http://acme.org/mainrepo")); - assertEquals("c:\\subrepo", subrepoWithUrl("c:\\subrepo").resolveUrl("http://acme.org/mainrepo")); + try { + subrepoWithUrl("c:\\subrepo").resolveUrl("http://acme.org/mainrepo"); + fail(); + } catch (WrongSubrepoUrlException e) { + } assertEquals("ssh://acme.org//subrepo", subrepoWithUrl("../subrepo").resolveUrl("ssh://acme.org//mainrepo")); assertEquals("ssh://acme.org/subrepo", subrepoWithUrl("../subrepo").resolveUrl("ssh://acme.org/mainrepo")); }