Can I go back and edit comments on an SVN checkin?

SvnTortoisesvn

Svn Problem Overview


I put a mistake into a comment in SVN. Can I edit this after checkin?

Svn Solutions


Solution 1 - Svn

Commit messages are "unversioned properties" and can be changed with the svn propset command, for example

$ svn propset --revprop -r 25 svn:log "Journaled about trip to New York."
property 'svn:log' set on repository revision '25'

This is setting the revision property called "svn:log" on revision 25

Configuring subversion to allow revision property changes

Because these are unversioned, a default installation of subversion won't let you modify these properties unless you provide a pre-revprop-change hook script.

Here's a typical script, from /var/lib/svn/hooks/pre-revprop-change on my system:

#!/bin/sh

REPOS="$1"
REV="$2"
USER="$3"
PROPNAME="$4"
ACTION="$5"

if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:log" ]; then 
  echo "$1 $2 $3 $4 $5" >> /var/lib/svn/logchanges.log
  exit 0; 
fi

echo "Changing revision properties other than svn:log is prohibited" >&2
exit 1

This logs changes to svn:log revision properties, and allows the edit by using exit 0, any other revision property change is denied by using exit 1. See patmortech's answer for a Windows equivalent.

Solution 2 - Svn

To enable the revision property modification, you need to create a pre-revprop-change hook script. Can read about it here: http://svnbook.red-bean.com/en/1.0/ch05s02.html (look for Hook Scripts section).

For Windows, here's a link to an example batch file that only allows changes to the log message (not other properties): http://ayria.livejournal.com/33438.html. Basically copy the code below into a text file and name it pre-revprop-change.bat and save it in the /hooks subdirectory for your repository.

@ECHO OFF
:: Set all parameters. Even though most are not used, in case you want to add
:: changes that allow, for example, editing of the author or addition of log messages.
set repository=%1
set revision=%2
set userName=%3
set propertyName=%4
set action=%5

:: Only allow the log message to be changed, but not author, etc.
if /I not "%propertyName%" == "svn:log" goto ERROR_PROPNAME

:: Only allow modification of a log message, not addition or deletion.
if /I not "%action%" == "M" goto ERROR_ACTION

:: Make sure that the new svn:log message is not empty.
set bIsEmpty=true
for /f "tokens=*" %%g in ('find /V ""') do (
set bIsEmpty=false
)
if "%bIsEmpty%" == "true" goto ERROR_EMPTY

goto :eof

:ERROR_EMPTY
echo Empty svn:log messages are not allowed. >&2
goto ERROR_EXIT

:ERROR_PROPNAME
echo Only changes to svn:log messages are allowed. >&2
goto ERROR_EXIT

:ERROR_ACTION
echo Only modifications to svn:log revision properties are allowed. >&2
goto ERROR_EXIT

:ERROR_EXIT
exit /b 1

Solution 3 - Svn

A way to do a quick change to the log message without having to create a pre-revprop-change hook script is to use the following svnadmin command:

svnadmin setlog --bypass-hooks REPOS_PATH -r N FILE

where REPOS_PATH is the path to the repository on the server (e.g. /srv/svn/repository) and N is the revision number (e.g. 25) and FILE is a text file containing the correct commit log entry.

Two things: This requires filesystem access to the repository files, but so does creating a pre-revprop-change hook script... and secondly, this command will bypass any hook scripts that may be in place, so use advisedly...

Solution 4 - Svn

Using Tortoise SVN will make this very very easy for you. Simply bring up the log messages window, right click the revision log you would like to edit, and choose Edit Log from the context menu.

Solution 5 - Svn

In Tortoise SVN, you can follow the steps below.

  1. Go to Repository Browser.
  2. Right Click on the folder that you want to work on.
  3. Click Show Log.
  4. In the revision listing, select and right click on the revision that you want.
  5. Click Edit log message.

You can now edit your comments in the svn checkin revision.

Thanks!

Solution 6 - Svn

svn propset svn:log --revprop -r <REVISION> "My corrected log message" <PATH-TO-REPOSITORY> 

Solution 7 - Svn

In Eclipse (or Rational Application Developer) using Subclipse:

choose Team --> Show History then Right-click the revision whose comments you wish to change, then choose "Set Commit Properties" and you can change the comment and/or author.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionleoraView Question on Stackoverflow
Solution 1 - SvnPaul DixonView Answer on Stackoverflow
Solution 2 - SvnpatmortechView Answer on Stackoverflow
Solution 3 - SvnKit RoedView Answer on Stackoverflow
Solution 4 - SvnDanView Answer on Stackoverflow
Solution 5 - SvnAung Chan MyaeView Answer on Stackoverflow
Solution 6 - SvnDavid Snabel-CauntView Answer on Stackoverflow
Solution 7 - Svnuser244298View Answer on Stackoverflow