Version Control Systems Why use What systems What

  • Slides: 33
Download presentation
Version Control Systems Why use? What systems? What functions? Creative Commons License – Curt

Version Control Systems Why use? What systems? What functions? Creative Commons License – Curt Hill.

What are they? • Software that stores different versions of documents – Documents are

What are they? • Software that stores different versions of documents – Documents are usually source code – May also include auxiliary items: • Test cases • Documentation • Make files • Allow developers to recreate the way the system was at a previous time – Somewhat like an editor undo but much larger and more complicated Creative Commons License – Curt Hill.

Problems That are Solved • Program is updated but the fix broke something else

Problems That are Solved • Program is updated but the fix broke something else – Cannot find all the places changed to restore to original state – Problem not detected until much later • Two people make changes to a program – Both changes work alone – When put together it does not work Creative Commons License – Curt Hill.

Versions • Often refers to a succession of the same program – Windows 7

Versions • Often refers to a succession of the same program – Windows 7 and 8 are different versions • May also refer to different targets – Linux for Intel vs. Linux for ARM – Lots in common but differences in various places – This is more commonly referred to as a branch Creative Commons License – Curt Hill.

What do they do? • Keep multiple versions of any relevant documents • Maintain

What do they do? • Keep multiple versions of any relevant documents • Maintain information about changes – Who made the change – Comments on what the change did – Dates of the versions – Bug report completed • Allows code to be checked out, changed and then checked back in • Show differences between two files Creative Commons License – Curt Hill.

What not to keep? • Anything that can be generated: • Object or machine

What not to keep? • Anything that can be generated: • Object or machine language – Generated by compilers • Documentation that is machine generated by: – Java. Doc – Doxygen – Any other document generator • Anything else that can never change Creative Commons License – Curt Hill.

The Process • A repository keeps the documents – Very specialized database • Developer

The Process • A repository keeps the documents – Very specialized database • Developer checks out a document • This is edited to improve it • It is checked back in (aka committed) with the control information • If the repository supports: – Automatic unit tests are run – Failure of these can retract the check in Creative Commons License – Curt Hill.

Terminology • Version – updated copy of a document • Branch – new target

Terminology • Version – updated copy of a document • Branch – new target of a document – Versions are automatically created, but branches are not – Allows multiple current documents • Merge – making two branches into one • Project – a set of files pertaining to one program or system • Conflict – a check in of two items that do not agree Creative Commons License – Curt Hill.

First Branch Support • The C preprocessor was the first attempt to handle multiple

First Branch Support • The C preprocessor was the first attempt to handle multiple platforms • This uses the #if, #ifdef, #ifndef etc. • Code specific to a single hardware or compiler could be incorporated without separating into two separate files – The separate files will defy proper maintenance Creative Commons License – Curt Hill.

Example Branch • Version 1. 0 is released • Version 1. 1 is an

Example Branch • Version 1. 0 is released • Version 1. 1 is an improvement • Before 1. 1 is ready for release a problem is found a bug fix generated – Create 1. 0. 1 • We now have a branch of 1. 1 and 1. 0. 1 Creative Commons License – Curt Hill.

A Branch 1. 0 1. 1 1. 0. 1 Creative Commons License – Curt

A Branch 1. 0 1. 1 1. 0. 1 Creative Commons License – Curt Hill.

Example Merge • Two branches – 1. 1 is still under development – 1.

Example Merge • Two branches – 1. 1 is still under development – 1. 0. 1 is stable • Version 1. 1 has some improvements which we do not want to discard • What is needed is to merge the fix of 1. 0. 1 into 1. 1 Creative Commons License – Curt Hill.

A Merge 1. 0 1. 1 1. 2 1. 0. 1 Creative Commons License

A Merge 1. 0 1. 1 1. 2 1. 0. 1 Creative Commons License – Curt Hill.

Example Again • It is possible that the changes of 1. 1 did not

Example Again • It is possible that the changes of 1. 1 did not need the bug fix of 1. 0. 1 because it tried another approach to the same code – If so the 1. 0. 1 becomes a dead end and is not developed further • The version numbers are likely to be maintained by the version control and more version numbers will be generated Creative Commons License – Curt Hill.

Branching Again • The branch before produced a dead end after the changes were

Branching Again • The branch before produced a dead end after the changes were merged with the developed new version • Branches are often more permanent – One branch for Windows – One branch for Mac – Both will be continued indefinitely Creative Commons License – Curt Hill.

Simultaneous Checkout 1. 2 a 1. 2 b Suppose two or more developers check

Simultaneous Checkout 1. 2 a 1. 2 b Suppose two or more developers check out the same code in a day. What will happen on check in? Creative Commons License – Curt Hill.

Concurrency • Some systems only allow the first check in – This will force

Concurrency • Some systems only allow the first check in – This will force the second one to reconcile the two sets of changes – Atomic commits • Some systems will accept both provided they do not touch any of the same lines – Merging • Some will merge both and then run tests and reject them if they do not work Creative Commons License – Curt Hill.

Check in 1. 3 1. 4 1. 2 1. 3 Top checked in first

Check in 1. 3 1. 4 1. 2 1. 3 Top checked in first and retained. Bottom checks out 1. 3 and then applies different changes. Creative Commons License – Curt Hill.

Storage • There mostly two ways to store the data – Snapshot – Keep

Storage • There mostly two ways to store the data – Snapshot – Keep separate copies of each file for each version • Faster to extract but uses more space – Change set – Store changes within the file • Unchanged lines only exist once • Where are things stored: – Single library containing all the files – A directory of files • Usually matches the sandbox directory Creative Commons License – Curt Hill.

 • Local Paradigms – Originally there was a single local repository – All

• Local Paradigms – Originally there was a single local repository – All changes needed to be run on that machine • Client – server – Still one repository, but clients may update from any networked machine • Distributed – Repository is duplicated on every developer’s machine Creative Commons License – Curt Hill.

Distributed Again • A distributed version control system has multiple repositories • How are

Distributed Again • A distributed version control system has multiple repositories • How are they kept synchronized? • A push is a repository telling others about changes in a project • A pull is a repository asking for updates from another • Push/pull usually involves multiple files instead of single files Creative Commons License – Curt Hill.

Systems • • SCCS RCS Subversion GIT Mercurial Visual Source Safe Many others Creative

Systems • • SCCS RCS Subversion GIT Mercurial Visual Source Safe Many others Creative Commons License – Curt Hill.

SCCS • • Source Code Control System UNIX May be first, no later that

SCCS • • Source Code Control System UNIX May be first, no later that early 1970 s Stored originals and then the differences between a version and the next version Creative Commons License – Curt Hill.

RCS • Revision Control System • Update of SCCS, also on UNIX • Keep

RCS • Revision Control System • Update of SCCS, also on UNIX • Keep current and uses differences to go back in time Creative Commons License – Curt Hill.

CVS • Concurrent Version System • Update of RCS but operates on several types

CVS • Concurrent Version System • Update of RCS but operates on several types of systems • Uses client / server approach Creative Commons License – Curt Hill.

Subversion • An update of CVS • May apply versioning to directories and metadata

Subversion • An update of CVS • May apply versioning to directories and metadata – Not just files • Atomic check-in – No overwriting • Client Server model – Clients may be on different machines Creative Commons License – Curt Hill.

SVN Architecture Creative Commons License – Curt Hill.

SVN Architecture Creative Commons License – Curt Hill.

GIT • An open-source, distributed version control system – GITHUB seems to be the

GIT • An open-source, distributed version control system – GITHUB seems to be the current choice for open source projects • Developed by Linus Torvalds for the LINUX kernel • Designed for speed and scalability • Each developer gets a local copy of the repository Creative Commons License – Curt Hill.

Seriously Creative Commons License – Curt Hill.

Seriously Creative Commons License – Curt Hill.

Mercurial • Another open-source, distributed version control system with many similarities to GIT Creative

Mercurial • Another open-source, distributed version control system with many similarities to GIT Creative Commons License – Curt Hill.

Too Old • If a software system lasts long enough you may not be

Too Old • If a software system lasts long enough you may not be interested in saving everything forever • One possibility is choosing a date and then removing all the changes that occurred earlier than that time – Possibly moving the old changes to less accessible media Creative Commons License – Curt Hill.

Conclusions • Version control is a requirement for software development • Allows easy recreation

Conclusions • Version control is a requirement for software development • Allows easy recreation of the project at a particular time – Which makes it easier to find when a bug was introduced • Also supports branches – Different platforms or different functionality while still maintaining the common code base • The check out and check in feature enables teams Creative Commons License – Curt Hill.

Post Conclusions • Let’s see if we can examine some of these – Subversion

Post Conclusions • Let’s see if we can examine some of these – Subversion – Git – Google’s Version Control Creative Commons License – Curt Hill.