Tag: svn

Apache Subversion header

Update Subversion commit authors

This week I faced the need to edit commit authors. Thanks to the new LDAP authentication, I need to change the way users log on the server. The side effect is the manually declared users differ from the LDAP user names. To keep consistent, I updated the previous commit authors with their new LDAP names. For those who have the same need, I share my script below:

#
# Subject: Bash script to update commit authors.
# Author: Bruce BUJON (bruce.bujon@gmail.com)
# Description: This script use a dictionary (AUTHORS) to replace a Subversion repository commit authors.
# Usage: Edit REPOSITORY_PATH and AUTHORS variables then run the script.
#

# The repository path
REPOSITORY_PATH="http://my-repository-url/"
# Get the repository head revision
HEAD=`svn info $REPOSITORY_PATH | grep Revision: | cut -c11-`
# The authors (keys are original authors, values are replaced authors)
declare -A AUTHORS
AUTHORS=( ["olduser1"]="newuser1" ["olduser2"]="newuser2")

# Process each revision up to head
for revision in $(seq 1 $HEAD)
do
  echo -n "Processing revision $revision: "
  # Get revision author
  author=`svn propget --revprop svn:author -r $revision $REPOSITORY_PATH`
  # Check if replacement author is available
  newauthor=${AUTHORS[$author]}
  if [[ ! -z "$newauthor" ]]; then
    # Update commit author
    output=$(svn propset --revprop svn:author $newauthor -r $revision $REPOSITORY_PATH 2>&1)
    result=$?
    # Check update status
    if [ $result != 0 ]; then
      # An error occurred
      echo "an error occurred!"
      echo $output
      exit -1
    else
      # Author replaced
      echo "author replaced ($author > $newauthor)."
    fi
  else
    # Author kept
    echo "author kept."
  fi
done
# End of script
echo "$HEAD revisions successfully proceed."

Note that you will the server allows revision property changes. To do that, ensure the pre-revprop-change hook return 0, at least the time of the maintenance. You don’t want your users editing the commit authors and logs to make you a joke.

Apache Subversion header

Svnbook in epub

If like me you use Play Book to store books and manuals, you will be sad to read the great Subversion book: svnbook. PDF format import fails to parse table of content and its navigation links. So I make the epub build of the book and everything works well now.

So for everyone who need it, I share the svnbook under the epub format:

svnbook
The Subversion book epub

Please note svnbook is maintained by svnbook.red-bean.com under open source licence.