390 likes | 656 Views
Introduction to Distributed Version Control with Mercurial. John C. Zablocki Development Lead, Magazine Radar Engineering Lead, ImOK Philly Code Camp 2011.1 2011-04-09. Agenda. Distributed Version Control. It’s not just for kernel developers…. Distributed.
E N D
Introduction to Distributed Version Control with Mercurial John C. Zablocki Development Lead, Magazine Radar Engineering Lead, ImOK Philly Code Camp 2011.1 2011-04-09
Distributed Version Control It’s not just for kernel developers…
There is no centralized repository • A centralized workflow is possible and common • Working copies are full repositories • Built in redundancy • Commits are made to local history first • Frequent commits without affecting other developers • Revision numbers are replaced by changesets • Better merging capabilities Distributed Version Control Basics
Alice Repository Commit Bob Checkout Carl Commit Centralized Workflow
Commit Alice Centralized Repository Push Push Bob Pull Pull Carl Distributed Workflow
Clone Remote Repository Local History Modify Add Push Commit Basic Workflow - Push
Local History Remote Repository Update Merge Pull Commit Basic Workflow - Pull
Mercurial Basics http://mercurial.selenic.com/wiki/UnderstandingMercurial
Maintained by Selenic • Sponsored by Microsoft, Google, Atlassian, FogCreek and many others • Open source and licensed under GPL • Written mostly in Python (2.4-2.7), with some portable C where necessary for performance • Binaries available for Windows, GNU/Linux, Mac OSX, Solaris 11 Express • It’s kind of awesome About Mercurial
Repository – the .hg directory in the repository root • Working Directory – top-level directory in a repository • Changeset – atomic collection of changes to files • Revision – a distinct changeset in a repository • Head – a changeset with no child changesets • Tip – the most recently changed head Mercurial Glossary
Mercurial separates the act of committing new code from the act of inflicting it on everybody else. - Joel Spolsky
.hg What’s in a Repository?
Cset Head Tip Revisions, Changesets, Heads and Tip
Bob clone’s Alice’s Repo Bob commits two changes (local) Cloning, making changes, merging, pulling and updating
Alice commits one change locally Bob pulls Alice’s changes Bob merges Alice’s changes Cloning, making changes, merging, pulling and updating
Bob commits to create a new changeset Cloning, making changes, merging, pulling and updating
Alice pulls from Bob’s repository Alice’s updates her working directory Cloning, making changes, merging, pulling and updating
Frequent commits without affecting others • Better Merging • Mercurial stores more information about changes • More efficient storage • Revisions contain only deltas of changed files • Faster checkouts (cloning) • Incremental snapshots • Redundancy • Every developer has a copy of the repository Mercurial Advantages
Disambiguation • hg com == hg commit • Commit is on entire directory • Not ideal for partial checkout scenarios • Empty directories are not tracked • Add EMPTY file Mercurial Concepts
Mercurial.ini or .hgrc • Global configuration • Username • [ui]username = johnzablocki • Auth • [web]push_ssl= falseallow_push= * • Extensions • [extensions]hgsubversion= path/to/extensionhgexternals= path/to/extensionmercurial_keyring= • Hooks • .hg/hgrc • Repository specific version of Mercurial.ini • Not cloned • .hgignore • Include in working directory root to set ignore patterns for all commits • #-- Directoriesbin/BIN/ Mercurial Configuration
Mercurial Extensions Nothing to compile…
ACL Extension • Allows fine grained access control over parts of a repository using deny and allow lists • Keyring Extension • Securely save HTTP passwords in OS keyring Security Extensions
hgsubversion • Use Mercurial as an SVN client • tfs • Update Team Foundation Server work items • hg-git • Push and pull from a Git server • cvscommit – Push changesets to CVS Interoperability Extensions
hgexternals – Pull external repositories into a Mercurial repository • fetch – Pull, merge and update in one step • purge – Purge all untracked files in a repository Other Useful Extensions
Mercurial on Windows Yes, there’s a Tortoise…
Yet another shell extension to add to your context menu in Explorer! • Contains useful Python extensions TortoiseHg
Non-trivial • CGI -http://www.jeremyskinner.co.uk/mercurial-on-iis7/ • WSGI - http://www.eworldui.net/blog/post/2010/04/08/Setting-up-Mercurial-server-in-IIS7-using-a-ISAPI-module.aspx Running Hg on IIS
http://dllHell.net - my blog • http://www.CodeVoyeur.com- my code • http://www.linkedin.com/in/johnzablocki • http://twitter.com/codevoyeur • http://mercurial.selenic.com- Mercurial site • http://bitbucket.org • http://about.me/johnzablocki Links