Version Control Subversion
November 22, 2019, 4:43 PMTable of Contents
Subversion
- This page is originally documented in DigiPen's wiki - https://inside.digipen.edu/main/SVN
SVN requires a client program to connect to what is called a "repository" where the files are stored. On commonly used SVN client is called TortoiseSVN, which is available on all DigiPen workstations.
All you need to do is send a request to helpdesk.sg@digipen.edu for an SVN creation by stating the preferred name of your group's SVN and provide the list of usernames who needs to have to it. Should you need to have access to an existing SVN repository send a request and specify the name of the SVN you would need to have access to.
[Show video playback for example of SVN request to helpdesk email]
How do I use SVN?
The basic life cycle of SVN is:
- Make and initialize a repository (send email to helpdesk.sg@digipen.edu)
- Checkout or update
- Do your work, including editing, adding, or deleting files.
- Commit
- Refer to below steps.
Checkout a repository
[Show video playback for example of SVN checkout command.]
After a repository has been created, the first thing to is "Checkout." Checkout downloads the current contents of the repository to the local computer so that you can work on it. To checkout a repository, right-click in a folder to open the windows context menu. In there you will see, among other things, "SVN Checkout..."
This will open the checkout window. There are two important things here. The first is the repository URL. If you skipped the previous section, we recommend you go through it again.
Personal Repositories: https://svn.sg.digipen.edu/users/username
Project Repositories: https://svn.sg.digipen.edu/projects/team_name
Enter the appropriate URL substituting "username" with the username you login with or "team_name" with the name of your project team.
The other field is the location to put the files on the local computer. This defaults to the folder that you right clicked in. If there are already things in this folder, then TortoiseSVN will complain. It is a good idea to create an empty subfolder and checkout into there instead. IE: C:\Users\username\Desktop\SVN_Folder; you could also keep your working copy on removable media.
Using removable media, such as a USB drive, has several advantages:
- You can use the same working copy on any computer at DigiPen or at home.
- USB storage is faster than network storage.
- You won't loose your work if somebody else uses the workstation or it is re-imaged or replaced.
Once you click ok, you will be prompted to key in your username and password. This will be the same username and password you use to login with, regardless of if it is a personal or project repository.
If everything goes correctly, it will begin downloading files.
Congratulations, that's all there is to it. Inside the folder you will see the files under the repository's control. If this is your very first time checking out the project, then the only thing will be a place holder readme file. Feel free to "SVN Delete" it.
Updating
If you already have a repository checked out on the computer, then you do not need to check it out again. Instead what you do is "Update" it to download any files that have been committed since the lack checkout or update. To do this, go into the repository and right click, where you will see an "SVN Update" option.
When you click this, SVN will begin the process of downloading changes from the server. Once it is done, you can begin work.
Editing, Adding, and Deleting Files
Once a repository had been checked out, you are free work on it as you see fit. Get to work!
Adding: Since the repository starts empty, the first thing to do is make some files. Come back once that is done... Ok, before SVN will do anything with a file, you have to add it to the repository. This is done, once again, in the right-click menu, in the "TortoiseSVN" submenu, "Add."
When you click this, a list of all of the files not currently user SVN's control will appear. All of the checked files will be added to the repository.
Just click OK.
Deleting: Similarly, if you ever wish to remove a file from the repository, there is a "delete" option. Just right click on the file and choose delete.
Committing
So you've done all of this work. Adding and editing files, and maybe even deleting a few. The last step is to commit your work back to the server. Without this step, then nothing really happened from the server's perspective. ALWAYS remember to do this - It's the whole point of version control!
If you haven't guess by now, the "SVN Commit" option is in the right click menu.
When you click it, a window will come up. The first large text field is for comment about what you have done. It is good idea to give a short description of the changes you have made to the repository.
Below that is the list of files that have been changed.
If everything goes smoothly, then the server will contain your updated files. One common problem that occurs is when someone else makes a commit between the time you last updated. When this happens, the commit will display an error telling you to update.
In most cases a simple update will grab the newest files from the server, merge your changes, and you will be able to finish the commit. In rare cases, a conflict will occurs when changes overlap.
Conflicts
SVN is like CVS in that it does not exclusively lock files when you check out a repository. It is entirely possible, and in fact, very common, for two people to be working on the same project at the same time. SVN does its best to merge these changes together no matter what order things are checked out, updated, edited, and committed in.
In general, it does a very good job of it. In fact, it is possible to two people to edit the same file in different locations and the changes will be merged together. Unfortunately, the process is not perfect, and it cannot handle situations where changes overlap in a file. When this happens, it is called a "conflict."
Conflicts usually happen when you try to update or commit a file that you and someone else have both edited. It become the job of whoever came second to fix the situation. SVN will display a message when this happens and list the offending files.
The files that are conflicting will be marked with a warning symbol:
TortoiseSVN comes with a built in diff and merge program. It is very useful for resolving conflicts in files. To access it, right-click on the file and in the "TortoiseSVN" menu there is an "Edit Conflicts" option.
This will bring up the TortoiseMerge. In the top left pane is the 1st committed file (IE: The file your teammate probably committed). In the top right pane is the file with your edits. And in the bottom is the merged result. The conflicts are highlighted in bright red, and you can choose which version of each line to keep and throw away by right clicking on the lines.
Other FAQs
What do the little symbols on the files mean?
The three most common symbols are:
- Up to date: this version of the file is the same as the server's.
- Changed: you have made changes to this file that have not been committed
- Conflict: this file has a conflict
Troubleshooting
Can Trac send emails when tickets are created?
- Yes, everyone on the team simply needs to login to Trac, go to Preferences, and enter in their name and email. After that, Trac will send emails to everyone who entered in their info about any new tickets or posts.
Sometimes problems can occur which are related to your workstation account. Here are a few things you can try to do to resolve such problems:
- Right click on a svn repo and choose: TortoiseSVN -> Settings -> Saved Data -> Clear the "Authentication data" (perhaps also clear the other items)
- Right click on the start menu and choose Explore. Now go up one folder and see if there is a \Local Settings\Application Data\TSVNCache folder. Remove it.
- See if you have a R:\Application_Data\TortoiseSVN or a R:\Application_Data\Subversion folder and remove them.
Sometimes the operating system may create new files or folders within a repository that you may not be aware of, these may cause a problems.
- You you view a folder as thumbnails windows may create a thumbs.db file, remove it.