changeset 348:fd56b9524834

Better method name
author Dmitry Neverov <dmitry.neverov@jetbrains.com>
date Wed, 11 Jan 2012 15:09:52 +0400
parents 4a49a0baf30b
children e0464f11206c
files mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialIncludeRuleUpdater.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommand.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/IdentifyCommand.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PullCommand.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PushCommand.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/Settings.java mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SettingsTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommandTestCase.java
diffstat 9 files changed, 26 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialIncludeRuleUpdater.java	Wed Jan 11 13:22:42 2012 +0400
+++ b/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialIncludeRuleUpdater.java	Wed Jan 11 15:09:52 2012 +0400
@@ -119,7 +119,7 @@
 
   private void updateLocalMirror() throws VcsException, IOException {
     Settings settings = new Settings(myHgPathProvider, myRoot);
-    File mirrorDir = myMirrorManager.getMirrorDir(settings.getRepositoryUrl());
+    File mirrorDir = myMirrorManager.getMirrorDir(settings.getRepositoryUrlWithCredentials());
     myLogger.message("Update local mirror at " + mirrorDir);
     if (!Settings.isValidRepository(mirrorDir)) {
       initRepository(settings, mirrorDir, false);
@@ -276,10 +276,10 @@
 
   private String getDefaultPullUrl(Settings settings, boolean useLocalMirror) throws IOException {
     if (useLocalMirror) {
-      File mirrorDir = myMirrorManager.getMirrorDir(settings.getRepositoryUrl());
+      File mirrorDir = myMirrorManager.getMirrorDir(settings.getRepositoryUrlWithCredentials());
       return mirrorDir.getCanonicalPath();
     } else {
-      return settings.getRepositoryUrl();
+      return settings.getRepositoryUrlWithCredentials();
     }
   }
 
@@ -295,7 +295,7 @@
 
   public boolean isClonedFromLocalMirror(@NotNull final File workingDir) {
     try {
-      File mirrorDir = myMirrorManager.getMirrorDir(mySettings.getRepositoryUrl());
+      File mirrorDir = myMirrorManager.getMirrorDir(mySettings.getRepositoryUrlWithCredentials());
       File hgrc = new File(workingDir, ".hg" + File.separator + "hgrc");
       String config = FileUtil.readText(hgrc);
       return config.contains("default = " + mirrorDir.getCanonicalPath());
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommand.java	Wed Jan 11 13:22:42 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommand.java	Wed Jan 11 15:09:52 2012 +0400
@@ -31,7 +31,7 @@
   public CloneCommand(@NotNull Settings settings, @NotNull File workingDir) {
     super(settings, workingDir);
     myWorkingDir = workingDir;
-    myRepository = getSettings().getRepositoryUrl();
+    myRepository = getSettings().getRepositoryUrlWithCredentials();
   }
 
   /**
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/IdentifyCommand.java	Wed Jan 11 13:22:42 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/IdentifyCommand.java	Wed Jan 11 15:09:52 2012 +0400
@@ -53,7 +53,7 @@
     if (myInLocalRepository) {
       cli.setWorkDirectory(this.getWorkDirectory().getAbsolutePath());
     } else {
-      cli.addParameter(getSettings().getRepositoryUrl());
+      cli.addParameter(getSettings().getRepositoryUrlWithCredentials());
     }
     if (myChangeSet != null) {
       cli.addParameter("--rev");
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PullCommand.java	Wed Jan 11 13:22:42 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PullCommand.java	Wed Jan 11 15:09:52 2012 +0400
@@ -30,7 +30,7 @@
   private final String myPullUrl;
 
   public PullCommand(@NotNull Settings settings, @NotNull File workingDir) {
-    this(settings, workingDir, settings.getRepositoryUrl());
+    this(settings, workingDir, settings.getRepositoryUrlWithCredentials());
   }
 
   public PullCommand(@NotNull Settings settings, @NotNull File workingDir, @NotNull String pullUrl) {
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PushCommand.java	Wed Jan 11 13:22:42 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PushCommand.java	Wed Jan 11 15:09:52 2012 +0400
@@ -41,7 +41,7 @@
     if (myForced) {
       cli.addParameter("-f");
     }
-    cli.addParameter(getSettings().getRepositoryUrl());
+    cli.addParameter(getSettings().getRepositoryUrlWithCredentials());
     CommandResult res = runCommand(cli);
     failIfNotEmptyStdErr(cli, res);
   }
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/Settings.java	Wed Jan 11 13:22:42 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/Settings.java	Wed Jan 11 15:09:52 2012 +0400
@@ -116,13 +116,10 @@
     AUTH_PROTOS.add("ssh");
   }
 
-  /**
-   * Returns URL to use for push command
-   * @return URL to use for push command
-   */
-  public String getRepositoryUrl() {
+  public String getRepositoryUrlWithCredentials() {
     if (isRequireCredentials()) {
-      if (containsCredentials(myRepository)) return myRepository;
+      if (containsCredentials(myRepository))
+        return myRepository;
       try {
         return createURLWithCredentials(myRepository);
       } catch (MalformedURLException e) {
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java	Wed Jan 11 13:22:42 2012 +0400
+++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java	Wed Jan 11 15:09:52 2012 +0400
@@ -255,7 +255,7 @@
         StringBuilder res = new StringBuilder();
         res.append(quoteIfNeeded(settings.getHgCommandPath()));
         res.append(" identify ");
-        final String obfuscatedUrl = CommandUtil.removePrivateData(settings.getRepositoryUrl(), Collections.singleton(settings.getPassword()));
+        final String obfuscatedUrl = CommandUtil.removePrivateData(settings.getRepositoryUrlWithCredentials(), Collections.singleton(settings.getPassword()));
         res.append(quoteIfNeeded(obfuscatedUrl));
         res.append('\n').append(id.execute());
         return res.toString();
@@ -775,7 +775,7 @@
 
   private File getWorkingDir(Settings s) {
     File customDir = s.getCustomWorkingDir();
-    return customDir != null ? customDir : myMirrorManager.getMirrorDir(s.getRepositoryUrl());
+    return customDir != null ? customDir : myMirrorManager.getMirrorDir(s.getRepositoryUrlWithCredentials());
   }
 
   private Settings createSettings(final VcsRoot root) throws VcsException {
@@ -786,7 +786,7 @@
       createClonedRepositoryParentDir(parentDir);
 
       // take last part of repository path
-      String repPath = settings.getRepositoryUrl();
+      String repPath = settings.getRepositoryUrlWithCredentials();
       String[] splitted = repPath.split("[/\\\\]");
       if (splitted.length > 0) {
         repPath = splitted[splitted.length-1];
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SettingsTest.java	Wed Jan 11 13:22:42 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SettingsTest.java	Wed Jan 11 15:09:52 2012 +0400
@@ -49,57 +49,57 @@
   public void test_url_without_credentials() {
     VcsRootImpl vcsRoot = createVcsRoot("http://host.com/path");
     Settings settings = createSettings(vcsRoot);
-    assertEquals("http://user:pwd@host.com/path", settings.getRepositoryUrl());
+    assertEquals("http://user:pwd@host.com/path", settings.getRepositoryUrlWithCredentials());
   }
 
   public void test_url_with_credentials() {
     VcsRootImpl vcsRoot = createVcsRoot("http://user:pwd@host.com/path");
     Settings settings = createSettings(vcsRoot);
-    assertEquals("http://user:pwd@host.com/path", settings.getRepositoryUrl());
+    assertEquals("http://user:pwd@host.com/path", settings.getRepositoryUrlWithCredentials());
   }
 
   public void test_url_with_username() {
     VcsRootImpl vcsRoot = createVcsRoot("http://user@host.com/path");
     Settings settings = createSettings(vcsRoot);
-    assertEquals("http://user:pwd@host.com/path", settings.getRepositoryUrl());
+    assertEquals("http://user:pwd@host.com/path", settings.getRepositoryUrlWithCredentials());
   }
 
   public void test_url_with_at_after_slash() {
     VcsRootImpl vcsRoot = createVcsRoot("http://host.com/path@");
     Settings settings = createSettings(vcsRoot);
-    assertEquals("http://user:pwd@host.com/path@", settings.getRepositoryUrl());
+    assertEquals("http://user:pwd@host.com/path@", settings.getRepositoryUrlWithCredentials());
   }
 
   public void test_url_with_at_in_username() {
     VcsRootImpl vcsRoot = createVcsRoot("http://host.com/path", "my.name@gmail.com", "1234");
     Settings settings = createSettings(vcsRoot);
-    assertEquals("http://my.name%40gmail.com:1234@host.com/path", settings.getRepositoryUrl());
+    assertEquals("http://my.name%40gmail.com:1234@host.com/path", settings.getRepositoryUrlWithCredentials());
   }
 
   /** TW-13768 */
   public void test_underscore_in_host() {
 		VcsRootImpl vcsRoot = createVcsRoot("http://Klekovkin.SDK_GARANT:8000/", "my.name@gmail.com", "1234");
     Settings settings = createSettings(vcsRoot);
-		assertEquals("http://my.name%40gmail.com:1234@Klekovkin.SDK_GARANT:8000/", settings.getRepositoryUrl());
+		assertEquals("http://my.name%40gmail.com:1234@Klekovkin.SDK_GARANT:8000/", settings.getRepositoryUrlWithCredentials());
 	}
 
   /** TW-13768 */
   public void test_underscore_in_host_with_credentials_in_url() {
     VcsRootImpl vcsRoot = createVcsRoot("http://me:mypass@Klekovkin.SDK_GARANT:8000/");
     Settings settings = createSettings(vcsRoot);
-		assertEquals("http://me:mypass@Klekovkin.SDK_GARANT:8000/", settings.getRepositoryUrl());
+		assertEquals("http://me:mypass@Klekovkin.SDK_GARANT:8000/", settings.getRepositoryUrlWithCredentials());
   }
 
   public void test_windows_path() throws Exception {
     VcsRootImpl vcsRoot = createVcsRoot("c:\\windows\\path");
     Settings settings = createSettings(vcsRoot);
-    assertEquals("c:\\windows\\path", settings.getRepositoryUrl());
+    assertEquals("c:\\windows\\path", settings.getRepositoryUrlWithCredentials());
   }
 
   public void test_file_scheme_has_no_credentials() {
     VcsRootImpl vcsRoot = createVcsRoot("file:///path/to/repo", "my.name@gmail.com", "1234");
     Settings settings = createSettings(vcsRoot);
-    assertEquals("file:///path/to/repo", settings.getRepositoryUrl());
+    assertEquals("file:///path/to/repo", settings.getRepositoryUrlWithCredentials());
   }
 
   public void uncompressed_transfer() {
@@ -113,14 +113,14 @@
   public void ampersand_in_password() {
     VcsRootImpl vcsRoot = createVcsRoot("http://some.org/path", "user", "m&n");
     Settings settings = createSettings(vcsRoot);
-    assertEquals("http://user:m%26n@some.org/path", settings.getRepositoryUrl());
+    assertEquals("http://user:m%26n@some.org/path", settings.getRepositoryUrlWithCredentials());
   }
 
   //TW-18835
   public void test_ssh() {
     VcsRootImpl vcsRoot = createVcsRoot("ssh://ourserver.com/mercurialrepo/", "user", "pwd");
     Settings settings = createSettings(vcsRoot);
-    assertEquals("ssh://user:pwd@ourserver.com/mercurialrepo/", settings.getRepositoryUrl());
+    assertEquals("ssh://user:pwd@ourserver.com/mercurialrepo/", settings.getRepositoryUrlWithCredentials());
   }
 
   private VcsRootImpl createVcsRoot(String url) {
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommandTestCase.java	Wed Jan 11 13:22:42 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommandTestCase.java	Wed Jan 11 15:09:52 2012 +0400
@@ -75,7 +75,7 @@
     VcsRoot vcsRoot = new VcsRootImpl(1, vcsRootProps);
     ServerPluginConfig config = new ServerPluginConfigBuilder().build();
     Settings settings = new Settings(new ServerHgPathProvider(config), vcsRoot);
-    final File workingDir = mirrorManager.getMirrorDir(settings.getRepositoryUrl());
+    final File workingDir = mirrorManager.getMirrorDir(settings.getRepositoryUrlWithCredentials());
     settings.setCustomWorkingDir(workingDir);
     try {
       if (myCloneRequired) {