Mercurial > hg > mercurial
changeset 129:021589a73f03
Fix problem with windows paths
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Wed, 06 Oct 2010 14:00:36 +0400 |
parents | 5ff5ff61f7d4 |
children | fc86dd075156 |
files | mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/Settings.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SettingsTest.java |
diffstat | 2 files changed, 33 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/Settings.java Tue Sep 28 15:00:50 2010 +0400 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/Settings.java Wed Oct 06 14:00:36 2010 +0400 @@ -105,17 +105,20 @@ * @return URL to use for push command */ public String getRepositoryUrl() { - if (containsCredentials(myRepository)) return myRepository; - - try { - URI repoURI = createUriWithCredentials(myRepository); - if (AUTH_PROTOS.contains(repoURI.getScheme())) { - return repoURI.toASCIIString(); + if (isRequireCredentials()) { + if (containsCredentials(myRepository)) return myRepository; + try { + URI repoURI = createUriWithCredentials(myRepository); + if (AUTH_PROTOS.contains(repoURI.getScheme())) { + return repoURI.toASCIIString(); + } + } catch (URISyntaxException e) { + Loggers.VCS.warn("Error while parsing url " + myRepository, e); } - } catch (URISyntaxException e) { - Loggers.VCS.warn("Error while parsing url " + myRepository, e); + return myRepository; + } else { + return myRepository; } - return myRepository; } private boolean containsCredentials(final String repository) { @@ -144,6 +147,15 @@ repositoryURI.getFragment()); } + private boolean isRequireCredentials() { + for (String scheme : AUTH_PROTOS) { + if (myRepository.startsWith(scheme + ":")) { + return true; + } + } + return false; + } + private String createUserInfo() { String userInfo = ""; if (!StringUtil.isEmpty(myUsername)) {
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SettingsTest.java Tue Sep 28 15:00:50 2010 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SettingsTest.java Wed Oct 06 14:00:36 2010 +0400 @@ -57,6 +57,18 @@ assertEquals("http://my.name%40gmail.com:1234@host.com/path", settings.getRepositoryUrl()); } + public void test_windows_path() throws Exception { + VcsRootImpl vcsRoot = createVcsRoot("c:\\windows\\path"); + Settings settings = new Settings(new File("."), vcsRoot); + assertEquals("c:\\windows\\path", settings.getRepositoryUrl()); + } + + public void test_file_scheme_has_no_credentials() { + VcsRootImpl vcsRoot = createVcsRoot("file:///path/to/repo", "my.name@gmail.com", "1234"); + Settings settings = new Settings(new File("."), vcsRoot); + assertEquals("file:///path/to/repo", settings.getRepositoryUrl()); + } + private VcsRootImpl createVcsRoot(String url) { return createVcsRoot(url, "user", "pwd"); }