Much ado about scripting, Linux & Eclipse: card subject to change

Showing posts with label log. Show all posts
Showing posts with label log. Show all posts

2011-10-29

HOWTO: See what happened in SVN between builds

I was recently asked how to determine what changed between two builds. Jenkins provides nice interlinks into JIRA (issues), Fisheye (source changes), SVN (sources), but let's say you want to kick things a little more old school and investigate the old way... or the builds you want to compare are no longer shown in Jenkins because they expired and their metadata was automatically purged.

If you can't just look at the changelog in Jenkins to see what revision of source was used for the build, you can check the SVN log to find revision numbers based on the timestamp of the build.

So, if your build was generated on 2011-10-18, you can see that the log shows the last commit before that build was this:

$ svn log http://svn.jboss.org/repos/jbosstools/branches/jbosstools-3.2.x/

...

r35735 | bfitzpat | 2011-10-17 15:35:23 -0400 (Mon, 17 Oct 2011) | 2 lines
Changed paths:
   A esb/plugins/.project
   M esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/ESBRuntimeResolver_410.java

JBDS-1889 - Now checking for juddi-client-3.1.2.jar as well as 3.1.0 and 3.1.1 when seeing if the runtime includes ESB 4.10

...

Want to see actual diffs between that build and the latest one?

$ svn diff http://svn.jboss.org/repos/jbosstools/branches/jbosstools-3.2.x/@35735 http://svn.jboss.org/repos/jbosstools/branches/jbosstools-3.2.x/

Or, if you want to collect just the section of log relevant to the change:

$ svn log -r35735:HEAD http://svn.jboss.org/repos/jbosstools/branches/jbosstools-3.2.x/

Of course if you have all the sources locally, you don't need to log or diff via a URL - you can simply use local file paths. And if like me you use git-svn instead of pure svn, you can use that to diff or log too.

If you want to easily determine when a branch was created and get the SVN revision number for that branch point, use this:

# from r28571, returns -r28571:HEAD
rev=$(svn log --stop-on-copy \
  http://svn.jboss.org/repos/jbosstools/branches/jbosstools-3.2.x \
  | egrep "r[0-9]+" | tail -1 | sed -e "s#\(r[0-9]\+\).\+#-\1:HEAD#")

If you'd like to view a specific svn revision in your browser, use !svn/bc/REVISION_NUMBER/ before the branch and path to file or folder:

http://svn.jboss.org/repos/jbosstools/!svn/bc/35735/branches/jbosstools-3.2.x/

2010-04-04

Cleaner Ant Build Logs: Get Rid of "Trying to override old definition of task"

If you use macros in Ant, you have probably seen clutter in your log such as

Trying to override old definition of task ...

Here's how to purge this garbage from your log and keep your build output cleaner.

  1. move your macros into a target such as <target name="init">
  2. have your main target(s) depend on the target that defines the macros
  3. call your macros

You can make your log even quieter with -q when running ant, eg., ant -f build.xml -q

Here's a complete example that will first self-bootstrap itself by downloading Ant-Contrib, define two ant macros, and produce very quiet output (unless debug=true):

<project default="run">
 <property name="COMMON_TOOLS" value="${java.io.tmpdir}" />
 <property name="debug" value="false"/>

 <target name="get.ant-contrib" unless="ant-contrib.jar.exists">
  <property name="ANTCONTRIB_MIRROR" value="http://downloads.sourceforge.net/ant-contrib/" />
  <get usetimestamp="true"
       dest="${COMMON_TOOLS}/ant-contrib-1.0b2-bin.zip"
       src="${ANTCONTRIB_MIRROR}/ant-contrib-1.0b2-bin.zip"
  />
  <touch file="${COMMON_TOOLS}/ant-contrib-1.0b2-bin.zip" />
  <mkdir dir="${java.io.tmpdir}/ant-contrib-1.0b2-bin.zip_" />
  <unzip src="${COMMON_TOOLS}/ant-contrib-1.0b2-bin.zip"
         dest="${java.io.tmpdir}/ant-contrib-1.0b2-bin.zip_"
         overwrite="true"
  />
  <copy file="${java.io.tmpdir}/ant-contrib-1.0b2-bin.zip_/ant-contrib/lib/ant-contrib.jar"
        tofile="${COMMON_TOOLS}/ant-contrib.jar"
        failonerror="true"
  />
  <delete dir="${java.io.tmpdir}/ant-contrib-1.0b2-bin.zip_" includeemptydirs="true" quiet="true" />
 </target>

 <target name="init">
  <available file="${COMMON_TOOLS}/ant-contrib.jar" type="file" property="ant-contrib.jar.exists" />
  <antcall target="get.ant-contrib" />

  <taskdef resource="net/sf/antcontrib/antlib.xml">
   <classpath>
    <pathelement location="${COMMON_TOOLS}/ant-contrib.jar" />
   </classpath>
  </taskdef>
  
  <macrodef name="debug">
   <text name="echo" />
   <sequential>
    <if>
     <and>
      <isset property="debug" />
      <istrue value="${debug}" />
     </and>
     <then>
      <echo message="@{echo}" />
     </then>
    </if>
   </sequential>
  </macrodef>

  <macrodef name="list.count">
   <attribute name="list" default="" />
   <sequential>
    <var name="count" value="" />
    <for param="listitem" list="@{list}" delimiter=", ">
     <sequential>
      <var name="count" value="${count}0" />
     </sequential>
    </for>
    <length property="list.count.return" string="${count}" />
   </sequential>
  </macrodef>
 </target>

 <target name="run" depends="init">
  <property name="list" value="foo bar baz"/>
  <list.count list="${list}" />
  <debug>For list [${list}], size = </debug>
  <echo>${list.count.return}</echo>
 </target>

</project>