[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Catching dangling transactions

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: 2003-10-12 01:47:27 CEST

Occasionally I discover transactions hanging around in my private repository, and wonder how they got there. In a suitably controlled environment, it would be nice if the Subversion command-line client would check, after completing its task, that no transactions are left hanging around in the database. I suppose one of the main causes is the client exiting unexpectedly, so only a wrapper could really do this. And of course it would only work for a local repository, and only if it can know which repository is being accessed. And only when there is no concurrent access. Etc.

The script below does the job crudely. It is a wrapper for "svn", and prints a message afterwards if there are dangling transactions in any local repositories that it thinks might have been accessed. Here it shows that a second attempt at an obstructed update leaves a dangling transaction:

~/tmp/svn-sandbox> svn up
At revision 36.
[No dangling transactions in '/home/julianfoad/vcs/sandbox']

~/tmp/svn-sandbox> svn up -r33
UU f
/home/julianfoad/src/subversion/subversion/libsvn_wc/update_editor.c:798: (apr_err=155000)
svn: Obstructed update
svn: failed to delete file 'eol-test': file has local modifications.
[No dangling transactions in '/home/julianfoad/vcs/sandbox']

~/tmp/svn-sandbox> svn up -r33
/home/julianfoad/src/subversion/subversion/libsvn_wc/update_editor.c:798: (apr_err=155000)
svn: Obstructed update
svn: failed to delete file 'eol-test': file has local modifications.
### Dangling transactions in '/home/julianfoad/vcs/sandbox': 5c

I don't know if there is a better way of detecting these bugs; this is certainly inelegant. It could be much cleaner and more accurate if Subversion itself somehow told it which repository had been accessed, but already it it very interesting to me.

- Julian

~/bin/svn:
[[[
#!/bin/bash
# Run the Subversion command-line client and then, knowing that this is a
# controlled test environment with no concurrent access, check that no
# dangling transactions have been left in the repositories.

SVN=~/build/subversion/subversion/clients/cmdline/svn
$SVN "$@"

# If it was a non-repository-contacting subcommand, don't check further.
#SUBCMD=$1
#case $SUBCMD in ...

# We don't know which repositories were accessed, so guess from any WC args:
WCDIRS=
for ARG in $*; do
  if [ -d $ARG/.svn ]; then
    WCDIRS="$WCDIRS $ARG"
  elif [ -f $ARG ] && [ -d `dirname $ARG` ]; then
    WCDIRS="$WCDIRS `dirname $ARG`"
  fi
done
# If no arguments look like WCs, try implicit "."
if [ "$WCDIRS" == "" ] && [ -d .svn ]; then
  WCDIRS=.
fi

# Find any local (file://) repositories connected to those WCDIRS.
REPOSITORIES=
for WCDIR in $WCDIRS; do
  REPOS=`$SVN info $WCDIR | sed -e "s,^URL: file://,," -e "t" -e "d"`
  if [ "$REPOS" ]; then
    while ! [ -d "$REPOS/db" ]; do
      REPOS=`dirname "$REPOS"`
      if [ "$REPOS" == "." ] || [ "$REPOS" == "/" ]; then
        echo "$0: repository not found for WC '$WCDIR'"
      fi
    done
    REPOSITORIES="$REPOSITORIES $REPOS"
  fi
done

for REPOS in $REPOSITORIES; do
  # There should be no outstanding transactions listed.
  TXNS=`svnadmin lstxns $REPOS`

  if [ "$TXNS" ]; then
    echo "### Dangling transactions in '$REPOS':" $TXNS
# else
# echo "[No dangling transactions in '$REPOS']"
  fi
done
]]]

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Oct 12 01:46:49 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.