To deal with this type of DEV and PRODUCTION environment, I've written a perl script to help me with what would otherwise be manual work. I've given certain steps familiar names so I remember to run them in the correct order. I only have DEV under SVN. I create a PRODUCTION environment each time with this script. That way I don't have to worry about maintaining 2 branches of code.
I'm using SVN so I choose a new checkout directory (like /tmp/foobar) of my DEV code. It's not going to be there very long.
Optional step 0: diff database structures
mysqldump -d -u USER -pPASS mydotcom > production.sql
mysqldump -d -u USER -pPASS mydotcom_dev > development.sql
vim -d production.sql development.sql
Sometimes plugins will add tables, and this will show that. Otherwise I replay the changes made within tables (install a plugin) when it's not worth it to diff certain tables and copy SQL statements.
step 1 clean:
The script deletes all files in the current directory, do a fresh svn checkout of the DEV branch. This fresh checkout is going to be transformed into the PRODUCTION code and copied to its webroot.
step 2 make:
perl runs a vim search and replace of the database name in wpconfig.php. The search and replace is just as easily done in perl.
system('vim -c "%s/define(\'DB_NAME\', \'mydotcom_dev\'/define(\'DB_NAME\', \'mydotcom\'/g | w | q" wp-config.php');
Remove local file uploads directory (so we don't overwrite the PRODUCTION one). wpcontent/uploads I believe it is on a standard install.
Another find and replace on all text files within the project that have my DEV url, for example
vim -c "%s/dev\.mydot\.com/www.mydot.com/g | w | q FILENAME.php
step 3 install.
Backup the wpcontent/uploads with dircopy() to be safe. Do a dircopy() of this cleaned up directory to the PRODUCTION webroot. Remove all .svn directories within the webroot like so:
find /PRODUCTION/WEBROOT -ignore_readdir_race -name .svn -exec rm -fr {} \; >/dev/null 2>&1
Now your DEV code has been transformed into your PRODUCTION code replacing all hardcoded URLs and keeping safe around the uploads directory that is not in SVN. You can even have it stop and start apache for you too. I hope my solution helps solves your problem.