Distributed Version Control Systems Matthieu Moy Computer Science - - PowerPoint PPT Presentation

distributed version control systems
SMART_READER_LITE
LIVE PREVIEW

Distributed Version Control Systems Matthieu Moy Computer Science - - PowerPoint PPT Presentation

Prehistory History Linux Bazaar Conclusion Distributed Version Control Systems Matthieu Moy Computer Science and Automation Indian Institute of Science Bangalore October 2006 Matthieu Moy (CSA/IISc) DVC October 2006 < 1 / 43 >


slide-1
SLIDE 1

Prehistory History Linux Bazaar Conclusion

Distributed Version Control Systems

Matthieu Moy

Computer Science and Automation Indian Institute of Science Bangalore

October 2006

Matthieu Moy (CSA/IISc) DVC October 2006 < 1 / 43 >

slide-2
SLIDE 2

Prehistory History Linux Bazaar Conclusion

Outline

1

Motivations, Prehistory

2

History and Categories of Version Control Systems

3

Version Control for the Linux Kernel

4

Bazaar (bzr): One Decentralized Revision Control System

5

Conclusion

Matthieu Moy (CSA/IISc) DVC October 2006 < 2 / 43 >

slide-3
SLIDE 3

Prehistory History Linux Bazaar Conclusion

Outline

1

Motivations, Prehistory

2

History and Categories of Version Control Systems

3

Version Control for the Linux Kernel

4

Bazaar (bzr): One Decentralized Revision Control System

5

Conclusion

Matthieu Moy (CSA/IISc) DVC October 2006 < 3 / 43 >

slide-4
SLIDE 4

Prehistory History Linux Bazaar Conclusion

Backups: The Old Good Time

Basic problems:

◮ “Oh, my disk crashed.” / “Someone has stolen my laptop!” ◮ “@#%!!, I’ve just deleted this important file!” ◮ “Oops, I introduced a bug a long time ago in my code, how can I see

how it was before?”

Matthieu Moy (CSA/IISc) DVC October 2006 < 4 / 43 >

slide-5
SLIDE 5

Prehistory History Linux Bazaar Conclusion

Backups: The Old Good Time

Basic problems:

◮ “Oh, my disk crashed.” / “Someone has stolen my laptop!” ◮ “@#%!!, I’ve just deleted this important file!” ◮ “Oops, I introduced a bug a long time ago in my code, how can I see

how it was before?”

Historical solutions:

Matthieu Moy (CSA/IISc) DVC October 2006 < 4 / 43 >

slide-6
SLIDE 6

Prehistory History Linux Bazaar Conclusion

Backups: The Old Good Time

Basic problems:

◮ “Oh, my disk crashed.” / “Someone has stolen my laptop!” ◮ “@#%!!, I’ve just deleted this important file!” ◮ “Oops, I introduced a bug a long time ago in my code, how can I see

how it was before?”

Historical solutions:

◮ Replicate:

$ cp -r ~/project/ ~/backup/

Matthieu Moy (CSA/IISc) DVC October 2006 < 4 / 43 >

slide-7
SLIDE 7

Prehistory History Linux Bazaar Conclusion

Backups: The Old Good Time

Basic problems:

◮ “Oh, my disk crashed.” / “Someone has stolen my laptop!” ◮ “@#%!!, I’ve just deleted this important file!” ◮ “Oops, I introduced a bug a long time ago in my code, how can I see

how it was before?”

Historical solutions:

◮ Replicate:

$ cp -r ~/project/ ~/backup/

◮ Keep history:

$ cp -r ~/project/ ~/backup/project-2006-10-4

Matthieu Moy (CSA/IISc) DVC October 2006 < 4 / 43 >

slide-8
SLIDE 8

Prehistory History Linux Bazaar Conclusion

Backups: The Old Good Time

Basic problems:

◮ “Oh, my disk crashed.” / “Someone has stolen my laptop!” ◮ “@#%!!, I’ve just deleted this important file!” ◮ “Oops, I introduced a bug a long time ago in my code, how can I see

how it was before?”

Historical solutions:

◮ Replicate:

$ cp -r ~/project/ ~/backup/

◮ Keep history:

$ cp -r ~/project/ ~/backup/project-2006-10-4

◮ Keep a description of history:

$ echo "Description of current state" > \ ~/backup/project-2006-10-4/README.txt

Matthieu Moy (CSA/IISc) DVC October 2006 < 4 / 43 >

slide-9
SLIDE 9

Prehistory History Linux Bazaar Conclusion

Backups: Improved Solutions

Replicate over multiple machines Incremental backups: Store only the changes compared to previous revision

◮ With file granularity ◮ With finer-grained (diff)

Many tools available:

◮ Standalone tools: rsync, rdiff-backup, . . . ◮ Versionned filesystems: VMS, Windows 2003+, cvsfs, . . . Matthieu Moy (CSA/IISc) DVC October 2006 < 5 / 43 >

slide-10
SLIDE 10

Prehistory History Linux Bazaar Conclusion

Collaborative Development: The Old Good Time

Basic problems: Several persons working on the same set of files

1

“Hey, you’ve modified the same file as me, how do we merge?”,

2

“Your modifications are broken, your code doesn’t even compile. Fix your changes before sending it to me!”,

3

“Your bug fix here seems interesting, but I don’t want your other changes”.

Matthieu Moy (CSA/IISc) DVC October 2006 < 6 / 43 >

slide-11
SLIDE 11

Prehistory History Linux Bazaar Conclusion

Collaborative Development: The Old Good Time

Basic problems: Several persons working on the same set of files

1

“Hey, you’ve modified the same file as me, how do we merge?”,

2

“Your modifications are broken, your code doesn’t even compile. Fix your changes before sending it to me!”,

3

“Your bug fix here seems interesting, but I don’t want your other changes”.

Historical solutions:

Matthieu Moy (CSA/IISc) DVC October 2006 < 6 / 43 >

slide-12
SLIDE 12

Prehistory History Linux Bazaar Conclusion

Collaborative Development: The Old Good Time

Basic problems: Several persons working on the same set of files

1

“Hey, you’ve modified the same file as me, how do we merge?”,

2

“Your modifications are broken, your code doesn’t even compile. Fix your changes before sending it to me!”,

3

“Your bug fix here seems interesting, but I don’t want your other changes”.

Historical solutions:

◮ Never two person work at the same time. When one person stops

working, (s)he sends his/her work to the others. ⇒ Doesn’t scale up! Unsafe.

Matthieu Moy (CSA/IISc) DVC October 2006 < 6 / 43 >

slide-13
SLIDE 13

Prehistory History Linux Bazaar Conclusion

Collaborative Development: The Old Good Time

Basic problems: Several persons working on the same set of files

1

“Hey, you’ve modified the same file as me, how do we merge?”,

2

“Your modifications are broken, your code doesn’t even compile. Fix your changes before sending it to me!”,

3

“Your bug fix here seems interesting, but I don’t want your other changes”.

Historical solutions:

◮ Never two person work at the same time. When one person stops

working, (s)he sends his/her work to the others. ⇒ Doesn’t scale up! Unsafe.

◮ People work on the same directory (same machine, NFS, . . . )

⇒ Painful because of (2) above.

Matthieu Moy (CSA/IISc) DVC October 2006 < 6 / 43 >

slide-14
SLIDE 14

Prehistory History Linux Bazaar Conclusion

Collaborative Development: The Old Good Time

Basic problems: Several persons working on the same set of files

1

“Hey, you’ve modified the same file as me, how do we merge?”,

2

“Your modifications are broken, your code doesn’t even compile. Fix your changes before sending it to me!”,

3

“Your bug fix here seems interesting, but I don’t want your other changes”.

Historical solutions:

◮ Never two person work at the same time. When one person stops

working, (s)he sends his/her work to the others. ⇒ Doesn’t scale up! Unsafe.

◮ People work on the same directory (same machine, NFS, . . . )

⇒ Painful because of (2) above.

◮ People lock the file when working on it.

⇒ Doesn’t scale up!

Matthieu Moy (CSA/IISc) DVC October 2006 < 6 / 43 >

slide-15
SLIDE 15

Prehistory History Linux Bazaar Conclusion

Collaborative Development: The Old Good Time

Basic problems: Several persons working on the same set of files

1

“Hey, you’ve modified the same file as me, how do we merge?”,

2

“Your modifications are broken, your code doesn’t even compile. Fix your changes before sending it to me!”,

3

“Your bug fix here seems interesting, but I don’t want your other changes”.

Historical solutions:

◮ Never two person work at the same time. When one person stops

working, (s)he sends his/her work to the others. ⇒ Doesn’t scale up! Unsafe.

◮ People work on the same directory (same machine, NFS, . . . )

⇒ Painful because of (2) above.

◮ People lock the file when working on it.

⇒ Doesn’t scale up!

◮ People work trying to avoid conflicts, and merge later. Matthieu Moy (CSA/IISc) DVC October 2006 < 6 / 43 >

slide-16
SLIDE 16

Prehistory History Linux Bazaar Conclusion

Merging: Problem and Solution

My version #include <stdio.h> int main () { printf("Hello"); return EXIT_SUCCESS; } Your version #include <stdio.h> int main () { printf("Hello!\n"); return 0; }

Matthieu Moy (CSA/IISc) DVC October 2006 < 7 / 43 >

slide-17
SLIDE 17

Prehistory History Linux Bazaar Conclusion

Merging: Problem and Solution

My version #include <stdio.h> int main () { printf("Hello"); return EXIT_SUCCESS; } Your version #include <stdio.h> int main () { printf("Hello!\n"); return 0; } Common ancestor #include <stdio.h> int main () { printf("Hello"); return 0; }

Matthieu Moy (CSA/IISc) DVC October 2006 < 7 / 43 >

slide-18
SLIDE 18

Prehistory History Linux Bazaar Conclusion

Merging: Problem and Solution

My version #include <stdio.h> int main () { printf("Hello"); return EXIT_SUCCESS; } Your version #include <stdio.h> int main () { printf("Hello!\n"); return 0; } Common ancestor #include <stdio.h> int main () { printf("Hello"); return 0; }

Tools like diff3 can solve this Merging relies on history!

Matthieu Moy (CSA/IISc) DVC October 2006 < 7 / 43 >

slide-19
SLIDE 19

Prehistory History Linux Bazaar Conclusion

Merging: Problem and Solution

My version #include <stdio.h> int main () { printf("Hello"); return EXIT_SUCCESS; } Your version #include <stdio.h> int main () { printf("Hello!\n"); return 0; } Common ancestor #include <stdio.h> int main () { printf("Hello"); return 0; }

Tools like diff3 can solve this Merging relies on history! Collaborative development linked to backups

Matthieu Moy (CSA/IISc) DVC October 2006 < 7 / 43 >

slide-20
SLIDE 20

Prehistory History Linux Bazaar Conclusion

Merging

Space of possible revisions (arbitrarily represented in 2D)

Matthieu Moy (CSA/IISc) DVC October 2006 < 8 / 43 >

slide-21
SLIDE 21

Prehistory History Linux Bazaar Conclusion

Merging

Space of possible revisions (arbitrarily represented in 2D) Mine Yours

Matthieu Moy (CSA/IISc) DVC October 2006 < 8 / 43 >

slide-22
SLIDE 22

Prehistory History Linux Bazaar Conclusion

Merging

Space of possible revisions (arbitrarily represented in 2D) Mine Yours Ancestor

Matthieu Moy (CSA/IISc) DVC October 2006 < 8 / 43 >

slide-23
SLIDE 23

Prehistory History Linux Bazaar Conclusion

Merging

Space of possible revisions (arbitrarily represented in 2D) Mine Yours Ancestor Merged revision

Matthieu Moy (CSA/IISc) DVC October 2006 < 8 / 43 >

slide-24
SLIDE 24

Prehistory History Linux Bazaar Conclusion

Revision Control System: Basic Idea

Keep track of history:

◮ User makes modification and use commit to keep a snapshot of the

current state,

◮ Meta-data (user’s name, date, descriptive message,. . . ) recorded

together with the state of the project.

Use it for merging/collaborative development.

◮ Each user works on its own copy, ◮ User explicitly “takes” modifications from others when (s)he wants. Matthieu Moy (CSA/IISc) DVC October 2006 < 9 / 43 >

slide-25
SLIDE 25

Prehistory History Linux Bazaar Conclusion

Revision Control System: Basic Idea

Keep track of history:

◮ User makes modification and use commit to keep a snapshot of the

current state,

◮ Meta-data (user’s name, date, descriptive message,. . . ) recorded

together with the state of the project.

Use it for merging/collaborative development.

◮ Each user works on its own copy, ◮ User explicitly “takes” modifications from others when (s)he wants.

Efficient storage (“delta-compression” ≈ incremental backups):

◮ At least at file level (git) ◮ Usually store a concatenation of diffs Matthieu Moy (CSA/IISc) DVC October 2006 < 9 / 43 >

slide-26
SLIDE 26

Prehistory History Linux Bazaar Conclusion

Revision Control System: Basic Idea

Keep track of history:

◮ User makes modification and use commit to keep a snapshot of the

current state,

◮ Meta-data (user’s name, date, descriptive message,. . . ) recorded

together with the state of the project.

Use it for merging/collaborative development.

◮ Each user works on its own copy, ◮ User explicitly “takes” modifications from others when (s)he wants.

Efficient storage (“delta-compression” ≈ incremental backups):

◮ At least at file level (git) ◮ Usually store a concatenation of diffs

(Optional) notion of branch:

◮ Set of revisions recorded, but not visible in mainline, ◮ Can be merged into mainline when ready. Matthieu Moy (CSA/IISc) DVC October 2006 < 9 / 43 >

slide-27
SLIDE 27

Prehistory History Linux Bazaar Conclusion

Outline

1

Motivations, Prehistory

2

History and Categories of Version Control Systems

3

Version Control for the Linux Kernel

4

Bazaar (bzr): One Decentralized Revision Control System

5

Conclusion

Matthieu Moy (CSA/IISc) DVC October 2006 < 10 / 43 >

slide-28
SLIDE 28

Prehistory History Linux Bazaar Conclusion

CVS: The Centralized Approach

Configuration:

◮ 1 repository (contains all about the history of the project) ◮ 1 working copy per user (contains only the files of the project)

Basic operations:

◮ checkout: get a new working copy ◮ update: update the working copy to include new revisions in the

repository

◮ commit: record a new revision in the repository Matthieu Moy (CSA/IISc) DVC October 2006 < 11 / 43 >

slide-29
SLIDE 29

Prehistory History Linux Bazaar Conclusion

CVS: Example

Start working on a project: $ cvs checkout project $ cd project Work on it: $ vi foo.c # or whatever See if other users did something, and if so, get their modifications: $ cvs update Review local changes: $ cvs diff Record local changes in the repository (make it visible to others): $ cvs commit -m "Fixed incorrect Hello message"

Matthieu Moy (CSA/IISc) DVC October 2006 < 12 / 43 >

slide-30
SLIDE 30

Prehistory History Linux Bazaar Conclusion

Commit/Update Approach

Space of possible revisions

Matthieu Moy (CSA/IISc) DVC October 2006 < 13 / 43 >

slide-31
SLIDE 31

Prehistory History Linux Bazaar Conclusion

Commit/Update Approach

Space of possible revisions Existing revision

Matthieu Moy (CSA/IISc) DVC October 2006 < 13 / 43 >

slide-32
SLIDE 32

Prehistory History Linux Bazaar Conclusion

Commit/Update Approach

Space of possible revisions Existing revision User works on a checkout

Matthieu Moy (CSA/IISc) DVC October 2006 < 13 / 43 >

slide-33
SLIDE 33

Prehistory History Linux Bazaar Conclusion

Commit/Update Approach

Space of possible revisions Existing revision User works on a checkout New upstream revisions

Matthieu Moy (CSA/IISc) DVC October 2006 < 13 / 43 >

slide-34
SLIDE 34

Prehistory History Linux Bazaar Conclusion

Commit/Update Approach

Space of possible revisions Existing revision User works on a checkout New upstream revisions

Matthieu Moy (CSA/IISc) DVC October 2006 < 13 / 43 >

slide-35
SLIDE 35

Prehistory History Linux Bazaar Conclusion

Commit/Update Approach

Space of possible revisions Existing revision User works on a checkout New upstream revisions

Matthieu Moy (CSA/IISc) DVC October 2006 < 13 / 43 >

slide-36
SLIDE 36

Prehistory History Linux Bazaar Conclusion

Commit/Update Approach

Space of possible revisions Existing revision User works on a checkout New upstream revisions

Matthieu Moy (CSA/IISc) DVC October 2006 < 13 / 43 >

slide-37
SLIDE 37

Prehistory History Linux Bazaar Conclusion

Commit/Update Approach

Space of possible revisions Existing revision User works on a checkout New upstream revisions User runs "update"

Matthieu Moy (CSA/IISc) DVC October 2006 < 13 / 43 >

slide-38
SLIDE 38

Prehistory History Linux Bazaar Conclusion

Commit/Update Approach

Space of possible revisions Existing revision New upstream revisions User runs "update"

Matthieu Moy (CSA/IISc) DVC October 2006 < 13 / 43 >

slide-39
SLIDE 39

Prehistory History Linux Bazaar Conclusion

Commit/Update Approach

Space of possible revisions Existing revision New upstream revisions User runs "update" "commit" creates new revision

Matthieu Moy (CSA/IISc) DVC October 2006 < 13 / 43 >

slide-40
SLIDE 40

Prehistory History Linux Bazaar Conclusion

Commit/Update Approach

Space of possible revisions Existing revision New upstream revisions User runs "update" "commit" creates new revision

And so on ... !

Matthieu Moy (CSA/IISc) DVC October 2006 < 13 / 43 >

slide-41
SLIDE 41

Prehistory History Linux Bazaar Conclusion

Conflicts

When several users change the same line of code concurrently, Impossible for the tool to guess which version to take, ⇒ CVS leaves both versions with explicit markers, user resolves manually. Merge tools (Emacs’s smerge-mode, . . . ) can help.

Matthieu Moy (CSA/IISc) DVC October 2006 < 14 / 43 >

slide-42
SLIDE 42

Prehistory History Linux Bazaar Conclusion

Conflicts: an Example

Someone added \n, someone else added !: #include <stdio.h> int main () { <<<<<<< hello.c printf("Hello\n"); ======= printf("Hello!"); >>>>>>> 1.6 return EXIT_SUCCESS; }

Matthieu Moy (CSA/IISc) DVC October 2006 < 15 / 43 >

slide-43
SLIDE 43

Prehistory History Linux Bazaar Conclusion

CVS: Obvious Limitations

File-based system. No easy way to get back to a consistant old revision. No management of rename (remove + add) Bad performances

Matthieu Moy (CSA/IISc) DVC October 2006 < 16 / 43 >

slide-44
SLIDE 44

Prehistory History Linux Bazaar Conclusion

Subversion: A Replacement for CVS

Idea of subversion: drop-in replacement for CVS (could have been “CVS, version 2”, fix the obvious limitation, but no major change/innovation:

◮ Atomic, tree-wide commits (commit is either successful or unsuccessful,

but not half),

◮ Rename management, ◮ Optimized performances, some operations available offline. Matthieu Moy (CSA/IISc) DVC October 2006 < 17 / 43 >

slide-45
SLIDE 45

Prehistory History Linux Bazaar Conclusion

Remaining Limitations

Weak support for branching, Most operations can not be performed offline, Permission management:

◮ Allowing anyone on earth to commit compromises the security, ◮ Denying someone permission to commit means this user can not use

most of the features

◮ Constraint acceptable for private project, but painful for Free Software

in particular.

Matthieu Moy (CSA/IISc) DVC October 2006 < 18 / 43 >

slide-46
SLIDE 46

Prehistory History Linux Bazaar Conclusion

Decentralized Revision Control Systems

Idea: not just 1 central repository. Each user has his own repository. By default, operations (including commit are done on the user’s private branch) Users publish their repository, and request a merge.

Matthieu Moy (CSA/IISc) DVC October 2006 < 19 / 43 >

slide-47
SLIDE 47

Prehistory History Linux Bazaar Conclusion

Outline

1

Motivations, Prehistory

2

History and Categories of Version Control Systems

3

Version Control for the Linux Kernel

4

Bazaar (bzr): One Decentralized Revision Control System

5

Conclusion

Matthieu Moy (CSA/IISc) DVC October 2006 < 20 / 43 >

slide-48
SLIDE 48

Prehistory History Linux Bazaar Conclusion

Linux: A Project With Huge Needs in Version Control

Not the biggest Open-Source project, but probably the most active, ≈ 10Mb of patch per month, ≈ 20,000 files, 280Mb of sources. Many branches:

◮ Short life: work on a feature in a branch, request merge when ready. ◮ Long life: things that are unlikely to get into the official kernel before

some time (grsecurity, reiserfs4, SELinux in the past, . . . )

◮ Test, debug: a modification goes through several branches, is tested

there, before getting into mainline

◮ Distributor: Most distributions maintain a modified version of Linux

⇒ Centralized revision control is not manageable.

Matthieu Moy (CSA/IISc) DVC October 2006 < 21 / 43 >

slide-49
SLIDE 49

Prehistory History Linux Bazaar Conclusion

A bit of history

1991: Linus Torvalds starts writing Linux, using CVS, 2002: Linux adopts BitKeeper, a proprietary decentralized version control system (available free of cost for Linux), 2002-2005: Flamewars against BitKeeper, some Free Software alternatives appear (GNU Arch, Darcs, Monotone). None are good enough technically.

Matthieu Moy (CSA/IISc) DVC October 2006 < 22 / 43 >

slide-50
SLIDE 50

Prehistory History Linux Bazaar Conclusion

A bit of history

1991: Linus Torvalds starts writing Linux, using CVS, 2002: Linux adopts BitKeeper, a proprietary decentralized version control system (available free of cost for Linux), 2002-2005: Flamewars against BitKeeper, some Free Software alternatives appear (GNU Arch, Darcs, Monotone). None are good enough technically. 2005: BitKeeper’s free of cost license revoked. Linux has to migrate. 2005: Unsatisfied by the alternatives, Linus decides to start his own project, git.

Matthieu Moy (CSA/IISc) DVC October 2006 < 22 / 43 >

slide-51
SLIDE 51

Prehistory History Linux Bazaar Conclusion

A bit of history

1991: Linus Torvalds starts writing Linux, using CVS, 2002: Linux adopts BitKeeper, a proprietary decentralized version control system (available free of cost for Linux), 2002-2005: Flamewars against BitKeeper, some Free Software alternatives appear (GNU Arch, Darcs, Monotone). None are good enough technically. 2005: BitKeeper’s free of cost license revoked. Linux has to migrate. 2005: Unsatisfied by the alternatives, Linus decides to start his own project, git. 2006: Many young, but good projects for decentralized revision control: Darcs, git, Monotone, Mercurial, Bazaar, . . . 200?: Most likely, several projects will continue to compete, but I guess only 2 or 3 of the best will be widely adopted.

Matthieu Moy (CSA/IISc) DVC October 2006 < 22 / 43 >

slide-52
SLIDE 52

Prehistory History Linux Bazaar Conclusion

Outline

1

Motivations, Prehistory

2

History and Categories of Version Control Systems

3

Version Control for the Linux Kernel

4

Bazaar (bzr): One Decentralized Revision Control System

5

Conclusion

Matthieu Moy (CSA/IISc) DVC October 2006 < 23 / 43 >

slide-53
SLIDE 53

Prehistory History Linux Bazaar Conclusion

History of Bazaar

GNU Arch: First Free Software Decentralized Revision Control. Extremely complex for what it does, very slow, Baz: Fork of GNU Arch. Unmaintained as of now, Bazaar: Complete rewrite of Baz, with different concepts and user

  • interface. “Bazaar” is the name of the project, “bzr” is the

unix command. http://bazaar-vcs.org/

Matthieu Moy (CSA/IISc) DVC October 2006 < 24 / 43 >

slide-54
SLIDE 54

Prehistory History Linux Bazaar Conclusion

Bazaar Concepts

Revision: State of a project at a point in time, with meta-information, Repository: Set of revisions, with ancestry information, Branch: Totally ordered (and numbered) set of revisions, Working tree (aka Checkout): The project itself (set of files,

  • directories. . . ).

Matthieu Moy (CSA/IISc) DVC October 2006 < 25 / 43 >

slide-55
SLIDE 55

Prehistory History Linux Bazaar Conclusion

Starting a Project

Create a new, empty project: $ bzr init project $ cd project Alternatively, create a project in an existing directory: $ cd existing-project $ bzr init This creates a repository, a branch, and a working tree in the same

  • place. Try “ls .bzr/” to understand what happened.

Matthieu Moy (CSA/IISc) DVC October 2006 < 26 / 43 >

slide-56
SLIDE 56

Prehistory History Linux Bazaar Conclusion

Create the First Revision

Add files (bzr won’t touch the files unless you explicitly add them): $ bzr add

  • r individually

$ bzr add file1; bzr add file2 Commit (record new revision): $ bzr commit -m "descriptive message" (if you don’t provide -m, an editor will be opened to let you type your message)

Matthieu Moy (CSA/IISc) DVC October 2006 < 27 / 43 >

slide-57
SLIDE 57

Prehistory History Linux Bazaar Conclusion

Look at Your Own Changes

Short summary:

$ bzr status added: foo.c modified: bar.c

Complete diff:

$ bzr diff === modified file ’foo.c’

  • -- foo.c

2006-10-04 18:17:30 +0000 +++ foo.c 2006-10-04 18:17:35 +0000 @@ -1,5 +1,5 @@ #include <stdio.h> int main () {

  • printf("Hello");

+ printf("Hello\n"); }

Matthieu Moy (CSA/IISc) DVC October 2006 < 28 / 43 >

slide-58
SLIDE 58

Prehistory History Linux Bazaar Conclusion

Look at the History

See the past revisions:

$ bzr log

  • revno: 2

committer: Matthieu Moy <Matthieu.Moy@imag.fr> branch nick: foo timestamp: Wed 2006-10-04 23:55:49 +0530 message: fixed a bug

  • revno: 1

committer: Matthieu Moy <Matthieu.Moy@imag.fr> branch nick: foo timestamp: Wed 2006-10-04 23:47:30 +0530 message: initial revision

Matthieu Moy (CSA/IISc) DVC October 2006 < 29 / 43 >

slide-59
SLIDE 59

Prehistory History Linux Bazaar Conclusion

Publish your branch

Up to now, your branch is just on your hard disk, no one else sees it, Publish you branch: $ bzr push sftp://some-host.com/project-upstream Other people can now get their own copy: $ bzr get http://some-host.com/project-upstream (assuming the sftp location and http location are the same on some-host.com).

Matthieu Moy (CSA/IISc) DVC October 2006 < 30 / 43 >

slide-60
SLIDE 60

Prehistory History Linux Bazaar Conclusion

Working on an Existing Project

Get your own branch: $ bzr branch http://some-host.com/project $ cd project (note: get is indeed an alias for branch).

Matthieu Moy (CSA/IISc) DVC October 2006 < 31 / 43 >

slide-61
SLIDE 61

Prehistory History Linux Bazaar Conclusion

Working on an Existing Project

Get your own branch: $ bzr branch http://some-host.com/project $ cd project (note: get is indeed an alias for branch). Work on it! Commit your changes: $ bzr commit -m "implemented something awesome"

Matthieu Moy (CSA/IISc) DVC October 2006 < 31 / 43 >

slide-62
SLIDE 62

Prehistory History Linux Bazaar Conclusion

Working on an Existing Project

Get your own branch: $ bzr branch http://some-host.com/project $ cd project (note: get is indeed an alias for branch). Work on it! Commit your changes: $ bzr commit -m "implemented something awesome" Publish it and request a merge: $ bzr push sftp://my.isp.com/project-contrib/ $ mail -s "please, merge ..."

Matthieu Moy (CSA/IISc) DVC October 2006 < 31 / 43 >

slide-63
SLIDE 63

Prehistory History Linux Bazaar Conclusion

Merging

Two use cases:

◮ A contributor started working on a feature in your own branch, but you

want to follow upstream development.

◮ The contributor’s feature is completed, upstream wants to merge it.

Symetry in both use-cases, Successive merge possible, Bazaar keeps track of merge history. It knows what you miss, and what has already been merged.

Matthieu Moy (CSA/IISc) DVC October 2006 < 32 / 43 >

slide-64
SLIDE 64

Prehistory History Linux Bazaar Conclusion

Merging

Merge the changes into the working tree: $ bzr merge ../bar/ All changes applied successfully.

Matthieu Moy (CSA/IISc) DVC October 2006 < 33 / 43 >

slide-65
SLIDE 65

Prehistory History Linux Bazaar Conclusion

Merging

Merge the changes into the working tree: $ bzr merge ../bar/ All changes applied successfully. Check what happened: $ bzr status modified: foo.c pending merges: Matthieu Moy 2006-10-05 implemented something awesome

Matthieu Moy (CSA/IISc) DVC October 2006 < 33 / 43 >

slide-66
SLIDE 66

Prehistory History Linux Bazaar Conclusion

Merging

Merge the changes into the working tree: $ bzr merge ../bar/ All changes applied successfully. Check what happened: $ bzr status modified: foo.c pending merges: Matthieu Moy 2006-10-05 implemented something awesome Commit: $ bzr commit -m "merged awesome feature from X" Committed revision 3. When commiting, bzr records both the previous revision and the merged revision as ancestor.

Matthieu Moy (CSA/IISc) DVC October 2006 < 33 / 43 >

slide-67
SLIDE 67

Prehistory History Linux Bazaar Conclusion

Merging

Space of possible revisions

Matthieu Moy (CSA/IISc) DVC October 2006 < 34 / 43 >

slide-68
SLIDE 68

Prehistory History Linux Bazaar Conclusion

Merging

Space of possible revisions Existing revision

Matthieu Moy (CSA/IISc) DVC October 2006 < 34 / 43 >

slide-69
SLIDE 69

Prehistory History Linux Bazaar Conclusion

Merging

Space of possible revisions Existing revision User works on a local branch

Matthieu Moy (CSA/IISc) DVC October 2006 < 34 / 43 >

slide-70
SLIDE 70

Prehistory History Linux Bazaar Conclusion

Merging

Space of possible revisions Existing revision User works on a local branch local commit

Matthieu Moy (CSA/IISc) DVC October 2006 < 34 / 43 >

slide-71
SLIDE 71

Prehistory History Linux Bazaar Conclusion

Merging

Space of possible revisions Existing revision User works on a local branch local commit New upstream revisions

Matthieu Moy (CSA/IISc) DVC October 2006 < 34 / 43 >

slide-72
SLIDE 72

Prehistory History Linux Bazaar Conclusion

Merging

Space of possible revisions Existing revision User works on a local branch local commit New upstream revisions

Matthieu Moy (CSA/IISc) DVC October 2006 < 34 / 43 >

slide-73
SLIDE 73

Prehistory History Linux Bazaar Conclusion

Merging

Space of possible revisions Existing revision User works on a local branch local commit New upstream revisions

Matthieu Moy (CSA/IISc) DVC October 2006 < 34 / 43 >

slide-74
SLIDE 74

Prehistory History Linux Bazaar Conclusion

Merging

Space of possible revisions Existing revision User works on a local branch local commit New upstream revisions

Matthieu Moy (CSA/IISc) DVC October 2006 < 34 / 43 >

slide-75
SLIDE 75

Prehistory History Linux Bazaar Conclusion

Merging

Space of possible revisions Existing revision User works on a local branch local commit New upstream revisions merge runs upstream

Matthieu Moy (CSA/IISc) DVC October 2006 < 34 / 43 >

slide-76
SLIDE 76

Prehistory History Linux Bazaar Conclusion

Merging

Space of possible revisions Existing revision User works on a local branch local commit New upstream revisions merge runs upstream

Matthieu Moy (CSA/IISc) DVC October 2006 < 34 / 43 >

slide-77
SLIDE 77

Prehistory History Linux Bazaar Conclusion

Merging

Space of possible revisions Existing revision User works on a local branch local commit New upstream revisions merge runs upstream "commit" creates new revision

Matthieu Moy (CSA/IISc) DVC October 2006 < 34 / 43 >

slide-78
SLIDE 78

Prehistory History Linux Bazaar Conclusion

Merging

Space of possible revisions Existing revision User works on a local branch local commit New upstream revisions merge runs upstream "commit" creates new revision

And so on ... !

Matthieu Moy (CSA/IISc) DVC October 2006 < 34 / 43 >

slide-79
SLIDE 79

Prehistory History Linux Bazaar Conclusion

Merging

Space of possible revisions Existing revision User works on a local branch local commit New upstream revisions merge runs upstream "commit" creates new revision

And so on ... !

Resulting revision history is a DAG

Matthieu Moy (CSA/IISc) DVC October 2006 < 34 / 43 >

slide-80
SLIDE 80

Prehistory History Linux Bazaar Conclusion

Other Features of Interest

Light Checkout: A working tree pointing to an branch located somewhere else (a la CVS). bzr update to get changes from the branch into the working tree, Heavy Checkout: A working tree plus a duplicate of the branch used as a

  • cache. Allows local commits (bzr commit --local),

Shared repository: Multiple branches sharing the common revisions for storage, Revision Bundle: Pack a set of revisions in a single file (to be sent by email and merged in another branch for example), together with a human-readable diff, Plugins: Extensibility via a plugin system in Python, Foreign Branches: Experimental plugins to access a Subversion branch directly with bzr.

Matthieu Moy (CSA/IISc) DVC October 2006 < 35 / 43 >

slide-81
SLIDE 81

Prehistory History Linux Bazaar Conclusion

Outline

1

Motivations, Prehistory

2

History and Categories of Version Control Systems

3

Version Control for the Linux Kernel

4

Bazaar (bzr): One Decentralized Revision Control System

5

Conclusion

Matthieu Moy (CSA/IISc) DVC October 2006 < 36 / 43 >

slide-82
SLIDE 82

Prehistory History Linux Bazaar Conclusion

Benefit of Version Control

Working alone:

◮ Possibility to revert to a previous revision, ◮ Makes it easy to review your own code (before committing), ◮ Synchronization of multiple machines.

Collaborative development:

◮ One can work without disturbing others, ◮ Merge is automated. Matthieu Moy (CSA/IISc) DVC October 2006 < 37 / 43 >

slide-83
SLIDE 83

Prehistory History Linux Bazaar Conclusion

Benefit of Version Control

Working alone:

◮ Possibility to revert to a previous revision, ◮ Makes it easy to review your own code (before committing), ◮ Synchronization of multiple machines.

Collaborative development:

◮ One can work without disturbing others, ◮ Merge is automated.

Text editing without version control is like sky diving without a parachute!

Matthieu Moy (CSA/IISc) DVC October 2006 < 37 / 43 >

slide-84
SLIDE 84

Prehistory History Linux Bazaar Conclusion

Benefit of Decentralized Version Control

Easy branch/merge, Simplifies permission management (no need to give any permission to other users), Disconnected operation (useful for laptop users in particular).

Matthieu Moy (CSA/IISc) DVC October 2006 < 38 / 43 >

slide-85
SLIDE 85

Prehistory History Linux Bazaar Conclusion

Other Decentralized Version Control Systems

Monotone: A clever system based on hashes (SHA1). Inspired git a lot. http://venge.net/monotone/ git: Designed for speed. Used by the Linux kernel, http://git.or.cz/ Mercurial: Close in concepts and performance to git. Written in python, with a plugin system. http://www.selenic.com/mercurial/ Darcs: Based on a powerful patch theory. Was the first system to have a really simple user-interface. http://abridgegame.org/darcs/ SVK: Distributed Version Control built on top of Subversion. http://svk.bestpractical.com/

Matthieu Moy (CSA/IISc) DVC October 2006 < 39 / 43 >

slide-86
SLIDE 86

Prehistory History Linux Bazaar Conclusion

Emacs Users

[ Warning: Self advertisement ] Most version control systems have an Emacs integration. Check out DVC: http://download.gna.org/dvc/

Matthieu Moy (CSA/IISc) DVC October 2006 < 40 / 43 >

slide-87
SLIDE 87

Prehistory History Linux Bazaar Conclusion

Version Control and Backups

Version Control is a good complement for backups But your repository should be backed-up/replicated ! (many users lost their data and their revision history at the same time with a disk crash) Usually:

◮ Version Control = User side (manual creation of project, manual add

  • f source files, manual commits, . . . )

◮ Backup = System Administrator side (cron job, backing up everything) Matthieu Moy (CSA/IISc) DVC October 2006 < 41 / 43 >

slide-88
SLIDE 88

Prehistory History Linux Bazaar Conclusion

Last Word on Backups

Don’t trust your hard disk, Don’t trust a CD (too short life), Don’t trust yourself, Don’t trust Anything! REPLICATE!!!

◮ Multiple machines for normal work ◮ Multiple sites for important work (are you ready to loose you thesis if

your house or lab burns?)

Matthieu Moy (CSA/IISc) DVC October 2006 < 42 / 43 >

slide-89
SLIDE 89

Prehistory History Linux Bazaar Conclusion

Learn More

Bazaar: http://bazaar-vcs.org/ Bazaar Docs: http://doc.bazaar-vcs.org/ Version Control: http://en.wikipedia.org/wiki/Revision control This presentation: http://www-verimag.imag.fr/∼moy/slides/bzr/

Matthieu Moy (CSA/IISc) DVC October 2006 < 43 / 43 >