0

I'm currently migrating repositories and have created some key variables to use in my Subversion commit, the most important of those are Commit message, and Date I am trying to commit with those variables as part of the svn ci operation, the message is fairly easy as I can use svn ci -m"$(LOGMSG)" for the message, but I have no idea how to explicitly add the DATE and AUTHOR fields to the commit, could someone help?

for (( r=$CURREV; r<$ENDREV+1; r++ ))
do

  git svn fetch -r $CURREV

  # move whitelists subversion folder
  find "$GIT_FOLDER" \
    -mindepth 1 \
    -maxdepth 1 \
    -regextype posix-egrep \
    -not -regex ".*/(${EXCLUDE_PATTERN})$" \
    -exec mv -t "$SVN_FOLDER" '{}' '+'

    # set opts for SVN logging
    CID=$(git log --format=oneline |awk '{print $1}')
    AUTHOR='Jd Daniel <jdaniel@erado.com>'
    DATE=$(git log --date=iso |grep 'Date' |awk -v N=2 '{sep=""; for (i=N; i<=NF; i++) {printf("%s%s",sep,$i); sep=OFS}; printf("\n")}')
    LOGMSG=$(git log --oneline |awk -v N=2 '{sep=""; for (i=N; i<=NF; i++) {printf("%s%s",sep,$i); sep=OFS}; printf("\n")}')


    # move to svn
    cd $SVN_FOLDER

    ADD=$(svn st |grep '?\|M' |awk '{printf "%s ", $2}'); [  -z "$ADD" ] || svn add $ADD
    REM=$(svn st |grep 'D\|!' |awk '{printf "%s ", $2}'); [  -z "$REM" ] || svn rm  $REM

    # do commit
    svn ci -m 'GIT ID: '$CID$'\n'$LOGMSG


  break # just on rev for now

done
Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
ehime
  • 8,025
  • 14
  • 51
  • 110
  • Try python svn bindings: http://stackoverflow.com/questions/1448894/subversion-python-bindings-documentation. One guy here somehow find a way to solve it with it: http://www.wandisco.com/svnforum/threads/38846-Change-svn-author-on-commit. And this script might give the concept: http://svn.apache.org/repos/asf/subversion/trunk/tools/examples/revplist.py – konsolebox Sep 03 '13 at 20:22

1 Answers1

1

You can change the author and date of an already committed revision with the command svn propset --revprop. The following two commands change the properties for the most recent revision:

svn propset --revprop -r HEAD svn:author "$AUTHOR"
svn propset --revprop -r HEAD svn:date "$DATE"

The date should be in the format YYYY-mm-ddTHH:MM:SS.MSZ. See the output of the following command for reference:

svn propget --revprop -r HEAD svn:date

Unfortunately, you have to change each property separately. The command svn commit has also an option for revision properties (--with-revprop). However, this option can not be used to override standard properties during commit.

The SVN repository must be configured to allow revision property changes. If it is not configured accordingly, you will get an error message. In this case you have to create or change the hook script hooks/pre-revprop-change in the SVN repository. Take a look at the template file hooks/pre-revprop-change.tmpl for more information.

nosid
  • 48,932
  • 13
  • 112
  • 139
  • Looks like it works, unfortunately Redmine is taking forever to update, but an `svn log` shows this to be working. Accepted and +1 for an awesome answer, thanks brother – ehime Sep 03 '13 at 19:43