Mercurial > hg > mercurial
changeset 59:30cc10fe9479
accept version in two formats: with rev number and without
author | Pavel.Sher |
---|---|
date | Sun, 26 Oct 2008 16:50:12 +0300 |
parents | d1ed856e38ea |
children | ba1dadfd81bf |
files | mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/ChangeSet.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/TipCommand.java mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java |
diffstat | 3 files changed, 12 insertions(+), 60 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/ChangeSet.java Sun Oct 26 16:34:32 2008 +0300 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/ChangeSet.java Sun Oct 26 16:50:12 2008 +0300 @@ -35,14 +35,19 @@ } /** - * Constructor for version in the form revnum:changeset_id + * Constructor for version in the form revnum:changeset_id or just changeset_id (in this case rev number is set to -1) * @param fullVersion full changeset version as reported by hg log command */ public ChangeSet(@NotNull final String fullVersion) { try { - String[] parts = fullVersion.split(":"); - myRevNumber = Integer.parseInt(parts[0]); - myId = parts[1]; + int colon = fullVersion.indexOf(":"); + if (colon != -1) { + myRevNumber = Integer.parseInt(fullVersion.substring(0, colon)); + myId = fullVersion.substring(colon+1); + } else { + myRevNumber = -1; + myId = fullVersion; + } } catch (Throwable e) { throw new IllegalArgumentException(e); }
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/TipCommand.java Sun Oct 26 16:34:32 2008 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* - * Copyright 2000-2007 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package jetbrains.buildServer.buildTriggers.vcs.mercurial.command; - -import com.intellij.execution.configurations.GeneralCommandLine; -import jetbrains.buildServer.ExecResult; -import jetbrains.buildServer.vcs.VcsException; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -/** - * @author Pavel.Sher - * Date: 14.07.2008 - */ -public class TipCommand extends BaseCommand { - public TipCommand(@NotNull final Settings settings) { - super(settings); - } - - @NotNull - public ChangeSet execute() throws VcsException { - GeneralCommandLine cli = createCommandLine(); - cli.addParameter("tip"); - ExecResult res = runCommand(cli); - List<ChangeSet> changeSets = LogCommand.parseChangeSets(res.getStdout()); - if (changeSets.isEmpty()) { - CommandUtil.commandFailed("hg tip", res); - } - - return changeSets.get(0); - } -}
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java Sun Oct 26 16:34:32 2008 +0300 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java Sun Oct 26 16:50:12 2008 +0300 @@ -110,7 +110,7 @@ // stored in database (note that getContent method will be invoked with this version) List<VcsChange> files = toVcsChanges(modifiedFiles, prev.getFullVersion(), cur.getFullVersion(), includeRule); if (files.isEmpty()) continue; - ModificationData md = new ModificationData(cur.getTimestamp(), files, cur.getSummary(), cur.getUser(), root, cur.getFullVersion(), extractRevisionId(cur.getFullVersion())); + ModificationData md = new ModificationData(cur.getTimestamp(), files, cur.getSummary(), cur.getUser(), root, cur.getFullVersion(), cur.getId()); result.add(md); prev = cur; } @@ -158,8 +158,7 @@ syncClonedRepository(vcsRoot); Settings settings = createSettings(vcsRoot); CatCommand cc = new CatCommand(settings); - ChangeSet cs = new ChangeSet(version); - cc.setRevId(cs.getId()); + cc.setRevId(new ChangeSet(version).getId()); File parentDir = cc.execute(Collections.singletonList(filePath)); try { File file = new File(parentDir, filePath); @@ -255,13 +254,7 @@ } public String getVersionDisplayName(final String version, final VcsRoot root) throws VcsException { - return extractRevisionId(version); - } - - private String extractRevisionId(final String version) { - int colon = version.indexOf(':'); - if (colon == -1) return version; - return version.substring(colon+1); + return new ChangeSet(version).getId(); } @NotNull