TortoiseSVN: A Windows Shell Extension
To install TortoiseSVN, just download it and run the installer for your selected platform. Both 32-bit and 64-bit options are available, and they can be run on the same machine. For now, just accept the default settings in the installer. The following sections assume that you’ve installed TortoiseSVN and created a repository and working copy. Even if you haven’t done any of that, the description should be detailed enough for you to follow along just by reading. But there’s nothing quite like doing it.
Right-clicking the file PaymentMachine.java produces an Explorer menu with a few new menu options (see Figure 2):
- SVN Update
- SVN Commit
Figure 2 New options provided by TortoiseSVN.
The first two menu options relate to the files in your working copy. The SVN Update option refreshes the files in your working copy; that is, you receive any changes made by other developers whose changes have been committed to the repository. The SVN Commit option allows you to write your working copy changes to the repository. The terms update and commit relate to reading from and writing to the repository, respectively. We’ll look at these options shortly.
The other menu option, TortoiseSVN, has quite a few interesting submenu options, as shown in Figure 3.
Figure 3 The TortoiseSVN submenu options.
For a complete description of all the options on Figure 3, consult the TortoiseSVN documentation. We’ll see just a couple of the options in action here.
Creating a Graph of Revisions and Commits
The Show Log option creates a "graph" of revisions and commits. If I select PaymentMachine.java and then choose TortoiseSVN > Show log from the pop-up menu, I get the log window shown in Figure 4.
Figure 4 The message log.
Figure 4 shows a single entry that reflects the initial import into the repository of the selected Java file. However, the data in the log provides a lot of power to a Subversion repository manager. Very often, you can use the data to determine who has broken a build! I’ve used it for this purpose more than once, precisely because it provides author, date, and time information.
The repository is now stable in the sense that all changes have been committed. Let’s change a file in the working copy and see what TortoiseSVN makes of it.
Modifying a Working Copy File
Let’s return to the single file (PaymentMachine.java) in the repository and working copy. Open the file using a text editor, make a small change, and save the file to disk. Take a look at the Explorer window and you’ll see that the file representation has changed, as illustrated in Figure 5.
Figure 5 A change has occurred to a working copy file.
Notice the red exclamation points, indicating that TortoiseSVN has detected that the file has changed. If you right-click the modified file, you can select the option to commit the changes. The result of committing the changes is that the working copy in Figure 5 reverts to the usual green checkmark.
After committing the changes, you can use another TortoiseSVN option to view another perspective of the Java file history. Right-click the file and select Tortoise > Revision graph, and you should see something like Figure 6.
Figure 6 Revision change graph.
In Figure 6, the Java file has two revisions—the initial revision and the updated one.
So far, you’ve seen these steps:
- Creating the repository.
- Importing the source code files.
- Creating a working copy.
- Making changes to a file.
- Committing the changes.
- Viewing revision change details.
How do you check files out of the repository into your working copy?
Checking Files Out of the Repository
You can probably figure out how to refresh your working copy. Right-click and choose SVN Update, and you should see a window similar to that in Figure 7.
Figure 7 Updating the working copy.
Figure 7 indicates that the latest revision is 2 and that the working copy now matches revision 2. In other words, you’re up to date.