Creating a new repository in Subversion

For no other reason than ‘I can never remember’, this entry is being created. Most of my projects are ongoing, and rarely do I find the need to create new repositories. So when the time comes to run svnadmin create, I often find myself pondering the correct logistics of the svn import commmand.

This entry will assume you have a working subversion on your server. If you are on Ensim and you do NOT have subversion working on your server, then look no further than this article I wrote.

Now, let’s get going:

1 - Create the tree for the repository:
cd /tmp
mkdir myproject
cd myproject
mkdir trunk
mkdir branches
mkdir tags
cd trunk
cp -R /path/to/my/project ./
cd ../../

2 - Create the new repository which, for the purposes of this entry, we will call ‘myproject’. I am using the same naming convention that I used when I set up subversion. The path to my repos is where my subversion repos are officially kept according the apache configs I set up in this article.

svnadmin create /home/virtual/domainname/home/svn/repos/myproject

3 - Import the repos:

svn import /tmp/myproject file:///home/virtual/domainname/home/svn/repos/myproject -m “initial import”

You should see the following zip by on your screen:

Adding /tmp/project/branches
Adding /tmp/project/tags
Adding /tmp/project/trunk
Adding /tmp/project/trunk/.... your files here
.
.
.
#

Assuming it all went well, don’t forget to modify your svn-auth-file and svn-access-file.

Replace DB content on the fly

This appears to be a little known fact, so it has earned the right to be posted as a how-to on my site.

If you have a database with lots of content and you discover to your dismay that you have made a mistake on some of the text, in many rows, you might find yourself asking “How am I going to fix all those errors?”

For example, you have a table with 5000 rows and one column is a URI. You have entered the URI in this database as http://www.mystartupcompany.com/index.php?id=4001, http://www.mystartupcompany.com/index.php?id=4006, http://www.mystartupcompany.com/index.php?id=4009 and so on.

Now you discover that you can have the URI’s in a search engine friendly format that looks like this: http://www.mystartupcompany.com/product/4001, http://www.mystartupcompany.com/product/4006, http://www.mystartupcompany.com/product/4009 and so on.

Can you imagine having to go through the database one by one and correct all 5000 URI’s?

Relax, there is a simple and fast way to do it.

We will assume for arguments sake, that the table name is products, and the column name to modify is prod_uri.

Simply run this command:
UPDATE products SET prod_uri=REPLACE(prod_uri,‘mystartupcompany.com/index.php?id=’,‘mystartupcompany.com/product/’);

Note that the above code is all on one line.

Within a second or two, all the columns and rows will be updated.

Many thanks to Rob over at MacOSXHints for bringing this to my attention.

Page 19 of 19 pages ‹ First  < 17 18 19