Source Code Control

Source Code Control

Source Code Control

  • Maintains all of a project's source code in a repository
  • Protects team resources from accidental deletion
  • Maintains a version-by-version history of all project files
  • Protects individual changes from being unknowingly overwritten
  • Also known as Version Control or Revision Control

Source Code Control Features

  • Files are saved as they are edited, and can be restored to any past version
  • Multiple people can share files and stay up-to-date with the latest version
  • Developers can throw away recent changes and revert back to the last known good version
  • Developers can jump back to an old version of a file and see the changes made that day
  • As files are updated, developers can leave messages explaining the reason for the change
  • Every change is tagged with the name of the person who made it
  • Developers can make temporary changes in an isolated area, then test and resolve errors before “checking in” the changes to the mainline
  • Developers can branch a copy of their code into a separate area and modify it in isolation (tracking changes separately). Later, they can merge their work back into the common area

Source Code Control Concepts

  • Repository (repo) is the database storing the files to be managed and shared by everyone on the development team; the official place where all completed work is stored
  • Mainline is a reference to the current state of the source code control system
  • Trunk or mainline is the primary location for code in the repository
  • Source Control Server is the computer where the repository is stored
  • Source Control Client is the computer connecting to the repository
  • Check out is when a developer makes a controlled copy of the mainline to their own machine
  • Working Folder, Working Set or Working Copy is the local directory of files on the Source Control Client, where an individual developer make changes
  • Check in is when a devloper merges their changes from their working copy back to the mainline
  • History contains every version of every file that has ever been checked in to the repository

Source Code Control Benefits

  • Provides a place to store the source code for a project
  • Provides a historical record of what was done over time
  • Provides a way for developers to work on separate tasks in parallel, merging their efforts later
  • Provides a way for developers to work together without getting in each others' way

Source Code Control Basic Workflow

  • Copy the contents of the repository into a working folder
  • Make changes to the code in the working folder
  • Update the repository to incorporate those changes
  • Repeat Steps

Source Code Control Guidelines

  • Use a common project structure
  • Implement a consistent naming convention for all files and folders in the project
  • Update your working copy before making any changes to files
  • Update your working copy before merging changes back into the mainline
  • Put everything needed to do builds under version control
    • All files associated with the project
    • Configuration files
    • Database schema
    • Installation scripts
    • Properties files
    • Test scripts
    • Third party libraries
  • Consider placing project documents under version control
    • Architecture and design documents
    • Artwork
    • IDE configurations
    • Meeting minutes and notes
    • Protocol and other specifications
    • Serialized database content, etc.
  • Create home folders in the repository for developer sandboxes
  • Commit changes in logical chunks and commit often
  • Keep your use of branches for different streams of development to a minimum
    • Developers should work off the mainline most of the time
    • Use branches for bug fixes of prior production releases and temporary experiments
  • Write meaningful commit messages when committing something to the repository
  • Perform all copy, delete, move and rename file/folder operations in the version control system instead of directly in the file system
  • Set up change notifications to send out an e-mail or update an RSS feed whenever a commit is made

Repository Guidelines

  • Create a single repository for the entire company or department and store all projects in this repository
    • Reduces the amount of required source control server maintenance activity
    • Enables collaborators to move data between projects easily, without losing any historical versioning information
    • Subversion operations like copy, diff and merge  are not supported across multiple projects
  • Create three subfolders for each project
    • The trunk folder contains the main development branch
    • The branches folder contains subfolders with temporary copies of trunk for what-if and trial development
    • The tags folder contains copies of the officially released versions