Change a comment in an SVN log (or fixing a malformed SVN log file after changing a comment)

This post falls into the category of "self-reminders".

Several months back, I ran into an issue with a corrupt Subversion log entry while trying to update the comments in a log. I found this post then on what the problem was, and how to fix it:

svn: malformed file recovery

Back up for a minute... Why corrupt? How would that happen in the first place?

OK... let's say you post a comment when doing a commit, and you realize after committing that your comment was pertaining to the wrong fix, or you didn't make a comment and needed to, or did but you left something off. You can try to do this through your SVN GUI or maybe command line, but I've seen times where that change didn't work. You try to go into the repository manually, and you find where the logs are located, you find the revision and comment, change it, and... voila! Corrupt! You do a sanity check and discover that manual edit was the cause of the corruption. So, now what?

Let's take you through just that. Learn from my mistake!

Simply put, finding the revision comment in the log is easy enough to fix, assuming you have access to where the repository is stored (as opposed to access to the repository). Just go into your actual repository. You should find a "db" folder, then a revprops folder, and then a 0 folder and finally a file for the revision you want to change. On Windows, you should have something like this:

C:\{where my repositories are stored}\{repo name}\db\revprops\0\{revision number}

Assuming your comment hasn't been changed yet (it won't matter below), open that file, and you'll find the comment at line 12 that you want to change and change it.

Thought that was easy? Nope, not quite. Save the file, and then try to browse your repository log. You should now get a malformed file error message. If you had this before, you're probably snickering, as you're no farther ahead.

Now, go back to that revision number file that contains the log comment. See line 11? That should say V, then a space, and finally a number. That number is significant. That represents the number of characters in line 12. Count the number of characters on line 12 and replace the number on line 11. Save the file and try browsing the log again... problem fixed.

I thought this mental reminder would help others as much or more as it'll help me!

An SVN Server Commit Gotcha... Why can't I commit? Check case sensitivity!

My friend Dan Vega has become a blogging machine lately, and he keeps telling me that I need to blog some of the many pearls of wisdom I've collected. This one's bit me now twice, so it's time to blog it.

I have been doing a lot of work in recent months with Subversion, setting up two Subversion servers in different environments, both on Windows.

I ran into several issues setting up one of those servers. There is a TON of content I have on that - I could probably teach a course of setting up Subversion on a Windows server at this point... but I do suck at blogging, specifically finishing a blog post before it goes stale... so I'll keep my posts short and let out what I've learned as I have time (not often, including now!).

With that, here is my first Subversion blog post of what I think will be many to come... Even though you might set up Subversion on a Windows server, beware of case sensitivity. Yes, that's right... it's case sensitive.

In one of the installations I've recently completed, we're using the SVN server as a service rather than Apache. Why is the subject of a future blog entry, so let's keep that out of it for this one.

When you point to a repo that uses the SVN server and you have commit rights on the repository, make sure you use the correct URL and that includes case.

In other words, if your repository is called ProjectX, and you point to:

svn://www.yourrepo.com/projectX

You will have no trouble grabbing updates to your working copy, but when you commit, it will fail, and you'll get a notification like so:

8/23/2009 - 12:21:04 AM
Command              : Commit
Error                : Commit failed (details follow):
Error                : Authorization failed
Finished!            : 
1 kBytes transferred in 0 minute(s) and 13 second(s)

The correct URL would be:

svn://www.yourrepo.com/ProjectX

To change the URL, you have to relocate the working copy to the correct URL. Your Subversion client will object, warning that you may corrupt your working copy. Ignore the warnings, and proceed. Once you have relocated the working copy, you should have no trouble performing a commit to the Subversion repository.

A colleague of mine had this occur about a month and a half ago, just after that Subversion server was set up. Tonight... I had the same issue, though it took me a while to realize what I had my colleague change the first time. It was my first commit to this repository in some time, so I hadn't noticed my error until now.

If you are using Apache, you won't be able to update or commit, so it becomes pretty obvious when you first try to set up your working copy that you entered the wrong URL. The SVN server is a little more subtle, and it won't become obvious until you try to commit.

As they say, fool me once, shame on you... but I was fooled twice, and I should have remembered this one a lot sooner than I did tonight! :-) I hope this helps someone out there.