changeset 793:0a1ac46bfa8c Gaya-8.1.x

TW-33522 do not retry clone for repositories with custom clone dirs A custom dir was configured by user, so hg-plugin cannot change it. Running clone in the same directory will fail with the same error, there is no reason to do that.
author Dmitry Neverov <dmitry.neverov@gmail.com>
date Mon, 19 May 2014 17:14:38 +0200
parents 75aed0d7a1f9
children 7a8caf98dc6e
files mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java	Mon May 19 17:05:32 2014 +0200
+++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java	Mon May 19 17:14:38 2014 +0200
@@ -498,6 +498,7 @@
   }
 
   public <T> T syncRepository(@NotNull HgVcsRoot root, @NotNull VcsCallable<T> cmd) throws VcsException {
+    boolean customWorkingDir = root.getCustomWorkingDir() != null;
     File workingDir = getWorkingDir(root);
     int attemptsLeft = 3;
     VcsException lastError = null;
@@ -505,11 +506,15 @@
       try {
         return syncRepositoryOnce(root, cmd, workingDir);
       } catch (UnrelatedRepositoryException e) {
+        if (customWorkingDir)
+          throw e;
         Loggers.VCS.warn("Repository at " + workingDir.getAbsolutePath() + " is unrelated to " + root.getRepository() +
                 ". Clone it again, attempts left " + attemptsLeft);
         myMirrorManager.forgetDir(workingDir);
         lastError = e;
       } catch (AbandonedTransactionFound e) {
+        if (customWorkingDir)
+          throw e;
         Loggers.VCS.warn("Abandoned transaction found in repository " + root.getRepository() + " at "
                 + workingDir.getAbsolutePath() + ". Clone it again, attempts left " + attemptsLeft);
         myMirrorManager.forgetDir(workingDir);