SVN Setup

From 1511Wookiee
Jump to navigationJump to search

Source Code Repository Introduction

Team 1511 uses Subversion for its source code management. Subversion allows multiple developers to easily work together on a common code base, across many computer systems. On this page, you'll find the access information for our repository, as well as links to Subversion client software.

Using SVN to Access the Robot Code

  • Initial Setup
    • Pick one of the client options from the bottom of this page and install it. The easiest client to use on Windows is Tortoise SVN. These instructions assume you are using this.
    • Install TortoiseSVN - the default options are typically fine for most people.
    • Create a folder on your computer to hold the robot code. For this example, we will use c:\FIRST
    • Open this folder in Windows Explorer, then right-click in the explorer window. In the context menu, choose "SVN Checkout"
    • In the window that opens, you need to enter the URL to the SVN repository. You can get the right URL to use in the next section of this page (each year's code uses a different URL)
    • Click OK
    • You will be prompted to login. If you don't have a login for SVN or forgot it, ask a mentor.
    • The most recent version of the robot code on the server is transferred to c:\FIRST on your computer.
  • Updating Your Local Copy of Code
    • Your local version of the robot code can be updated with the work others have checked into the server - you should do this once a day or more often when you start working
    • To update, open Windows explorer to your code location on your computer
    • Right-click the code folder and choose "SVN Update"
    • The code is updated locally - NOTE: If another person updated a file that you had made changes to as well, you may get what is known as a "Merge conflict". See "Resolving Merge Conflicts" below.
  • Committing Your Changes
    • Once you have made a set of changes that you want to share with the rest of the team, you will need to "commit" them to the SVN server.
    • Before doing this, have your changes checked by a mentor! See the section below on mentor review!
    • Open Windows Explorer to your robot code folder. Right-click the folder and choose "SVN Commit".
    • Enter a high-level description of the changes you made (example: "Added code to run the new intake"
    • Click OK -- the changes are sent to the server.
    • You may get a message that your local version is out of date. This means you need to Update (see above section) to get the latest changes from the server before you can commit. Update, then repeat the commit.
  • Resolving Merge Conflicts
    • Follow these steps if you have a merge conflict after doing an update. A merge conflict means that someone else made changes to the same part of the code that you did and SVN couldn't figure out how to automatically combine the changes in a sensible way.
    • In Windows Explorer, the files with conflicts will be marked with a special icon. Open these files in VS Code.
    • The file will have the sections in conflict marked up as follows:
   // My code I wrote or changed is here
   int my_x = 10;
   // The code changes by the other author will be here
   int the_other_persons_x = 20;
    • As you can see, your version of the code and the other author's changes are shown with special line markings (the <, ==, and > lines)
    • You need to edit these to produce one final version, merging things together. When you are done, you remove the special line markings, leaving only the final code.
    • Sometimes you might completely remove their edits and use yours, sometimes you might completely remove your edits because the other person did the same thing but differently, or other times you might keep both sets of changes or some mixture thereof!
    • If you need help figuring out what edits to make to fix a conflict, ask a mentor.
    • Once you edit all the conflicts, you need to tell SVN you are done. This is called "Resolving" the conflict. To do this, open Windows Explorer to the code location, find the conflicted file(s), select them, then right-click and choose Tortoise SVN, then "Resolve"
    • When you have marked all conflicts as resolved, you would continue the normal process to make your own changes to the code. Eventually you will want to commit to send your changes to the server. Remember to have a mentor review before committing!

Mentor Review of Code Changes

Before you commit changes to the code into SVN, a programming mentor should review the changes. When working in person, simply ask one of the programming mentors to look your changes over on the laptop you have been working on. If working remotely, follow these steps to get a mentor to look at your changes:

  1. Make sure all files in VSCode are saved!
  2. Do an Update from SVN before you proceed. This will make sure your changes apply cleanly with anyone else's recent changes. If you get conflicts, see the steps in the Using SVN section to resolve the conflicts.
  3. These next steps will generate a "patch file" that shows the changes you've made in a concise form.
    1. Open Windows Explorer to the location on your computer where your code is.
    2. Right-click in Explorer and mouse over TortoiseSVN to expand the next menu. Then choose "Create Patch".
    3. In the new window, make sure there is a checkmark next to all your changed files. It should do this automatically, but double-check. Especially check that any new files you are adding are checked.
    4. Click OK, then browse to a location to save the "patch" file.
  4. Post the newly created patch file in the programming Slack channel with a short message saying what the changes do and a mentor will take a look!
  5. Once the mentor reviews and says it is ok, proceed by committing.

Team 1511 Subversion Repository Details

We have one repository for each team-year. All repositories are accessible via http. Simple browsing can be done with a web browser; actually modifying and contributing code requires a Subversion client. When checking out your initial working copy, configure your Subversion client to use the URLs below:

Access requires a username and password. Access is provided to Programming Subteam members only. Please post to the Programming Build Season forum or contact Jeff if you need an account.

Subversion Client Software

Links to Subversion clients:

  • Tortoise SVN - Easy-to-use graphical client implemented as a Windows Explorer shell extension. Basically adds menu items to the Explorer right-click menues. Very convenient and user-friendly. Windows only.
  • SVN - Command-line client provided by creators of Subversion. Works on Linux, Windows, and just about everything.