Seventh Sense Rambling about life's little things, in 7 ≡ 1 (mod 6) fashion



 «
  »


BASH – Extracting Subversion Log

Subversion

Subversion Subversion (SVN) is a version control system initiated in 2000 by CollabNet Inc. It is used to maintain current and historical versions of files such as source code, web pages, and documentation. Its goal is to be a mostly-compatible successor to the widely used Concurrent Versions System (CVS). Subversion is well-known in the open source community and is used on many open source projects.

Subversion was started in 2000 as an effort to write a free version control system which operated much like CVS but with fixed bugs and misfeatures in CVS. By 2001, Subversion was sufficiently developed to be capable of hosting its own source code. More information, including this above paragraphs, is here.


Why This Script?

Per SVN Book:

svnlook is a tool provided by Subversion for examining the various revisions and transactions in a repository. No part of this program attempts to change the repository—it’s a read-only tool. svnlook is typically used by the repository hooks for reporting the changes that are about to be committed (in the case of the pre-commit hook) or that were just committed (in the case of the post-commit hook) to the repository. A repository administrator may use this tool for diagnostic purposes.

This BASH script uses svnlook and extends its usage to produce an elegant display of log of a Subversion repository.


The Script

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#! /bin/bash
#
# BASH script to generate SVN repository log
# Refer to http://svnbook.red-bean.com/en/1.1/ch05s03.html for details
#
# Usage: svn_log.sh [REPO_PATH]
# First written: Thu, 28 Jan 2010 12:19:37 -0500
# Last modified: Thu, 28 Jan 2010 12:19:37 -0500
 
 
if [ $# != 1 ];
then
  echo
  echo "  ERROR : REPOSITORY PATH missing"
  echo "  Usage : svn_log.sh [REPO_PATH]"
  echo
  exit
else
  export REPO=$1
 
  # Determine the youngest/newest/latest revision number
  export REVISION=`svnlook youngest $REPO`
 
  echo "----------------------------------------------------------------------------------------------------------------"
  echo " Rev #  Date/Time                                    Message"
  echo "----------------------------------------------------------------------------------------------------------------"
 
  while [ $REVISION -ge 1 ];
  do
    # Extract all information about the given revision
    svnlook info $REPO -r $REVISION > /tmp/sg_svnlook.tmp
 
    # Pick out relevant information from the above
    export DATETIME=`cat /tmp/sg_svnlook.tmp | head -2 | tail -1`
    export MESSAGE=`cat /tmp/sg_svnlook.tmp | tail -1`
 
    # Print them to the screen
    printf "%6s %45s %s\n"  "$REVISION" "$DATETIME" "$MESSAGE"
 
    # Decrement the revision number by 1
    export REVISION=`expr $REVISION - 1`
  done
 
  echo "----------------------------------------------------------------------------------------------------------------"
fi




Comments are closed.



Most of these posts, especially the ones with any hint of technical jargon, are intended to be Note2Self. But if any of them float your boat, then feel free to sail along.

If you feel so generous, improve my journey by sharing your thoughts!

Michigan Tech MS/PhD LaTeX Template


  @sgowtham

"… there is no such thing as professional photographers … just different skill levels" Marissa Mayer, CEO, Yahoo http://t.co/R2zBxykDf5
2013.05.21 @ 11:39:30 am


RT @Nobelprize_org: Heinrich Rohrer, received 1986 #NobelPrize in #Physics for the scanning tunneling microscope, died age 80, interview ht…
2013.05.21 @ 10:47:03 am


Ragin' Rainbow Falls: http://t.co/OoTXcKrlWn #Michigan #Nature #BlackRiver
2013.05.21 @ 3:23:28 am


(Trout) Lily Pad: http://t.co/BMnG6N4zKt #Michigan #Nature
2013.05.21 @ 3:22:27 am


Furious Superior: http://t.co/3JGbJNQrib #Wisconsin #Nature #PostFloodMudStir
2013.05.21 @ 3:21:23 am