Mercurial > hg > mercurial
changeset 685:5a0fc80839a8
Fix push from IDEA
author | eugene.petrenko@gmail.com |
---|---|
date | Tue, 10 Dec 2013 18:43:13 +0100 |
parents | 7fb8ecf0d35a (current diff) c0b08dd02418 (diff) |
children | 1efd1846f00a |
files | |
diffstat | 12 files changed, 207 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/artifacts/mercurial_vcs_worker.xml Tue Dec 10 18:43:13 2013 +0100 @@ -0,0 +1,19 @@ +<component name="ArtifactManager"> + <artifact name="mercurial-vcs-worker"> + <output-path>$PROJECT_DIR$/out/artifacts/mercurial_vcs_worker</output-path> + <properties id="ant-postprocessing"> + <options enabled="true"> + <file>file://$PROJECT_DIR$/build/ant.build.xml</file> + <target>replace-tokens-in-teamcity-plugin-xml</target> + </options> + </properties> + <root id="root"> + <element id="directory" name="lib"> + <element id="artifact" artifact-name="mercurial-common.jar" /> + <element id="artifact" artifact-name="mercurial-server.jar" /> + <element id="library" level="project" name="quartz-1.6.0" /> + </element> + <element id="file-copy" path="$PROJECT_DIR$/teamcity-plugin.xml" /> + </root> + </artifact> +</component> \ No newline at end of file
--- a/.idea/artifacts/plugin.xml Tue Dec 10 18:41:39 2013 +0100 +++ b/.idea/artifacts/plugin.xml Tue Dec 10 18:43:13 2013 +0100 @@ -25,6 +25,11 @@ </element> </element> <element id="file-copy" path="$PROJECT_DIR$/teamcity-plugin.xml" /> + <element id="directory" name="vcs-worker"> + <element id="archive" name="mercurial.zip"> + <element id="artifact" artifact-name="mercurial-vcs-worker" /> + </element> + </element> </root> </artifact> </component> \ No newline at end of file
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubRepo.java Tue Dec 10 18:41:39 2013 +0100 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubRepo.java Tue Dec 10 18:43:13 2013 +0100 @@ -53,6 +53,8 @@ try { URI parentURI = new URI(parentRepoUrl); URI subrepoAbsUrl = parentURI.resolve(url()); + if (isSsh(subrepoAbsUrl) && isPathFromRoot(parentURI)) + return getUrlWithPathFromRoot(subrepoAbsUrl); return subrepoAbsUrl.toString(); } catch (URISyntaxException e) { return parentRepoUrl + url(); @@ -61,6 +63,25 @@ } } + private boolean isSsh(@NotNull URI uri) { + return "ssh".equals(uri.getScheme()); + } + + private boolean isPathFromRoot(@NotNull URI uri) { + return uri.getPath() != null && uri.getPath().startsWith("//"); + } + + @NotNull + private String getUrlWithPathFromRoot(@NotNull URI uri) throws URISyntaxException { + return new URI(uri.getScheme(), + uri.getUserInfo(), + uri.getHost(), + uri.getPort(), + "/" + uri.getPath(), + uri.getQuery(), + uri.getFragment()).toString(); + } + @Override public String toString() { return myPath + " = " + myUrl + "#" + myRevision;
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResult.java Tue Dec 10 18:41:39 2013 +0100 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResult.java Tue Dec 10 18:43:13 2013 +0100 @@ -170,6 +170,18 @@ private String getExceptionMessage() { StringBuilder message = new StringBuilder(); message.append("'").append(getCommand()).append("' command failed."); + String stderr = getStderr(); + if (!isEmpty(stderr)) { + message.append("\n"); + int limit = mySettings.getExceptionOutputLimit(); + if (stderr.length() < limit || limit == -1) { + message.append("stderr: ").append(stderr); + } else { + if (limit > 4) + message.append("stderr: ").append(StringUtil.truncateStringValueWithDotsAtEnd(stderr, limit)); + message.append("\nSee details in teamcity-vcs.log"); + } + } return message.toString(); }
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandSettings.java Tue Dec 10 18:41:39 2013 +0100 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandSettings.java Tue Dec 10 18:43:13 2013 +0100 @@ -19,6 +19,7 @@ private String myLogLevel = "debug"; private Map<String, String> myHgEnv = new HashMap<String, String>(); private int myLogOutputLimit = -1; + private int myExceptionOutputLimit = 5000; public CommandSettings() { @@ -99,4 +100,12 @@ myLogOutputLimit = logOutputLimit; return this; } + + public int getExceptionOutputLimit() { + return myExceptionOutputLimit; + } + + public void setExceptionOutputLimit(int limit) { + myExceptionOutputLimit = limit; + } }
--- a/mercurial-server/resources/buildServerResources/mercurialSettings.jsp Tue Dec 10 18:41:39 2013 +0100 +++ b/mercurial-server/resources/buildServerResources/mercurialSettings.jsp Tue Dec 10 18:43:13 2013 +0100 @@ -22,7 +22,7 @@ <tr> <th><label for="branchName">Default branch: </label></th> <td> - <props:textProperty name="branchName" /> + <props:textProperty name="branchName" className="longField"/> <div class="smallNote" style="margin: 0;">Branch to be used if no branch from Branch Specification is set</div> </td> </tr> @@ -31,7 +31,7 @@ <th><label for="reportTagRevisions">Use tags as branches:</label></th> <td> <props:checkboxProperty name="useTagsAsBranches"/> - <div class="smallNote" style="margin: 0">If enabled tags can be used in branch specification</div> + <label for="reportTagRevisions">If enabled tags can be used in branch specification</label> </td> </tr> <tr class="advancedSetting"> @@ -51,7 +51,7 @@ </tr> <tr class="advancedSetting"> <th><label for="tagUsername">Username for tags/merge: </label></th> - <td><props:textProperty name="tagUsername"/> + <td><props:textProperty name="tagUsername" className="longField"/> <div class="smallNote" style="margin: 0;">Format: User Name <email></div> </td> </tr> @@ -73,14 +73,14 @@ <tr> <th><label for="username">User name:</label></th> <td> - <props:textProperty name="username"/> + <props:textProperty name="username" className="longField"/> <span class="smallNote">Leave blank to use settings from the server hgrc (see 'man hgrc' for details)</span> </td> </tr> <tr> <th><label for="secure:password">Password:</label></th> <td> - <props:passwordProperty name="secure:password"/> + <props:passwordProperty name="secure:password" className="longField"/> <span class="smallNote">Leave blank to use settings from the server hgrc (see 'man hgrc' for details)</span> </td> </tr>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialUrlSupport.java Tue Dec 10 18:43:13 2013 +0100 @@ -0,0 +1,54 @@ +package jetbrains.buildServer.buildTriggers.vcs.mercurial; + +import jetbrains.buildServer.vcs.*; +import jetbrains.buildServer.vcs.impl.VcsRootImpl; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; + +public class MercurialUrlSupport implements UrlSupport { + + private final MercurialVcsSupport myVcsSupport; + + public MercurialUrlSupport(@NotNull MercurialVcsSupport vcsSupport) { + myVcsSupport = vcsSupport; + } + + @Nullable + public Map<String, String> convertToVcsRootProperties(@NotNull VcsUrl url) throws VcsException { + String fetchUrl = url.getUrl(); + + boolean testRequired = true; + MavenVcsUrl mavenUrl = url.asMavenVcsUrl(); + if (mavenUrl != null && !"hg".equals(mavenUrl.getProviderSchema())) { + return null; + } + + if (mavenUrl != null) { + fetchUrl = mavenUrl.getProviderSpecificPart(); + testRequired = false; + } + + Map<String, String> res = new HashMap<String, String>(myVcsSupport.getDefaultVcsProperties()); + res.put(Constants.REPOSITORY_PROP, fetchUrl); + Credentials credentials = url.getCredentials(); + if (credentials != null) { + res.put(Constants.USERNAME, credentials.getUsername()); + res.put(Constants.PASSWORD, credentials.getPassword()); + } + + if (testRequired) { + try { + TestConnectionSupport testConnectionSupport = myVcsSupport.getTestConnectionSupport(); + assert testConnectionSupport != null; + testConnectionSupport.testConnection(new VcsRootImpl(-1, res)); + } catch (VcsException e) { + return null; + } + } + + return res; + } +}
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java Tue Dec 10 18:41:39 2013 +0100 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java Tue Dec 10 18:43:13 2013 +0100 @@ -664,6 +664,10 @@ return new ListFilesSupport(this, myConfig, myHgVcsRootFactory); } + @NotNull + public UrlSupport getUrlSupport() { + return new MercurialUrlSupport(this); + } @Override @Nullable
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialUrlSupportTest.java Tue Dec 10 18:43:13 2013 +0100 @@ -0,0 +1,57 @@ +package jetbrains.buildServer.buildTriggers.vcs.mercurial; + +import jetbrains.buildServer.BaseTestCase; +import jetbrains.buildServer.vcs.Credentials; +import jetbrains.buildServer.vcs.VcsException; +import jetbrains.buildServer.vcs.VcsUrl; +import junit.framework.Assert; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.util.Map; + +import static jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialSupportBuilder.mercurialSupport; +import static junit.framework.Assert.*; + +@Test +public class MercurialUrlSupportTest extends BaseMercurialTestCase { + private MercurialUrlSupport myUrlSupport; + + @BeforeMethod + @Override + public void setUp() throws Exception { + super.setUp(); + + ServerPluginConfig myPluginConfig = new ServerPluginConfigBuilder() + .cachesDir(myTempFiles.createTempDir()) + .build(); + MercurialVcsSupport vcsSupport = mercurialSupport().withConfig(myPluginConfig).build(); + myUrlSupport = new MercurialUrlSupport(vcsSupport); + } + + public void maven_like_url() throws VcsException { + VcsUrl url = new VcsUrl("scm:hg:http://host/v3", new Credentials("user1", "pass1")); + Map<String, String> props = myUrlSupport.convertToVcsRootProperties(url); + assertNotNull(props); + + assertEquals("http://host/v3", props.get(Constants.REPOSITORY_PROP)); + assertEquals("user1", props.get(Constants.USERNAME)); + assertEquals("pass1", props.get(Constants.PASSWORD)); + } + + public void http_protocol_mercurial_repo() throws VcsException { + VcsUrl url = new VcsUrl("http://hg.jetbrains.org/hg/mercurial/", new Credentials("user1", "pass1")); + Map<String, String> props = myUrlSupport.convertToVcsRootProperties(url); + assertNotNull(props); + + assertEquals("http://hg.jetbrains.org/hg/mercurial/", props.get(Constants.REPOSITORY_PROP)); + assertEquals("user1", props.get(Constants.USERNAME)); + assertEquals("pass1", props.get(Constants.PASSWORD)); + } + + public void http_protocol_svn_repo() throws VcsException { + VcsUrl url = new VcsUrl("http://svn.jetbrains.org/teamcity/plugins/xml-tests-reporting/trunk"); + Map<String, String> props = myUrlSupport.convertToVcsRootProperties(url); + assertNull(props); + } +}
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubRepoTest.java Tue Dec 10 18:41:39 2013 +0100 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubRepoTest.java Tue Dec 10 18:43:13 2013 +0100 @@ -9,12 +9,15 @@ public class SubRepoTest { public void url_resolution() throws Exception { + //http://www.selenic.com/mercurial/hg.1.html#urls assertEquals("http://acme.org/subrepo", subrepoWithUrl("../subrepo").resolveUrl("http://acme.org/mainrepo")); assertEquals("http://acme.org/mainrepo/subrepo", subrepoWithUrl("./subrepo").resolveUrl("http://acme.org/mainrepo")); 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")); + assertEquals("ssh://acme.org//subrepo", subrepoWithUrl("../subrepo").resolveUrl("ssh://acme.org//mainrepo")); + assertEquals("ssh://acme.org/subrepo", subrepoWithUrl("../subrepo").resolveUrl("ssh://acme.org/mainrepo")); } private SubRepo subrepoWithUrl(@NotNull String subrepoUrl) {
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResultTest.java Tue Dec 10 18:41:39 2013 +0100 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResultTest.java Tue Dec 10 18:43:13 2013 +0100 @@ -101,13 +101,25 @@ public void exception_should_not_contain_command_stdout_or_stderr() { final String stdout = "300Mb of output"; final String stderr = "300Mb from stderr"; - CommandResult cr = commandResultFor(execResult().withStdout(stdout).withStderr(stderr)); + CommandSettings settings = new CommandSettings(); + settings.setExceptionOutputLimit(0); + CommandResult cr = commandResultFor(execResult().withStdout(stdout).withStderr(stderr), settings); try { cr.checkCommandFailed(); } catch (VcsException e) { assertThat(e.getMessage(), not(containsString(stdout))); assertThat(e.getMessage(), not(containsString(stderr))); } + + settings = new CommandSettings(); + settings.setExceptionOutputLimit(14); + cr = commandResultFor(execResult().withStdout(stdout).withStderr(stderr), settings); + try { + cr.checkCommandFailed(); + } catch (VcsException e) { + assertThat(e.getMessage(), containsString("300Mb from...")); + assertThat(e.getMessage(), containsString("See details in teamcity-vcs.log")); + } } public void when_command_fails_stderr_should_be_logged() { @@ -128,6 +140,10 @@ return new CommandResult(myLogger, "", builder.build(), new HashSet<String>(Arrays.asList(privateData)), new CommandSettings()); } + CommandResult commandResultFor(ExecResultBuilder builder, CommandSettings settings) { + return new CommandResult(myLogger, "", builder.build(), new HashSet<String>(), settings); + } + private class ExecResultBuilder { private String myStdout = ""; private String myStderr = "";
--- a/mercurial-tests/src/testng.xml Tue Dec 10 18:41:39 2013 +0100 +++ b/mercurial-tests/src/testng.xml Tue Dec 10 18:43:13 2013 +0100 @@ -36,6 +36,7 @@ <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.TagsTest"/> <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.CommitsInfoBuilderSupportTest"/> <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialModificationInfoBuilderTest"/> + <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialUrlSupportTest"/> </classes> </test> </suite>