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
Share
divider

Responses to BASH – Extracting Subversion Log

  1. Have you ever considered about adding a little bit more than just your articles? I mean, what you say is important and everything. But think of if you added some great pictures or video clips to give your posts more, “pop”! Your content is excellent but with images and clips, this website could definitely be one of the most beneficial in its niche. Good blog!



Leave a Reply

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 with your comments &/or thoughts!
Looking for MS Thesis or PhD Dissertation Template in LaTeX? Click below!

MTU Create The Future
Twitter



Archives

Planet Kannada


Twitter: @sgowtham Facebook: @sgowtham Linked In: sgowtham