Setting up Tortoise SVN to apply a Patch
This article provides a step-by-step walkthrough on Tortoise SVN for users new to version control, with particular focus on setting up a local repository so as to apply patch files. Other articles provide a discussion of subversion in general, or online repositories.
Download & install Tortoise SVN http://tortoisesvn.tigris.org
Create a repository
Make a new folder somewhere that will be your 'repository' This is a backup of every version of your code.
Right click on it, choose Tortoise SVN / Create Repository Here
Create a working copy
Find the folder that holds all your code, right click on it and choose SVN Checkout. This folder will contain your "working copy" Enter the path of the repository that you just created, and press OK. You will get a warning that this folder is not empty, but that's ok. You will then see the "svn update" window, but as there are no files in your repository, it will not update any files just now. Close this window.
Ignore intermediate files
Now, before we commit your code into the repository, we want to make sure that the intermediate files will not be included - these are made from your code files, and assembled into your mod's dlls, but they are big and unnecessary - they will just make the repository much bigger than it needs to be. These are placed into specific folders, so are easy to find, when you compile in debug mode (the default) it will make the following folders:
and when you compile in release mode, it makes these:
If you have never compiled in one of these modes, the folders for that mode won't be there. You should find each of these folders (if they exist), and for each one, right click on it, and choose Tortoise SVN / Add To Ignore List, and then click the folder name in the sub-menu that appears.
Ignore VS user files (optional)
You can also tell it to ignore the .ncb and .suo files in the src/game/server and src/game/client directories, using the same method. These are visual studio user settings, and will be named after the project files you use (eg server_hl2mp_2005.vsproj will have server_hl2mp_2005.ncb & server_hl2mp_2005.suo). If you're struggling at this point, don't worry about these; they'll just take up a bit of extra space.
Your first commit
Now its time to copy ("commit") your code to the repository. Go to the source folder (the one you checked-out into in step 3., right click it, and choose SVN Commit...
Make sure that every file is checked in the popup window, use the Select All checkbox to do this easily. You can enter a text message to describe what has changed since your last update if you wish (as this is the first commit, you could say "unmodified hl2mp code"). Push OK & wait for it to complete; this can take quite a while the first time.
Up and running!
You are now set up with version control! Every time you complete a feature in your coding, it is recommended that you do an SVN commit; at any time you can easily right click and choose Tortoise SVN / Revert to undo your changes since the last commit (on the whole project, or just one file)
If you are sharing your repository with other coders, be sure to SVN Update regularly. This will merge their changes with yours. You will also have to be sure to Update before Commiting your code, otherwise if they have made changes, your commit will fail.
Applying a patch file
You are now ready to apply the patch file. Right click your source folder (this is your 'working copy') and choose Tortoise SVN / Apply Patch. Browse to the patch file, and click OK.
The patch tool
The patch tool is very powerful, but once its loaded you should see a small popup panel listing all the files to be modified. Assuming your code matches the code for which the patch was created, you should be able to right click this popup window, and choose Patch All. Wait a few seconds, and thats it! If any files in this list turn red, then patching has failed, as the file does not match that which is expected. You can use the patch utility's 3-way merge facility to patch files if this occurs, but that requires manually looking through the code changes one at a time, and is tedious.