M E R C U R I A L (The Source Control Management) Jamshaid Iqbal Janjua, Shahid Awan jamshaid.janjua@kics.edu.pk shahidawan@kics.edu.pk Al-Khawarizmi Institute of Computer Science University of Engineering & Technology, Lahore, Pakistan. ICOSST-2010, Dec 22-24, Lahore, Pakistan
Agenda Introduction Source Control Management Mercurial Basic Concepts Branches Merging Changesets Mercurial Features Underlying Model Talking to Other Systems Third Party Tools Demonstration
Source Control Management (SCM) Source Control Management is the administrative organization of Changes to Documents, Programs, and Other information stored as computer files. Also known as Revision Control System (RCS) Version Control System (VCS)
SCM :: Usage Why is Source Control Management Needed? Avoid Manual Management (an error-prone task) Tracks the History of the Project Easy to Manage the Drift Helps to Recover from Mistakes
SCM :: Options Software Maintainer Development Status Repository Model License Cost Mercurial Matt Mackall Actively developed Distributed GPL Free SVN CollabNet, Inc Actively developed Client server Apache/BSD style Free Git Junio Hamano Actively developed Distributed GPL Free CVS The CVS Team Maintained but new features not added Client server GPL Free VSS Microsoft Serious bug fixes only Shared Folder Proprietary Non -free
Knowing Mercurial Main Features Free source control management tool & Easier to learn Cross-platform, Fast, Distributed revision control system Robust support for branching & merging Scales to the demands of Real, Challenging environments High performance & Extensible Strong focus on back & forward Compatibility New Clients can Read/Write all old formats on disk Old clients can read/write to all new Servers Strong focus on Data Safety Files are not overwritten, only appended to Easier to recover from disk crashes http:// www.mercurial.selenic.com/
Why Distributed? Distributed SCM gives you: Offline commits Rich set of fast local operations Derived effects Fine file commits Searchable history Branching & Merging becomes a natural task Enables better Work flows
Who is Using Mercurial? And Many Others..
Mercurial Commands Local Commands hg commit : Save a snapshot into current repository hg update : Checkout revision into working directory hg merge : Join different lines of history Network Commands hg pull hg push : Retrieve changesets from another repository : Send your changesets to another repository Administrative Commands hg clone : Copies or downloads a repository hg add : Adds a file or directory to the local source tree hg remove : Removes a file or directory from the local source
Key Concepts Repository A Remote Copy of Source Tree with Revision History. Working Copy Also known as working directory. It's the Top-level Directory in a repository, in which the plain versions of files are available to read, edit and build. Changeset It's a Collection of all the Changes that lead to a new revision of the repository. Hello.java Makefile commit update push pull User A
Mercurial Branches A Key Concept Parallel lines of development Used to track releases Used to isolate disruptive changes 1.0.1 1.0.2 1.0
Mercurial Merging A Key Concept Combines two branches Used to merge back bug fixes Used to integrate feature branches 1.0.1 1.0.2 1.0
Moving Changesets Around USER A USER B 0 A1 A2 A3 pull 0 B1 B1 USER C 0 C1 C2 C3 C4 B1 A1 A2 A3
Distributed Revision Control Mercurial duplicates the history on many servers USER A USER A s Laptop USER B USER C
Distributed Revision Control Mercurial duplicates the history on many servers USER A USER A s Laptop SERVER USER B USER C
Workflow In a Team Mercurial scales from a single team. USER A USER C TEST SERVER PROD SEVER USER B
Workflow Between Company Divisions. to enterprise wide development. SITE B SITE A SITE C
Workflow Between Two Computers. to working with yourself USER A USER B
The Underlying Model A Mercurial changeset conceptually consists of: 0-2 parent changeset IDs Root changeset has no parents Normal changeset has one parents Merge changeset has two parents Date, username, commit message Difference from first parent changeset Changeset ID is computed as SHA-1 hash of above.
Migration The convert extension in Mercurial can import history from CVS, SVN, Git, Bazaar, Darcs, etc. Incremental conversion The hgsubversion extension in Mercurial let s you: Use hg clone on SVN Url Use hg pull to convert new SVN revisions Use hg push to commit changesets to SVN Server Goal: make Mercurial a better Subversion client then SVN!
Third-Party Tools Tools with Mercurial support: Shell integration: TortoiseHg(Windows, Mac, Linux) IDEs: Eclipse, NetBeans, IntelliJ, Visual Studio, Emacs Project Support: Trac, JIRA, Maven, Hudson, BuildBot Ant tasks
Installation
Tortoise Overlay Icon Server
TortoiseHg Global Settings
D E M O N S T R A T I O N
Conclusion Free source control management tool & Easier to Learn Cross-platform, Fast, Distributed Revision Control system Simple yet Strong Model for Branching & Merging Scales to the demands of Real, Challenging Environments Light Weight & High performance
Further Information http://mercurial.selenic.com/ http://hgbook.red-bean.com http://hginit.com http://mercurial.selenic.com/wiki/tutorial http://www.mercurial.ch http://jaoo.dk/dl/2009/web/mercurial.pdf http://www.softwareprojects.com/resources/programming/tmercurial-version-control-1853.html
Thank You!