diff mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java @ 299:e9e7d9fcf57d

Use customized xml output from the 'hg log' command instead of running 'hg status' for every commit
author Dmitry Neverov <dmitry.neverov@jetbrains.com>
date Thu, 08 Sep 2011 12:56:56 +0400
parents 8c1fd2e565ae
children e9cdb499350d
line wrap: on
line diff
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java	Thu Sep 08 11:27:21 2011 +0400
+++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java	Thu Sep 08 12:56:56 2011 +0400
@@ -119,13 +119,6 @@
     }
   }
 
-  private Collection<ModifiedFile> computeModifiedFilesForMergeCommit(final Settings settings, final ChangeSet cur) throws VcsException {
-    File workingDir = getWorkingDir(settings);
-    ChangedFilesCommand cfc = new ChangedFilesCommand(settings, workingDir);
-    cfc.setRevId(cur.getId());
-    return cfc.execute();
-  }
-
   private List<VcsChange> toVcsChanges(final List<ModifiedFile> modifiedFiles, String prevVer, String curVer, CheckoutRules rules) {
     List<VcsChange> files = new ArrayList<VcsChange>();
     for (ModifiedFile mf: modifiedFiles) {
@@ -518,7 +511,7 @@
     if (mergeBase == null)
       return null;
 
-    LogCommand lc = new LogCommand(settings, getWorkingDir(settings));
+    LogCommand lc = myCommandFactory.createLog(settings, getWorkingDir(settings));
     lc.setFromRevId(new ChangeSetRevision(mergeBase).getId());
     lc.setToRevId(new ChangeSetRevision(branchVersion).getId());
     lc.showCommitsFromAllBranches();
@@ -561,7 +554,7 @@
 
   @NotNull
   private String getMinusNthCommit(@NotNull Settings settings, int n) throws VcsException {
-    LogCommand log = new LogCommand(settings, getWorkingDir(settings));
+    LogCommand log = myCommandFactory.createLog(settings, getWorkingDir(settings));
     log.setFromRevId(settings.getBranchName());
     if (n > 0)
       log.setLimit(n);
@@ -581,10 +574,11 @@
 
     // first obtain changes between specified versions
     List<ModificationData> result = new ArrayList<ModificationData>();
-    if (currentVersion == null) return result;
+    if (currentVersion == null)
+      return result;
 
     File workingDir = getWorkingDir(settings);
-    LogCommand lc = new LogCommand(settings, workingDir);
+    LogCommand lc = myCommandFactory.createLog(settings, workingDir);
     String fromId = new ChangeSetRevision(fromVersion).getId();
     lc.setFromRevId(fromId);
     lc.setToRevId(new ChangeSetRevision(currentVersion).getId());
@@ -593,32 +587,20 @@
       return result;
     }
 
-    // invoke status command for each changeset and determine what files were modified in these changesets
-    StatusCommand st = new StatusCommand(settings, workingDir);
     ChangeSet prev = new ChangeSet(fromVersion);
     for (ChangeSet cur : changeSets) {
-      if (cur.getId().equals(fromId)) continue; // skip already reported changeset
+      if (cur.getId().equals(fromId))
+        continue; // skip already reported changeset
 
       List<ChangeSetRevision> curParents = cur.getParents();
       boolean mergeCommit = curParents.size() > 1;
-      List<ModifiedFile> modifiedFiles = new ArrayList<ModifiedFile>();
-      if (mergeCommit) {
-        modifiedFiles.addAll(computeModifiedFilesForMergeCommit(settings, cur));
-      } else {
-        if (!curParents.isEmpty())
-          st.setFromRevId(curParents.get(0).getId());
-        st.setToRevId(cur.getId());
-        modifiedFiles.addAll(st.execute());
-      }
-
-      // changeset full version will be set into VcsChange structure and
-      // stored in database (note that getContent method will be invoked with this version)
+      List<ModifiedFile> modifiedFiles = cur.getModifiedFiles();
       List<VcsChange> files = toVcsChanges(modifiedFiles, prev.getFullVersion(), cur.getFullVersion(), checkoutRules);
-      if (files.isEmpty() && !mergeCommit) continue;
+      if (files.isEmpty() && !mergeCommit)
+        continue;
       ModificationData md = new ModificationData(cur.getTimestamp(), files, cur.getDescription(), cur.getUser(), root, cur.getFullVersion(), cur.getId());
-      if (mergeCommit) {
+      if (mergeCommit)
         md.setCanBeIgnored(false);
-      }
       result.add(md);
       prev = cur;
     }