changeset 590:87754c01d304

LogUtil is not available in vcs worker + remove duplicates
author Dmitry Neverov <dmitry.neverov@jetbrains.com>
date Wed, 17 Apr 2013 14:56:05 +0400
parents ed76a2fa86bf
children c85cb270d59c
files mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialCollectChangesPolicy.java mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/BookmarksTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RevisionFormatTest.java
diffstat 4 files changed, 8 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialCollectChangesPolicy.java	Tue Apr 16 16:48:27 2013 +0400
+++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialCollectChangesPolicy.java	Wed Apr 17 14:56:05 2013 +0400
@@ -3,7 +3,6 @@
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.*;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception.UnknownRevisionException;
 import jetbrains.buildServer.log.Loggers;
-import jetbrains.buildServer.serverSide.impl.LogUtil;
 import jetbrains.buildServer.vcs.*;
 import jetbrains.buildServer.vcs.impl.VcsRootImpl;
 import org.jetbrains.annotations.NotNull;
@@ -48,7 +47,7 @@
     String defaultBranchName = hgRoot.getBranchName();
     if (revisions.get(defaultBranchName) == null) {
       throw new VcsException("Cannot find revision of the default branch '" +
-              defaultBranchName + "' of vcs root " + LogUtil.describe(root));
+              defaultBranchName + "' of vcs root " + myVcs.describeVcsRoot(root));
     }
     return RepositoryStateData.createVersionState(defaultBranchName, revisions);
   }
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java	Tue Apr 16 16:48:27 2013 +0400
+++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java	Wed Apr 17 14:56:05 2013 +0400
@@ -21,7 +21,6 @@
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception.UnrelatedRepositoryException;
 import jetbrains.buildServer.log.Loggers;
 import jetbrains.buildServer.serverSide.*;
-import jetbrains.buildServer.serverSide.impl.LogUtil;
 import jetbrains.buildServer.util.EventDispatcher;
 import jetbrains.buildServer.util.FileUtil;
 import jetbrains.buildServer.util.cache.ResetCacheRegister;
@@ -482,39 +481,6 @@
   }
 
   @NotNull
-  public RepositoryStateData getCurrentState(@NotNull VcsRoot root) throws VcsException {
-    HgVcsRoot hgRoot = myHgVcsRootFactory.createHgRoot(root);
-    syncRepository(hgRoot);
-    Map<String, String> revisions = new HashMap<String, String>();
-    revisions.putAll(getBookmarkRevisions(hgRoot));
-    revisions.putAll(getBranchesRevisions(hgRoot));
-    String defaultBranchName = hgRoot.getBranchName();
-    if (revisions.get(defaultBranchName) == null) {
-      throw new VcsException("Cannot find revision of the default branch '" +
-              defaultBranchName + "' of vcs root " + LogUtil.describe(root));
-    }
-    return RepositoryStateData.createVersionState(defaultBranchName, revisions);
-  }
-
-  @NotNull
-  private Map<String, String> getBranchesRevisions(@NotNull HgVcsRoot root) throws VcsException {
-    HgRepo repo = createRepo(root);
-    return repo.branches().call();
-  }
-
-  @NotNull
-  private Map<String, String> getBookmarkRevisions(@NotNull HgVcsRoot root) throws VcsException {
-    ServerHgRepo repo = createRepo(root);
-    if (!myConfig.bookmarksEnabled())
-      return emptyMap();
-    HgVersion v = repo.version().call();
-    if (!v.isEqualsOrGreaterThan(BookmarksCommand.REQUIRED_HG_VERSION))
-      return emptyMap();
-    return repo.bookmarks().call();
-  }
-
-
-  @NotNull
   public MercurialCollectChangesPolicy getCollectChangesPolicy() {
     return new MercurialCollectChangesPolicy(this, myConfig, myHgVcsRootFactory, myRepoFactory, myHgPathProvider);
   }
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/BookmarksTest.java	Tue Apr 16 16:48:27 2013 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/BookmarksTest.java	Wed Apr 17 14:56:05 2013 +0400
@@ -58,7 +58,7 @@
 
   public void current_state_should_include_bookmarks(@NotNull HgVersion _) throws Exception {
     setupRemoteRepositoryWithTwoBookmarks();
-    RepositoryStateData state = myVcs.getCurrentState(myRoot);
+    RepositoryStateData state = myVcs.getCollectChangesPolicy().getCurrentState(myRoot);
     assertThat(state, hasBranch("bookmark1").withRevision("15b4a116520d"));
     assertThat(state, hasBranch("bookmark2").withRevision("e9f8f67888f5"));
   }
@@ -69,7 +69,7 @@
 
     allBookmarksRemoved();
 
-    RepositoryStateData state = myVcs.getCurrentState(myRoot);
+    RepositoryStateData state = myVcs.getCollectChangesPolicy().getCurrentState(myRoot);
     assertThat(state, hasNoBranch("bookmark1"));
     assertThat(state, hasNoBranch("bookmark2"));
   }
@@ -80,7 +80,7 @@
 
     bookmark1Updated();
 
-    RepositoryStateData state = myVcs.getCurrentState(myRoot);
+    RepositoryStateData state = myVcs.getCollectChangesPolicy().getCurrentState(myRoot);
     assertThat(state, hasBranch("bookmark1").withRevision("7597a4da7195"));
   }
 
@@ -90,7 +90,7 @@
 
     bookmark1Diverged();
 
-    RepositoryStateData state = myVcs.getCurrentState(myRoot);
+    RepositoryStateData state = myVcs.getCollectChangesPolicy().getCurrentState(myRoot);
     assertThat(state, hasBranch("bookmark1").withRevision("e9f8f67888f5"));
   }
 
@@ -100,7 +100,7 @@
 
     branchWithNameBookmark2Created();
 
-    RepositoryStateData state = myVcs.getCurrentState(myRoot);
+    RepositoryStateData state = myVcs.getCollectChangesPolicy().getCurrentState(myRoot);
     assertThat(state, hasBranch("bookmark2").withRevision("f63a14e873d6"));
   }
 
@@ -111,7 +111,7 @@
 
   private void cloneRepositoryWithTwoBookmarks() throws Exception {
     setupRemoteRepositoryWithTwoBookmarks();
-    myVcs.getCurrentState(myRoot);
+    myVcs.getCollectChangesPolicy().getCurrentState(myRoot);
   }
 
   private void bookmark1Updated() throws IOException {
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RevisionFormatTest.java	Tue Apr 16 16:48:27 2013 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RevisionFormatTest.java	Wed Apr 17 14:56:05 2013 +0400
@@ -107,7 +107,7 @@
 
 
   public void should_not_include_revnum_in_current_state() throws VcsException {
-    RepositoryStateData state = myVcs.getCurrentState(myRoot);
+    RepositoryStateData state = myVcs.getCollectChangesPolicy().getCurrentState(myRoot);
     for (Map.Entry<String, String> entry : state.getBranchRevisions().entrySet()) {
       String branchName = entry.getKey();
       String revision = entry.getKey();