Git Mercurial Distributed Configuration Management CSCI 5828 Foundations of Software Engineering 2010 03 19 Dmitry Duplaykin Paul Madden Overview What is configuration management A brief history of CM systems State of the art Subversion Intro to distributed CM Git Mercurial Head to head comparison with Subversion Tips and Summary 2 What is configuration management A number of aliases Pilone Miles call it version control a tool usually a piece of software that will keep track of changes to your files and help you coordinate different developers working on different parts of your system at the same time Also known as revision control e g rcs Revision Control System or source code management e g http git scm com 3 What is configuration management Typically offers features allowing Code check out check in Branching Merging Tagging Recovery from mistakes Display of specific code changes Review of historical metadata Two architectural flavors Centralized CVS Subversion Distributed git Mercurial 4 A brief history of CM systems 1972 Source Code Control System sccs The original Proprietary Unix component 1982 Revision Control System rcs SCCS alternative Like SCCS works on single files not entire projects 1990 Concurrent Versions System cvs Built on and extended RCS entire project tree support client server network model allowed concurrent work without sccs rcs style locking by supporting merging 2000 Subversion svn A better CVS In so many ways Developer sought CVS pros without its cons 2005 Git Mercurial Distributed CMS Many many others both free and proprietary 5 State of the art Subversion Repository creation maintenance with svnadmin tool Either in client server mode or on local file URIs Network access via dedicated server sshd Apache Choice of storage databases svn s own fsfs simple Berkeley DB more features Offline diffs Copies tags branches are cheap Updates stored as diffs skip deltas File reconstructed by sequentially applying diffs 6 State of the art Subversion Client svn utility provides functions like checkout co get files from repository commit ci upload changes to repository copy cp create branches tags among other uses revert undo local changes to working copy status show what has changed in working copy or what updates are waiting in the repository update up bring working copy up to date with repo merge e g bring branch up to date with trunk diff compare revisions to each other working copy log show historical log messages wrappers for system commands like ls rm mv cp etc 7 An svn workflow svnadmin create repository only server side action svn import initial set of files into repository creates r1 svn co first working copy modify existing files create new ones svn add new files to place under revision control svn status to see what has changed locally svn revert to undo changes svn ci new and changed files creates r2 svn log to view log message metadata svn mv to rename svn rm to delete files svn ci these changes creates r3 svn co an older r2 working copy 8 An svn workflow svn diff r1 and r2 of modified file to see changes change file in 2nd copy of head svn ci look for changes in 1st copy of head svn up svn cp to create a tagged revision svn cp to create a branch svn co branch make two commits svn merge onto trunk commit 9 Transition to distributed CM Conceptual model looks like this 10 More complexity with git 11 git background Developed by Linus Torvalds in 2005 Linux Kernel team needed a new CM solution after BitKeeper licensing changed Design requirements fast distributed no central server every copy has complete development history in its git directory secure essentially impossible to change history Git differences entire project trees not individual files Revisions tracked with a SHA1 hash of information from the current project state Two storage locations changeable index immutable object database 12 Projects using git Among many others Android Debian Clojure Digg jQuery Perl Samba Ruby on Rails And of course famously the Linux kernel Linus Torvalds developed Linux because Andrew Tannenbaum wouldn t let him use Minix He developed git because BitKeeper revoked their free license Lesson Linux Torvalds will eat your lunch 13 Mercurial background Started by Matt Mackall at the same time as git Properties Written in Python 95 in Python core routines in C It s distributed Fast Design features Uses SHA 1 hashes like git Uses HTTP based protocol All above matches Google land religion Will be referred to as hg since commands start with it 14 Projects using Mercurial The list is quite long the most famous ones are Mozilla OpenJDK OpenSolaris OpenOffice org Symbian OS Go GNU Octave Netbeans The Python developers have announced that they will switch from Subversion to Mercurial when hgsubversion an extension that allows using Mercurial as a Subversion client and that has been under development since September 2009 is released 15 Head to head Create a repository initialize with files svn svnadmin create repos demo mkdir p import branches import tags import trunk cp source files import trunk svn import import file repos demo git cd source files git init git add git commit editor will open for commit message hg cd hg hg hg source files init add commit m Initial version 16 Head to head Get a working copy In Subversion we need to check out a working copy from the repository svn svn co file repos demo trunk wc git We already have a versioned working copy hg We have it 17 Head to head Edit add files view changes svn svn add fruit svn status concise view svn diff show actual deltas git git add fruit git status concise view git diff show actual deltas hg hg add fruit hg status show changed added deleted files hg diff show actual deltas 18 Head to head Revert changes We ve changed our minds about changing numbers svn svn revert numbers to checked out revision git git checkout numbers fetches from index git checkout HEAD number from database hg hg revert numbers What if you had committed Use this hg rollback It will help but only if you haven t pushed this change to central repository Then you have to think about it 19 Head to head Commit changes Let s commit the changes we ve decided to keep svn svn ci svn up update working copy s revision info git git add letters fruit stage to index git commit commit index to database or git commit a stage commit in one hg hg add letters fruit hg commit 20 Head to head View current status log log commands show most recent actions first svn svn info
View Full Document
Unlocking...