[Anthill-dev] Anthill OS patch: add-mercurial-repository-adapter
Jim Hague
jim.hague at acm.org
Mon Oct 29 05:45:54 CST 2007
# HG changeset patch
# User Jim Hague <jim.hague at icc-atcsolutions.com>
# Date 1193655841 0
# Node ID 0343b4614b64a11619eb34c79cd63ffc0c343be9
# Parent 6ff47cce62c822d52336f06e48d9dd5143bb1256
Add Mercurial repository adapter.
This adapter expects to be pointed to an existing Mercurial repository.
It will build within that repository and increment and check in the
build version and tag within the repository.
A clean build (the default) will delete all working files from the
repository and do an update to get clean working files.
diff -r 6ff47cce62c8 -r 0343b4614b64
source/main/java/com/urbancode/anthill/adapter/MercurialRepositoryAdapter.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++
b/source/main/java/com/urbancode/anthill/adapter/MercurialRepositoryAdapter.java
Mon Oct 29 11:04:01 2007 +0000
@@ -0,0 +1,598 @@
+/*
+ * MercurialRepositoryAdapter.java
+ */
+package com.urbancode.anthill.adapter;
+
+import org.apache.log4j.Logger;
+import com.urbancode.anthill.util.FileRemover;
+import com.urbancode.anthill.util.StreamPumper;
+import com.urbancode.anthill.BuildDefinition;
+import java.io.*;
+import java.net.URLDecoder;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Map;
+import java.util.HashMap;
+import com.urbancode.pagelet.*;
+import org.apache.regexp.*;
+
+
+/**
+ * <p>
+ * An implementation of <code>RepositoryAdapter</code> that interfaces with
+ * a command-line Mercurial client to work with a Mercurial repository.</p>
+ * <p>
+ * The following extra properties must be specified for this adapter in the
+ * .anthill file:
+ * <ul>
+ * <li>HG_DIR - absolute path to the directory containing the repository
+ * <li>HG_BRANCHNAME - the branch name on which Anthill should work
+ * <li>HG_USERNAME - the username Anthill should use
+ * </ul></p>
+ *
+ * @author Jim Hague <jim.hague at acm.org>
+ */
+public class MercurialRepositoryAdapter extends ProfileRepositoryAdapter {
+
+ //*************************************************************************
+ // CLASS
+ //*************************************************************************
+
+ // Create Log4j category instance for logging
+ static private Logger log =
+ Logger.getLogger(MercurialRepositoryAdapter.class.getName());
+ // Create Log4j category instance for logging
+ static private Logger streamLog =
+
Logger.getLogger(MercurialRepositoryAdapter.class.getName()+"Stream");
+
+ static public final String ADAPTER_SUFFIX = "mercurial";
+
+ static protected final String GET_REVISIONS_SINCE_PAGELET
= "getRevisionsSince.pgl";
+ static protected final String GET_HEADS_PAGELET = "getHeads.pgl";
+
+ // The various property keys
+ static public final String REPO_DIR_KEY = "repository.mercurial.dir";
+ static public final String BRANCHNAME_KEY
= "repository.mercurial.branchname";
+ static public final String USERNAME_KEY
= "repository.mercurial.anthill.username";
+
+ // The comment for build increment commits.
+ public static final String BUILD_INCREMENT_COMMENT = "Anthill: Increment
build number";
+
+ // The comment for tag commits.
+ public static final String TAG_COMMENT = "Anthill: Tag build";
+
+ // date format in build id.
+ public static SimpleDateFormat BUILD_DATE = new SimpleDateFormat();
+
+ private static final String NEW_LINE =
System.getProperty("line.separator");
+
+ //************************************************************************* //
Instance
+ //*************************************************************************
+
+ String anthillUserName;
+
+ /**
+ * Create a new MercurialRepositoryAdapter
+ */
+ public MercurialRepositoryAdapter() {
+ }
+
+ public String getAdapterSuffix() {
+ return ADAPTER_SUFFIX;
+ }
+
+ protected void calculateRepositoryProperties()
+ throws RepositoryException {
+ localProjectDirName = project.getProperties().getProperty(REPO_DIR_KEY);
+ branchName = project.getProperties().getProperty(BRANCHNAME_KEY);
+ anthillUserName = project.getProperties().getProperty(USERNAME_KEY);
+ }
+
+ /**
+ * Get the repository head revision. This checks for the existance
+ * of multiple heads and throws an exception if so.
+ *
+ * @param def info about the build.
+ * @return The repository heads as a ChangesetRevision.
+ */
+ String getHeadRev(BuildDefinition def)
+ throws RepositoryException {
+
+ log.debug("Getting heads of project: " + project.getProjectName());
+ Process p = null;
+ StreamPumper errorPumper = null;
+ int exitcode = 0;
+ List heads;
+
+ try {
+ Map tempMap = new HashMap();
+ tempMap.put("Adapter", this);
+ tempMap.put("Properties", project.getProperties());
+
+ Pagelet pagelet =
getPageletFactory().getPagelet(makeProfilePageletName(GET_HEADS_PAGELET));
+ if (pagelet != null) {
+ log.debug("Have getHeads pagelet.");
+ }
+ else {
+ log.debug("Pagelet is null in checkout!");
+ }
+ String commandString = pagelet.service(tempMap);
+ log.debug("Get heads command: " + commandString);
+ p = Runtime.getRuntime().exec(toArray(commandString));
+
+ // pump the error stream.
+ errorPumper = new StreamPumper(p.getErrorStream(), "getHeads",
+ System.err, true);
+ errorPumper.start();
+
+ // get and parse the input stream
+ heads = parseLogCommandResult(p.getInputStream(), false);
+
+ exitcode = p.waitFor();
+ }
+ catch (RepositoryException e) {
+ throw e;
+ }
+ catch (Exception e) {
+ throw new RepositoryException(
+ "hg heads failed: " + e.getMessage(),
+ e);
+ }
+ finally {
+ if (errorPumper != null) {
+ try {
+ errorPumper.join();
+ } catch (InterruptedException e) {
+ throw new RepositoryException(e);
+ }
+ }
+ }
+ // handle errors
+ if (exitcode != 0)
+ throw (new RepositoryException("hg heads failed. Exit code: " +
exitcode));
+
+ if ( heads.size() == 0 )
+ throw new RepositoryException("No head info - check branchname");
+ if ( heads.size() > 1 )
+ throw new RepositoryException("Multiple heads");
+
+ ChangesetRevision head = (ChangesetRevision) heads.get(0);
+ return head.changeId;
+ }
+
+ /**
+ * Check out the project.
+ * <p>
+ * First check the repo head. If there is more than one head,
+ * refuse to go any further. Otherwise request a checkout of
+ * the head.
+ *
+ * @param def info about the build.
+ * @return An id for the checked out source. The rev id plus the date.
+ */
+ public String getWorkingProjectCopyAndId(BuildDefinition def)
+ throws RepositoryException {
+ List heads;
+
+ String buildId = getHeadRev(def);
+
+ log.debug("Getting working copy of project: " +
project.getProjectName());
+ Process p = null;
+ StreamPumper errorPumper = null;
+ int exitcode = 0;
+ try {
+ Map tempMap = new HashMap();
+ tempMap.put("Adapter", this);
+ tempMap.put("Properties", project.getProperties());
+ tempMap.put("AtChange", getRevisionFromBuildId(buildId));
+ if (def.getVersionedBuildFlag()){
+ log.info("Retrieving project version " + def.getVersion());
+ tempMap.put("Version", def.getVersion().trim());
+ }
+
+ Pagelet pagelet =
getPageletFactory().getPagelet(makeProfilePageletName(WORKING_PROJECT_PAGELET));
+ if (pagelet != null) {
+ log.debug("Have checkout pagelet.");
+ }
+ else {
+ log.debug("Pagelet is null in checkout!");
+ }
+ String commandString = pagelet.service(tempMap);
+ log.debug("Checkout Command: " + commandString);
+ executeCommand(commandString, "checkout");
+ }
+ catch (RepositoryException e) {
+ throw e;
+ }
+ catch (Exception e) {
+ throw new RepositoryException(
+ "Checkout failed: " + e.getMessage(),
+ e);
+ }
+
+ // Wait for a second to ensure that any file change (i.e. the
+ // build number incrementing) doesn't happen in the same second
+ // as the file update. See Mercurial issue 618.
+ try {
+ Thread.currentThread().sleep(1000);
+ }
+ catch (InterruptedException ie) {
+ }
+
+ return buildId + " " + BUILD_DATE.format(new Date());
+ }
+
+ /**
+ * See if the adapter can call <code>getRevisionsSince()</code>
+ * without calling <code>getWorkingProjectCopyAndId()</code>
+ * first. In other words, can you check repository history
+ * without a checkout? Since we need to point to a local repo
+ * to work in, we can.
+ *
+ * @return <code>true</code> if a checkout required.
+ */
+ public boolean logRequiresCheckout() throws RepositoryException {
+ return false;
+ }
+
+ /**
+ * Returns a List of Revision objects detailing the changes that have
+ * been made since the specified change id.
+ *
+ * @param id the last change built.
+ * @return List.
+ */
+ public List getRevisionsSince(String id)
+ throws RepositoryException {
+ return getRevisionsBetween(id, null);
+ }
+
+ /**
+ * Returns a List of Revision objects detailing the changes that have
+ * been made after <code>fromId</code> up to and including
+ * <code>toId</code>.
+ * <p>
+ * It isn't particularly simple to get per-file change info out of
+ * Subversion and I'm not sure how much sense it makes to describe
+ * a changeset per-file. So invent ChangesetRevision instead.
+ *
+ * @param fromId start at the revision after this one.
+ * @param toId end at this revision.
+ * @return List.
+ */
+ public List getRevisionsBetween(String fromId, String toId)
+ throws RepositoryException {
+
+ Process p = null;
+ StreamPumper errorPumper = null;
+ int exitcode = 0;
+ List revisionList = new ArrayList();
+ try {
+ Map tempMap = new HashMap();
+ tempMap.put("Adapter", this);
+ tempMap.put("Properties", project.getProperties());
+
+ fromId = getRevisionFromBuildId(fromId);
+ toId = getRevisionFromBuildId(toId);
+
+ // We want from the change after the first one.
+ if ( fromId == null )
+ fromId = "0";
+
+ tempMap.put("FromChange", fromId);
+ tempMap.put("ToChange", toId);
+
+ Pagelet pagelet =
getPageletFactory().getPagelet(makeProfilePageletName(GET_REVISIONS_SINCE_PAGELET));
+ String commandString = pagelet.service(tempMap);
+ log.debug("Get revisions since command: " + commandString);
+ p = Runtime.getRuntime().exec(toArray(commandString));
+
+ // pump the error stream.
+ errorPumper = new
StreamPumper(p.getErrorStream(), "getRevisions",
+ System.err, true);
+ errorPumper.start();
+
+ // get and parse the input stream
+ InputStream input = p.getInputStream();
+ revisionList = parseLogCommandResult(input, true);
+
+ exitcode = p.waitFor();
+
+ }
+ catch (Exception e) {
+ log.error(e.getMessage() + " thrown in new catch");
+ e.printStackTrace();
+ throw new RepositoryException(e.getMessage());
+ }
+ finally {
+ if (errorPumper != null) {
+ try {
+ errorPumper.join();
+ } catch (InterruptedException e) {
+ throw new RepositoryException(e);
+ }
+ }
+ }
+
+ // handle errors
+ if (exitcode != 0) {
+ throw (new RepositoryException("hg log failed. Exit code: " +
exitcode));
+ }
+
+ // Remove any changes in the list that are either the fromId
+ // or which were due to the Anthill user.
+ for ( ListIterator li = revisionList.listIterator();
+ li.hasNext(); )
+ {
+ ChangesetRevision rev = (ChangesetRevision) li.next();
+
+ if ( rev.userName.compareTo(anthillUserName) == 0 )
+ li.remove();
+ else {
+ String localRevNo = getRevisionFromBuildId(rev.changeId);
+
+ if ( localRevNo.compareTo(fromId) == 0 )
+ li.remove();
+ }
+ }
+
+ return revisionList;
+ }
+
+ /**
+ * Parse the output of 'hg log' or 'hg heads'.
+ * <p>
+ * Build a new ChangesetRevision for
+ * each revision we find. When each ChangesetRevision is complete,
+ * add it to the list of revisions.
+ *
+ * @param in the input stream to read.
+ * @param isLog <code>true</code> if parsing output of 'hg log'.
+ * @return a list of <code>ChangesetRevision</code>s.
+ */
+ protected List parseLogCommandResult(InputStream in, boolean isLog)
+ throws IOException, RepositoryException {
+ final int PARSE_REV_START = 1;
+ final int PARSE_REV_FILELIST = 2;
+ final int PARSE_REV_COMMENT = 3;
+
+ BufferedReader br = new BufferedReader(new InputStreamReader(in));
+ ChangesetRevision rev = null;
+ String comment = null;
+ RE headerRE = null;
+ RE fileRE = null;
+ int parseState = PARSE_REV_START;
+ List revList = new ArrayList();
+
+ try
+ {
+ // Revision (rev and short node), branch (may be empty), user
+ // and timestamp (hgdate).
+ headerRE = new RE("^r([:digit:]+:[:xdigit:]+) \\| (.*) \\| (.+) \\|
([:digit:]+) -?[:digit:]+");
+
+ // Line with added/deleted/modified file names separated by
+ // '|'.
+ fileRE = new RE("(.*) \\| (.*) \\| (.*)");
+ }
+ catch (RESyntaxException rse)
+ {
+ log.error(rse);
+ throw new RepositoryException(rse);
+ }
+
+ for ( String line = br.readLine(); line != null; line = br.readLine() ){
+ boolean addChange = false;
+
+ switch (parseState)
+ {
+ case PARSE_REV_START:
+ // Just look out for lines matching the header.
+ if ( headerRE.match(line) )
+ {
+ String revId = headerRE.getParen(1);
+ String branch = headerRE.getParen(2);
+ String user = headerRE.getParen(3);
+ String unixtime = headerRE.getParen(4);
+
+ if ( branch.length() == 0 )
+ branch = "default";
+
+ // Ignore entries for branches other than the one we're
+ // interested in.
+ if ( branch.compareTo(branchName) == 0 )
+ {
+ long timems;
+
+ try
+ {
+ timems = Long.parseLong(unixtime) * 1000L;
+ }
+ catch (NumberFormatException nfe)
+ {
+ throw new RepositoryException(nfe);
+ }
+
+ Date date = new Date(timems);
+
+ rev = new ChangesetRevision(revId, user, date);
+
+ log.debug("RevID: " + revId);
+ log.debug("User: " + user);
+ log.debug("Date: " + rev.date);
+
+ if ( isLog )
+ parseState = PARSE_REV_FILELIST;
+ else
+ addChange = true;
+ }
+ }
+ break;
+
+ case PARSE_REV_FILELIST:
+ // Grab the file info lines. Note that this won't
+ // copy with filenames with space, but that's a
+ // Mercurial problem.
+ if (fileRE.match(line)) {
+ for ( int i = 1; i <= 3; i++ )
+ {
+ String flist = fileRE.getParen(i).trim();
+ if ( flist.length() == 0 )
+ continue;
+
+ String[] files = flist.split(":");
+
+ for ( int j = 0; j < files.length; j++ ) {
+ String fname =
URLDecoder.decode(files[j], "UTF-8");
+ Revision fileRevision = new Revision();
+ fileRevision.fileName = fname;
+
+ switch (i) {
+ case 1:
+ rev.addAddedFile(fileRevision);
+ break;
+ case 2:
+ rev.addDeletedFile(fileRevision);
+ break;
+ case 3:
+ rev.addModifiedFile(fileRevision);
+ break;
+ }
+ }
+ }
+
+ parseState = PARSE_REV_COMMENT;
+ }
+ break;
+
+ case PARSE_REV_COMMENT:
+ // There is one comment line, URLencoded.
+ comment = URLDecoder.decode(line, "UTF-8");
+ // End of revision info.
+ if ( rev != null )
+ addChange = true;
+ parseState = PARSE_REV_START;
+ break;
+ }
+
+ if ( addChange ) {
+ rev.comment = comment;
+ revList.add(rev);
+
+ comment = null;
+ rev = null;
+ }
+ }
+
+ return revList;
+ }
+
+ /**
+ * Mercurial doesn't at present have any pre-edit that needs
+ * doing as far as I can see.
+ *
+ * @param file file to prepare for editing
+ */
+ public void prepareFileForEdit(String file) throws RepositoryException {
+ }
+
+ /**
+ * Explain that the tag is a build number.
+ */
+ public String makeTagFromVersion(String version) {
+ return "build-" + version;
+ }
+
+ /**
+ * Labels all relevant project files with the provided tag.
+ * A Mercurial label/tag operation is simply a server-side copy of
+ * the project, but that means we must make sure we copy the project
+ * at the revision at which we built it.
+ *
+ * @param id The build id (i.e. repository revision) to tag
+ * @param tag The label to tag the files with
+ */
+ public void label(String id, String tag) throws RepositoryException {
+ if (tag == null || tag.length() == 0) {
+ throw (new RepositoryException("No label specified"));
+ }
+
+ tag = tag.replace(':', '_');
+
+ log.info("Tagging entire project with label: " + tag);
+
+ try {
+ Map tempMap = new HashMap();
+ tempMap.put("Properties", project.getProperties());
+ tempMap.put("Adapter", this);
+ tempMap.put("Tag", tag);
+ tempMap.put("BuildRevision", getRevisionFromBuildId(id));
+ Pagelet pagelet =
getPageletFactory().getPagelet(makeProfilePageletName(LABEL_PAGELET));
+ executeCommand(pagelet.service(tempMap), "Label");
+ }
+ catch (RepositoryException e) {
+ throw e;
+ }
+ catch (Exception e) {
+ throw new RepositoryException("Label failed: " + e.getMessage(),
e);
+ }
+ }
+
+ /**
+ * reverts changes made so far in this instance of the adapter.
+ * In other words, clears out the repository ready for a fresh
+ * checkout.
+ */
+ public void revert() throws RepositoryException {
+ // Delete everything in the repo except .hg.
+ try {
+ log.info("Cleaning up local files: ");
+ final File projdir = new File(getLocalProjectDirName());
+
+ FilenameFilter notHgDir = new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return !(dir.equals(projdir) &&
name.startsWith(".hg"));
+ }
+ };
+ File files[] = projdir.listFiles(notHgDir);
+ for ( int i = 0; i < files.length; i++ )
+ FileRemover.removeFile(files[i]);
+ }
+ catch (Exception e) {
+ throw new RepositoryException("revert failed", e);
+ }
+ }
+
+ /**
+ * The build ID is rev:node followed by the date of the
+ * build. From the ID extract the revision number. If the build ID
+ * is null or is corrupted and has no revision number, return
+ * <code>null</code>.
+ *
+ * @param id the build ID.
+ * @return a string with the revision from the build ID, or
+ * <code>null</code> if the build ID is not valid.
+ */
+ String getRevisionFromBuildId(String buildId)
+ {
+ if ( buildId == null )
+ return null;
+
+ // A revision is a positive number. So look for the first
+ // non-digit in the build id.
+ buildId = buildId.trim();
+ for ( int i = 0; i < buildId.length(); i++ )
+ if ( !Character.isDigit(buildId.charAt(i)) ) {
+ buildId = buildId.substring(0, i);
+ break;
+ }
+
+ if ( buildId.length() == 0 )
+ return null;
+ else
+ return buildId;
+ }
+}
diff -r 6ff47cce62c8 -r 0343b4614b64
source/main/profiles/Unix/unix_mercurial/anthill.style
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/source/main/profiles/Unix/unix_mercurial/anthill.style Mon Oct 29
11:04:01 2007 +0000
@@ -0,0 +1,8 @@
+header = 'r{rev}:{node|short} | {branches} | {author} | {date|hgdate}\n'
+changeset = '{file_adds} | {file_dels} | {files}\n{desc|urlescape}\n'
+file = '{file|urlescape}:'
+last_file = '{file|urlescape}'
+file_add = '{file_add|urlescape}:'
+last_file_add = '{file_add|urlescape}'
+file_del = '{file_del|urlescape}:'
+last_file_del = '{file_del|urlescape}'
diff -r 6ff47cce62c8 -r 0343b4614b64
source/main/profiles/Unix/unix_mercurial/getHeads.pgl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/source/main/profiles/Unix/unix_mercurial/getHeads.pgl Mon Oct 29
11:04:01 2007 +0000
@@ -0,0 +1,17 @@
+<%@ import="com.urbancode.anthill.ProjectProperties" %>
+<%@ import="com.urbancode.anthill.adapter.*" %>
+<%@ import="com.urbancode.anthill.Anthill" %>
+<%
+Anthill anthill = Anthill.getAnthill();
+
+ProjectProperties pp = (ProjectProperties)context.get("Properties");
+MercurialRepositoryAdapter ra =
(MercurialRepositoryAdapter)context.get("Adapter");
+
+String repoDir = pp.getProperty(MercurialRepositoryAdapter.REPO_DIR_KEY);
+String pageletDir = anthill.getAnthillRootDir().getAbsolutePath() +
+ File.separator + "conf" +
+ File.separator + "profiles"+ File.separator + "Unix" +
+ File.separator + "unix_mercurial" + File.separator;
+%>
+
+sh <%=pageletDir%>getHeads.sh --repository <%=repoDir%> --style
<%=pageletDir%>anthill.style
diff -r 6ff47cce62c8 -r 0343b4614b64
source/main/profiles/Unix/unix_mercurial/getHeads.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/source/main/profiles/Unix/unix_mercurial/getHeads.sh Mon Oct 29 11:04:01
2007 +0000
@@ -0,0 +1,4 @@
+#!/bin/bash
+echo "Executing: hg heads $@"
+hg heads "$@"
+
diff -r 6ff47cce62c8 -r 0343b4614b64
source/main/profiles/Unix/unix_mercurial/getRevisionsSince.pgl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/source/main/profiles/Unix/unix_mercurial/getRevisionsSince.pgl Mon Oct
29 11:04:01 2007 +0000
@@ -0,0 +1,28 @@
+<%@ import="com.urbancode.anthill.ProjectProperties" %>
+<%@ import="com.urbancode.anthill.adapter.*" %>
+<%@ import="com.urbancode.anthill.Anthill" %>
+<%
+Anthill anthill = Anthill.getAnthill();
+
+ProjectProperties pp = (ProjectProperties)context.get("Properties");
+MercurialRepositoryAdapter ra =
(MercurialRepositoryAdapter)context.get("Adapter");
+
+
+String fromChange = (String)context.get("FromChange");
+String toChange = (String)context.get("ToChange");
+String repoDir = pp.getProperty(MercurialRepositoryAdapter.REPO_DIR_KEY);
+String pageletDir = anthill.getAnthillRootDir().getAbsolutePath() +
+ File.separator + "conf" +
+ File.separator + "profiles"+ File.separator + "Unix" +
+ File.separator + "unix_mercurial" + File.separator;
+
+String revString = "-r " + fromChange + ":";
+
+if (toChange != null) {
+ revString += toChange;
+}
+
+// Currently --debug is necessary to get Mercurial to sort files into
+// added and deleted categories, rather than just lump them all into
modified.
+%>
+sh <%=pageletDir%>getRevisionsSince.sh --debug --repository
<%=repoDir%> --style <%=pageletDir%>anthill.style <%=revString%>
diff -r 6ff47cce62c8 -r 0343b4614b64
source/main/profiles/Unix/unix_mercurial/getRevisionsSince.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/source/main/profiles/Unix/unix_mercurial/getRevisionsSince.sh Mon Oct 29
11:04:01 2007 +0000
@@ -0,0 +1,4 @@
+#!/bin/bash
+echo "Executing: hg log $@"
+hg log "$@"
+
diff -r 6ff47cce62c8 -r 0343b4614b64
source/main/profiles/Unix/unix_mercurial/getWorkingProject.pgl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/source/main/profiles/Unix/unix_mercurial/getWorkingProject.pgl Mon Oct
29 11:04:01 2007 +0000
@@ -0,0 +1,27 @@
+<%@ import="com.urbancode.anthill.ProjectProperties" %>
+<%@ import="com.urbancode.anthill.adapter.*" %>
+<%@ import="com.urbancode.anthill.Anthill" %>
+<%
+Anthill anthill = Anthill.getAnthill();
+
+ProjectProperties pp = (ProjectProperties)context.get("Properties");
+ProfileRepositoryAdapter ra =
(ProfileRepositoryAdapter)context.get("Adapter");
+
+String atChange = (String)context.get("AtChange");
+String repoDir = pp.getProperty(MercurialRepositoryAdapter.REPO_DIR_KEY);
+String pageletDir = anthill.getAnthillRootDir().getAbsolutePath() +
+ File.separator + "conf" +
+ File.separator + "profiles"+ File.separator + "Unix" +
+ File.separator + "unix_mercurial" + File.separator;
+
+String version = (String)context.get("Version");
+
+String revString = "";
+
+if ( version != null && !version.trim().equals("") )
+ revString = "\"" + version + "\"";
+else if ( atChange != null )
+ revString = atChange;
+%>
+
+sh <%=pageletDir%>getWorkingProject.sh --repository <%=repoDir%> --clean
<%=revString%>
diff -r 6ff47cce62c8 -r 0343b4614b64
source/main/profiles/Unix/unix_mercurial/getWorkingProject.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/source/main/profiles/Unix/unix_mercurial/getWorkingProject.sh Mon Oct 29
11:04:01 2007 +0000
@@ -0,0 +1,4 @@
+#!/bin/sh
+echo "Executing: hg update $@"
+hg update "$@"
+
diff -r 6ff47cce62c8 -r 0343b4614b64
source/main/profiles/Unix/unix_mercurial/label.pgl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/source/main/profiles/Unix/unix_mercurial/label.pgl Mon Oct 29 11:04:01
2007 +0000
@@ -0,0 +1,22 @@
+<%@ import="com.urbancode.anthill.adapter.*" %>
+<%@ import="com.urbancode.anthill.ProjectProperties" %>
+<%@ import="com.urbancode.anthill.Anthill" %>
+<%
+Anthill anthill = Anthill.getAnthill();
+
+ProfileRepositoryAdapter ra =
(ProfileRepositoryAdapter)context.get("Adapter");
+ProjectProperties pp = (ProjectProperties)context.get("Properties");
+String tag = (String)context.get("Tag");
+String buildRevision = (String)context.get("BuildRevision");
+String user = pp.getProperty(MercurialRepositoryAdapter.USERNAME_KEY).trim();
+String repoDir = pp.getProperty(MercurialRepositoryAdapter.REPO_DIR_KEY);
+String pageletDir = anthill.getAnthillRootDir().getAbsolutePath() +
+ File.separator + "conf" +
+ File.separator + "profiles"+ File.separator + "Unix" +
+ File.separator + "unix_mercurial" + File.separator;
+
+String msg = "-m \"" + MercurialRepositoryAdapter.TAG_COMMENT + "\"";
+String useropt = "--user \"" + user + "\"";
+%>
+
+sh <%=pageletDir%>label.sh --repository <%=repoDir%> <%=useropt%> -r
<%=buildRevision%> <%=msg%> <%=tag%>
diff -r 6ff47cce62c8 -r 0343b4614b64
source/main/profiles/Unix/unix_mercurial/label.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/source/main/profiles/Unix/unix_mercurial/label.sh Mon Oct 29 11:04:01
2007 +0000
@@ -0,0 +1,3 @@
+#!/bin/bash
+echo "Executing: hg tag $@"
+hg tag "$@"
diff -r 6ff47cce62c8 -r 0343b4614b64
source/main/profiles/Unix/unix_mercurial/postEditPagelet.pgl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/source/main/profiles/Unix/unix_mercurial/postEditPagelet.pgl Mon Oct 29
11:04:01 2007 +0000
@@ -0,0 +1,22 @@
+<%@ import="com.urbancode.anthill.adapter.*" %>
+<%@ import="com.urbancode.anthill.ProjectProperties" %>
+<%@ import="com.urbancode.anthill.Anthill" %>
+<%
+Anthill anthill = Anthill.getAnthill();
+
+ProfileRepositoryAdapter ra =
(ProfileRepositoryAdapter)context.get("Adapter");
+ProjectProperties pp = (ProjectProperties)context.get("Properties");
+String postEditFile = (String)context.get("File");
+String user = pp.getProperty(MercurialRepositoryAdapter.USERNAME_KEY).trim();
+String repoDir = pp.getProperty(MercurialRepositoryAdapter.REPO_DIR_KEY);
+String pageletDir = anthill.getAnthillRootDir().getAbsolutePath() +
+ File.separator + "conf" +
+ File.separator + "profiles"+ File.separator + "Unix" +
+ File.separator + "unix_mercurial" + File.separator;
+
+postEditFile = repoDir + File.separator + postEditFile;
+
+String msg = "-m \"" + MercurialRepositoryAdapter.BUILD_INCREMENT_COMMENT
+ "\"";
+String useropt = "--user \"" + user + "\"";
+%>
+sh <%=pageletDir%>postEditPagelet.sh --repository <%=repoDir%> <%=useropt%>
<%=msg%> <%=postEditFile%>
diff -r 6ff47cce62c8 -r 0343b4614b64
source/main/profiles/Unix/unix_mercurial/postEditPagelet.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/source/main/profiles/Unix/unix_mercurial/postEditPagelet.sh Mon Oct 29
11:04:01 2007 +0000
@@ -0,0 +1,3 @@
+#!/bin/bash
+echo "Executing: hg commit $@"
+hg commit "$@"
--
Jim Hague - jim.hague at acm.org Never trust a computer you can't lift.
More information about the Anthill-dev
mailing list