Page 1
ICOSST-2010, Dec 22-24, Lahore, Pakistan
Jamshaid Iqbal Janjua, Shahid Awan
[email protected]
[email protected]
M E R C U R I A L (The Source Control Management)
Al-Khawarizmi Institute of Computer Science
University of Engineering & Technology, Lahore, Pakistan.
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 2
Agenda
Introduction
Source Control Management
Mercurial
Basic Concepts
Branches
Merging
Changesets
Mercurial Features
Underlying Model
Talking to Other Systems
Third Party Tools
Demonstration
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 3
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)
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 4
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
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 5
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
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 6
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:/
/ w
ww
.mercu
rial.se
lenic.co
m/
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 7
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
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 8
Who is Using Mercurial ?
And Many Others …..
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 9
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 : Retrieve changesets from another repository
hg push : 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
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 10
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
User A
push
pull
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 11
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
1.0.1 1.0.2
1.0
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 12
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
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 13
Moving Changesets Around
0 A1 A2 A3
C1 0
B1 0
B1
C2
A1
C4
A2
C3
B1
A3
USER A USER B
USER C
pull
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 14
Distributed Revision Control
Mercurial duplicates the history on many servers
USER B USER C
USER A USER A’s
Laptop
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 15
Distributed Revision Control
Mercurial duplicates the history on many servers
USER B USER C
USER A USER A’s
Laptop
SERVER
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 16
Workflow In a Team
Mercurial scales from a single team ….
USER A
USER C
USER B
TEST
SERVER
PROD
SEVER
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 17
Workflow Between Company Divisions
…. to enterprise wide development ….
SITE A
SITE B
SITE C
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 18
Workflow Between Two Computers
…. to working with yourself
USER A USER B
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 19
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.
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 20
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!
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 21
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
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 22
Installation
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 23
Tortoise Overlay Icon Server
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 24
TortoiseHg Global Settings
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 25
D E M O N S T R A T I O N
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 26
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
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 27
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/t-
mercurial-version-control-1853.html
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010
Page 28
Thank You!
Presented in Open Source Series Workshop 2010
22-24 December, 2010 © ICOSST 2010