upgrading a svn repository and recovering

While trying to integrate Sonar with Subversion, I had a suspicion that it wasn’t working because of either the version of the repository or a failed upgrade in the past. So on a whim*, I ran the upgrade command:

-bash-4.1$ svnadmin upgrade svn
Repository lock acquired.
Please wait; upgrading the repository may take some time…

Upgrade completed.

svn is the directory with our repository on CodeRanch. This happened almost instantaneously so I figured it was on the latest and nothing happened. Well, something happened. The permissions changed on a few files in the svn directory. I got this message:

Some of selected resources were not committed.
svn: E204900: Commit failed (details follow):
svn: E204900: Can’t open file ‘/home/vhost1/svn.javaranch.com/svn/db/txn-current-lock’: Permission denied
svn: E175002: MKACTIVITY of ‘/svn/!svn/act/bc61d1cc-5501-0010-ba7e-45a47496be2e’: 500 Internal Server Error (https://svn.javaranch.com)

Uh oh. I was able to commit before I started. Long story short, I fixed it by iterating through the errors and wound up just having to run:

chmod g+w txn-current*
 chmod g+w txn-protorevs

I tested by pulling, committing, tagging and deleting a tag. Everything seems to work.

Disclaimer

* If you work at a company, please don’t upgrade things on a whim nor allow your staff to do. I would never do that at my real job. CodeRanch operates more like the wild, wild west. Which is appropriate given the name and the fact that everything is volunteer driven and the culture is one that allows for some risk. I was able to fix this in about 15 minutes so no harm done. But if you are being paid to do something or can’t tolerate the risk, be careful. Do things on a development server. Plan. Tell people. Then these unpleasant moments where you realize you’ve made it so nobody can commit don’t happen.

eclipse mars (4.5) and trouble connecting to subversion

Every year, I create a blog post about the latest version of Eclipse. While this post is about Eclipse Mars (4.5), it is not that post. This post is about my troubles connecting to Subversion using Eclipse. Which was unexpected as I’ve never had that problem before.

After installing Subversive, I restarted Eclipse. I then got prompted for installing a SVN Connector. I chose the first one (SVN Kit 1.7). I don’t know what happened; it didn’t work.

Unsuccessful attempts

I then went to the workspace preferences > team > svn and clicked add connectors to get the prompt again. I wanted to choose SVN Kit 1.8. Unfortunately I clicked Javahl by accident. Which of course didn’t work because it I don’t have SVN natively installed.

The error I got for Javahl was at least clear:

SVN: ‘0x00400104: Check HEAD Revision’ operation finished with error: Selected SVN connector library is not available or cannot be loaded.
If you selected native JavaHL connector, please check if binaries are available or install and select pure Java Subversion connector from the plug-in connectors update site.
If connectors already installed then you can change the selected one at: Window->Preferences->Team->SVN->SVN Connector.
Get log messages for ‘https://svn.javaranch.com/svn’ failed.
Selected SVN connector library is not available or cannot be loaded.
If you selected native JavaHL connector, please check if binaries are available or install and select pure Java Subversion connector from the plug-in connectors update site.
If connectors already installed then you can change the selected one at: Window->Preferences->Team->SVN->SVN Connector.

Selected SVN connector library is not available or cannot be loaded.
If you selected native JavaHL connector, please check if binaries are available or install and select pure Java Subversion connector from the plug-in connectors update site.
If connectors already installed then you can change the selected one at: Window->Preferences->Team->SVN->SVN Connector.

No problem. I’ll just go back there and click add connectors again. Nothing. Can’t get pop-up to show up. I unsuccessfully tried restarting. Then I decided to uninstall Subversive entirely and start over.

Uninstalling

I went to help > installation details > subversive and clicked all subversive one. I then uninstalled. This was unnecessary as the problem was a connector. I then did help > installation details > javahl and uninstalled. After re-starting Eclipse, I got the connectors pop-up back.

Third attempt?

The connectors pop-up came back. SVN Kit 1.7 failed again. I then tried SVN Kit 1.8 which gave me an error about there not being any connectors. I restarted yet again and was finally able to connect to SVN. I’m not sure why this worked. I suppose the lesson is to uninstall and keep rebooting until it works?

 

svn, global search/replace and recovery

I started with a nice simple problem: do a global search and replace on the image directory path to save bandwidth (by pointing to a caching server.)  I used this regular expression and then had two problems:

  1. This isn’t easy to read (which isn’t a huge deal since I only have to run it once.)
  2. The find and replace updated the hidden .svn directory too.  Which meant when I went to sync with SVN, it thought it was up to date and didn’t commit anything.
More on both these problems.
Problem 1 – Unreadable regexp

find $path/templates/default -type f | xargs perl -pi -e ‘s/\$\{contextPath\}\/templates\/default\/images/\$\{imagesServedFrom\}\/templates\/default\/images/g’

All right.  What does this do?
  1. Find all files in the templates/default directory or any subdirectories
  2. Do a search for ${contextPath}/templates/default/images and replace with ${imagesServedFrom}/templates/default/images
I’m sure there is a clearer way of writing this.  I didn’t bother once I had something working because I only have to run it once.  (Famous last words, I know.)
Problem 2 – Updating SVN

The bigger problem is that I made a bunch of other changes in my commit and didn’t notice that none of the template/default/image changes got committed.  Eclipse/SVN didn’t commit the changed files because the .svn directory’s base file was changed as well.

I solved this by disconnecting from SVN in Eclipse. (Team disconnect) and deleting the metadata when prompted.  I then reconnected to SVN, Eclipse saw the difference and I committed normally.

If I was doing this again, I’d update the find statement to exclude the .svn directories.