Mercurial > hg > mercurial
diff mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java @ 285:aeaf4d594967 Eluru-6.0.x
Use customized xml output from the 'hg log' command
Do that to parse commit messages correctly (TW-18036). Also 'hg log'
can provide information on changed files, so we will not run a 'hg
status' for every found cset, that should improve changes collecting
performance.
Use custom xml format mainly because of the difference in the author
output. Default xml splits the author to the person and the email,
while default verbose log uses unsplitted author. It is not clear how
to make original author from the person and the email, because
author|person is not empty even if there is no person in the
ui.username config. Also default xml uses date format rfc3339date,
which is harder to parse.
root: /home/nd/sandbox/hg-plugin/original/ HG: branch: Eluru-6.0.x HG:
committing mercurial-common/mercurial-common.iml
mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/ChangeSet.java
mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandUtil.java
mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommand.java
mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java
mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java
mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommandTest.java
mercurial.ipr mercurial.xml
mercurial-server/resources/buildServerResources/log.template HG: Press
C-c C-c when you are done editing.
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Mon, 29 Aug 2011 17:31:31 +0400 |
parents | 20817ebd1a05 |
children | 41529b72c059 |
line wrap: on
line diff
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java Mon Aug 29 11:41:03 2011 +0400 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java Mon Aug 29 17:31:31 2011 +0400 @@ -54,14 +54,18 @@ * <p>Personal builds (remote runs) are not yet supported, they require corresponding functionality from the IDE. */ public class MercurialVcsSupport extends ServerVcsSupport implements LabelingSupport, VcsFileContentProvider { + + private final String LOG_TEMPLATE_NAME = "log.template"; private ConcurrentMap<String, Lock> myWorkDirLocks= new ConcurrentHashMap<String, Lock>(); private VcsManager myVcsManager; private File myDefaultWorkFolderParent; + private File myLogTemplate; public MercurialVcsSupport(@NotNull final VcsManager vcsManager, @NotNull ServerPaths paths, @NotNull final SBuildServer server, - @NotNull EventDispatcher<BuildServerListener> dispatcher) { + @NotNull EventDispatcher<BuildServerListener> dispatcher) throws Exception { + myLogTemplate = createLogTemplate(paths.getPluginDataDirectory()); myVcsManager = vcsManager; myDefaultWorkFolderParent = new File(paths.getCachesDir(), "mercurial"); dispatcher.addListener(new BuildServerAdapter() { @@ -96,10 +100,12 @@ }); } - private Collection<ModifiedFile> computeModifiedFilesForMergeCommit(final Settings settings, final ChangeSet cur) throws VcsException { - ChangedFilesCommand cfc = new ChangedFilesCommand(settings); - cfc.setRevId(cur.getId()); - return cfc.execute(); + private File createLogTemplate(@NotNull final File templateFileDir) throws IOException { + File template = new File(templateFileDir, LOG_TEMPLATE_NAME); + if (!template.exists()) { + FileUtil.copyResource(MercurialVcsSupport.class, "/buildServerResources/log.template", template); + } + return template; } private List<VcsChange> toVcsChanges(final List<ModifiedFile> modifiedFiles, String prevVer, String curVer, final IncludeRule includeRule) { @@ -469,12 +475,12 @@ public List<ModificationData> collectChanges(@NotNull final IncludeRule includeRule) throws VcsException { syncClonedRepository(root); - // first obtain changes between specified versions List<ModificationData> result = new ArrayList<ModificationData>(); - if (currentVersion == null) return result; + if (currentVersion == null) + return result; Settings settings = createSettings(root); - LogCommand lc = new LogCommand(settings); + LogCommand lc = new LogCommand(settings, myLogTemplate); String fromId = new ChangeSetRevision(fromVersion).getId(); lc.setFromRevId(fromId); lc.setToRevId(new ChangeSetRevision(currentVersion).getId()); @@ -483,36 +489,19 @@ return result; } - // invoke status command for each changeset and determine what files were modified in these changesets - StatusCommand st = new StatusCommand(settings); ChangeSet prev = new ChangeSet(fromVersion); for (ChangeSet cur : changeSets) { - if (cur.getId().equals(fromId)) continue; // skip already reported changeset - - String prevId = prev.getId(); - List<ChangeSetRevision> curParents = cur.getParents(); - boolean merge = curParents != null && curParents.size() > 1; - if (curParents != null && !merge) { - prevId = curParents.get(0).getId(); - } + if (cur.getId().equals(fromId)) + continue; // skip already reported changeset - List<ModifiedFile> modifiedFiles = new ArrayList<ModifiedFile>(); - if (merge) { - modifiedFiles.addAll(computeModifiedFilesForMergeCommit(settings, cur)); - } else { - st.setFromRevId(prevId); - st.setToRevId(cur.getId()); - modifiedFiles = 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) + boolean merge = cur.getParents().size() > 1; + List<ModifiedFile> modifiedFiles = cur.getModifiedFiles(); List<VcsChange> files = toVcsChanges(modifiedFiles, prev.getFullVersion(), cur.getFullVersion(), includeRule); - if (files.isEmpty() && !merge) continue; + if (files.isEmpty() && !merge) + continue; ModificationData md = new ModificationData(cur.getTimestamp(), files, cur.getDescription(), cur.getUser(), root, cur.getFullVersion(), cur.getId()); - if (merge) { + if (merge) md.setCanBeIgnored(false); - } result.add(md); prev = cur; }