Though many teams are using Subversion (SVN) to work together and share code, version control software provides a huge number of features that are not often used. Just about any developer these days knows how to checkout a project and commit or revert changes. But a lot of teams don’t really use more advanced features like branching and tagging to organize releases.
The great thing about version control systems like SVN is that you gain a bunch of really useful functionality – even if you have only been using it for sharing code. One of those features is the ability to create an export of all modified files since the previous release. A common scenario is when the team is working on a web application and it’s time to deploy all the recent changes to the production server. An app that is distributed would normally use tags or branches to keep the versions straight. But some teams prefer to just keep moving forward on the HEAD revision and never look back. If this sounds like you, luckily SVN provides an easy way to get all changed files since your last deployment and package them up with just a few clicks.
Lets say that you last deployed your application from repository version #85. After a few weeks of development, the repository is now up to revision #178. The team has decided that the code is stable and you are ready to package up all new/changed files to transfer to the host server, client, etc.
- Using TortoiseSVN, right-click on your working folder and select “Show Log” from the TortoiseSVN menu.
- Click the revision that was last published (#85 in this example)
- Ctrl+Click the HEAD revision (or whatever revision you want to release ie #178) so that both the old and the new revisions are highlighted.
- Right-click on either of the highlighted revisions and select “Compare revisions.” This will open a dialog window that lists all new/modified files.
- Select all files from this list (Ctrl+a) then right-click on the highlighted files and select “Export selection to…”
You’ll be prompted for a location to save your updated files and SVN will export them all with the directory structure preserved. You can then zip this up for your client, transfer it to your host or whatever you normally do to deploy the application.
Some teams prefer to actually do an update right on the production server and simply checkout the files that way. If your hosting setup permits and you don’t mind the “.svn” files in on your server, that is another easy option for deploying code.
For even more automation, this could all be done using batch, shell or ant build scripts such as svn-export-changes. If you know of another solution, please feel free to post it in the comments.