1 brief introduction to revision control ric holt

13
1 Brief Introduction to Revision Control Ric Holt

Upload: eleanor-wells

Post on 04-Jan-2016

214 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 1 Brief Introduction to Revision Control Ric Holt

1

Brief Introduction to Revision Control

Ric Holt

Page 2: 1 Brief Introduction to Revision Control Ric Holt

2

Revision Control, also known as:Version Control or

SCM = Source Control Management

Management of changes to documents, programs, and other information stored as computer files.

Each changed file (or set of files) is called a version or a revision. These are often numbered, e.g., version 12.6.2.

A release is made available to users.

http://en.wikipedia.org/wiki/Revision_control

Page 3: 1 Brief Introduction to Revision Control Ric Holt

3

Software for SCM• (Related: CMS: Content Management System)• SCCS = Source Code Control System

– Obsolete as of 1995– Predecessor to RCS

• RCS = Revision Control System– By Walter Tichy, 1980s– Keeps track of evolving versions = revision control– Single user

• CVS = Concurrent Versions System– By Dick Grune, 1980s– Based on RCS, but multi-user– Subversion = free “better” CVS

• GIT– By Linus Torvalds, 2005– Distributed revision control – no central version– All “branches” are complete

Page 4: 1 Brief Introduction to Revision Control Ric Holt

4

Storing Successive Versions of a File

• Each change to a file is stored as the “diff” from its previous version

• Saves space, avoids full copy of each version– Less important now that file space is check

Page 5: 1 Brief Introduction to Revision Control Ric Holt

5

Delta = Difference Between Files

• Forward delta = How to change file F to its next version (store file F, compute next versions)

• Backward delta = How to change file G to its previous (store file G, compute previous versions)

File F File G

Backward Delta

Forward Delta

Page 6: 1 Brief Introduction to Revision Control Ric Holt

6

1. using System;2. using System.Collections.Generic;3. using System.Text;

4.5. class Program6. {7. static void Main(string[] args)8. {9. Console.WriteLine(10. "Hello World");11. // comment12. }13. }

Kinds of Changes: Add, Delete & Replace

Example from http://www.itu.dk/courses/VOP/E2006/6_Slides.pdf

1. using System;2. using System.Collections.Generic;3. using System.Text;4. class Program5. {6. static void Main(string[] args)7. {8. Console.WriteLine(9. "Hello Version Control");10. // comment11. Console.ReadLine();12. }13. }

delete

add

replace

Page 7: 1 Brief Introduction to Revision Control Ric Holt

7

Diff: Unix tool, gives difference between two files.

$ diff v1.txt v2.txt4d3<10c9< "Hello World");---> "Hello Version

Control");11a11> Console.ReadLine();

Delete (d) line 4

Change (c) line 10

Add (a) line 11

Page 8: 1 Brief Introduction to Revision Control Ric Holt

8

Master Version & Working (Sandbox) Versions

x

yz

Master Version in Repository

x

yz

Anne’s Version in Her Sandbox

x

yz

Bob’s Version in His Sandbox

System consisting of files x, y and z is being developed.

Anne and Bob simultaneously change various files, ideally different files.

Page 9: 1 Brief Introduction to Revision Control Ric Holt

9

Check In, Check Out, etc.

x

yz

Master Copies in Repository

x

yz

Local (Working) Copies in Sandbox

Check Out (Lock)

Check In (Commit)

Page 10: 1 Brief Introduction to Revision Control Ric Holt

10

CVS Operations

• Check out - Lock set of files (get copies)

• Commit (check in) - Use your checked out copies to update the repository

• Update - Using central repository, get fresh copies

• Add - Signal that a local file is to be added to repository (upon commit)

Page 11: 1 Brief Introduction to Revision Control Ric Holt

11

Branches & Merges

• A branch is a new stream of development, e.g., Version 8.0 of a data base (new version of V7.0)

• As bugs are found in V7.0, these need to be merged into V8.0 (and vice versa)

• Merges can be very tricky and slow to carry out

Page 12: 1 Brief Introduction to Revision Control Ric Holt

12

Conflicts

• Ideally, no two people try to update the same file at the same time.

• If they do, and they changed different parts of the file, the changes are– MERGED

• If they do, and they have changed the same parts of a file, there is a– CONFLICT

• Generally conflicts are fixed manually.

Page 13: 1 Brief Introduction to Revision Control Ric Holt

13

GIT: A Fast Version Control System

• Invented by Linus Torvalds

• GIT – Is distributed --- no master copy– Is controversial– Safeguards against corruption– Has fast merges– Scales up– Convenient tools still being built