diff mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/Settings.java @ 63:cef5cfe52e3e

do not set credentials in the url if url already has them
author C:\Documents and Settings\pavel.sher\Application Data\The Bat!
date Thu, 02 Jul 2009 20:14:58 +0400
parents 99e757f2527b
children c9f14e3ef86d
line wrap: on
line diff
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/Settings.java	Wed Nov 26 19:12:27 2008 +0300
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/Settings.java	Thu Jul 02 20:14:58 2009 +0400
@@ -103,6 +103,8 @@
    * @return URL to use for push command
    */
   public String getPushUrl() {
+    if (containsCredentials(myRepository)) return myRepository;
+
     String cre = "";
     if (!StringUtil.isEmpty(myUsername)) {
       cre += myUsername;
@@ -121,6 +123,18 @@
     return myRepository;
   }
 
+  private boolean containsCredentials(final String repository) {
+    for (String proto: AUTH_PROTOS) {
+      if (myRepository.startsWith(proto)) {
+        String withoutProto = myRepository.substring(proto.length());
+        int comma = withoutProto.indexOf(':');
+        int at = withoutProto.indexOf('@');
+        if (at != -1 && comma != -1 && at > comma) return true;
+      }
+    }
+    return false;
+  }
+
   public void setHgCommandPath(@NotNull final String hgCommandPath) {
     myHgCommandPath = hgCommandPath;
   }