On Wed, Feb 2, 2011 at 22:00, Paul Koning <paul_kon...@dell.com> wrote:
> No.  Subversion specifically documents the fact that a pre-commit hook can't 
> change the transaction; it can only inspect it.
>
>        paul
>

Yes, here is a pilot post commit hook for bumping DATESTAMP:

 post-commit      |    2 ++
 update_datestamp |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+)

Index: hooks/update_datestamp
===================================================================
--- hooks/update_datestamp      (revision 0)
+++ hooks/update_datestamp      (revision 0)
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+REPOS="$1"
+REV="$2"
+
+PATH=/usr/local/bin:/usr/pkg/bin:/usr/bin:/bin
+IGNORE_BRANCHES='gcc-(2_95|3_0|3_1|3_2|3_3|3_4|4_0|4_1|4_2)-branch'
+
+# Run this from /tmp
+/bin/rm -rf /tmp/$$
+/bin/mkdir /tmp/$$
+cd /tmp/$$
+
+# Compute the branches which we should check for update.
+BRANCHES=`svnlook -r ${REV} dirs-changed "${REPOS}" \
+| grep -E "^trunk/|^branches/gcc-[0-9]+_[0-9]+-branch/" \
+| grep -E -v ${IGNORE_BRANCHES} \
+| awk -F '/' '{if ($1 == "trunk") { print $1} else { print $2}}' \
+| sort -u`
+
+# Assume all will go well.
+RESULT=0
+for BRANCH in ${BRANCHES}; do
+
+  # Compute the svn root URL we should check for update.
+  if test "${BRANCH}" = "trunk"; then
+    DATESTAMP_URL="file://${REPOS}/trunk/gcc"
+  else
+    DATESTAMP_URL="file://${REPOS}/branches/${BRANCH}/gcc"
+  fi
+
+  CURR_DATE=`/bin/date -u +"%Y%m%d"`
+  PREV_DATE=`svn cat "${DATESTAMP_URL}/DATESTAMP"`
+  if test "${CURR_DATE}" = "${PREV_DATE}"; then
+    continue
+  fi
+
+  svn -q co -N "${DATESTAMP_URL}/" gcc
+  echo -n ${CURR_DATE} > gcc/DATESTAMP
+  if ! svn commit -m "Daily bump." gcc/DATESTAMP; then
+    # If we could not commit the files, indicate failure.
+    RESULT=1
+  fi
+
+  # Remove the files.
+  rm -rf /tmp/$$/gcc
+done
+
+/bin/rm -rf /tmp/$$
+
+exit $RESULT

Property changes on: hooks/update_datestamp
___________________________________________________________________
Added: svn:executable
   + *

Index: hooks/post-commit
===================================================================
--- hooks/post-commit   (revision 169520)
+++ hooks/post-commit   (working copy)
@@ -17,3 +17,5 @@
    --repository "${REPOS}" --revision "${REV}" --background

 ${REPOS}/hooks/synchooks.sh "${REPOS}" "${REV}"
+
+${REPOS}/hooks/update_version_svn ${REPOS} ${REV} &

--
Dongsheng Song

Reply via email to