Revision control with Mercurial

Post on 23-Jan-2015

1.197 views 2 download

description

 

Transcript of Revision control with Mercurial

Revision Control with MercurialPaulo Gandra de Sousa

@pagsousa

Agenda

• The need• Basic concepts• Distributed revision control• Best practices• Tools

The need

• Share and synchronize among team members• Fast and reliable undo• For errors• For previous released versions

• Track changes• Connect with task & bug management

• Sandboxing

http://betterexplained.com/articles/a-visual-guide-to-version-control/

Basic concepts

• Repository• Trunk• Add• Check in

• Revision• Diff• Head

Basic edit flowhttp://betterexplained.com/articles/a-visual-guide-to-version-control/

• Check out• Working copy• Revert• Check in

http://betterexplained.com/articles/a-visual-guide-to-version-control/

Handling conflits

• Diff• Merge• Resolve

Handling files

• Add• Delete• Rename• Forget

• Lock• To avoid

Distributed version control

• Each user owns a repository and serve it to other users

• May use central (by convention) repository

http://betterexplained.com/articles/intro-to-distributed-version-control-illustrated/

Geographicaly distributed teams

http://www.ericsink.com/vcbe/vcbe_a4_lo.pdf

Revisions, heads, tips

Merge changeset

head

Head; tip

http://hginit.com/02.html

• Each user clones a “central” repository or inits a local repository

• Joel edits and/or adds files, check status, and commits in his local repository

http://hginit.com/02.html

• Joel pushes his change set to another (e.g., the “central”) repository

• Rose pulls from the central repository

push

pull

http://hginit.com/02.html

• Joel and Rose edit and commit in their local repository

• Rose pushes to the central repository

http://hginit.com/02.html

• Joel trys to push but gets an error

• Joel pulls the changes

• Joel merges the two heads and resolves any conflict

• Joel commits and pushes to the central repository

pull

Best practices

• Pull changes/Update before editing• Commit often• One commit – one issue• Write meaningful commit messages• Don’t commit broken code• Review the merge before commit• Setup change notifications• Read Diffs from other developers

TOOLSMercurial, TortoiseHG, HGE, Netbeans

Mercurial

• Download• http://mercurial.selenic.com/wiki/Download

• Tutorial• http://mercurial.selenic.com/wiki/Tutorial

• Hg definitive guide• http://hgbook.red-bean.com/

• Hosting (free and comercial)• http://mercurial.selenic.com/wiki/MercurialHosting

TortoiseHg

• Download• http://tortoisehg.bitbucket.org/download/

• Quick tutorial• http://tortoisehg.bitbucket.org/manual/1.1/quick.html

• TortoiseHg Manual• http://tortoisehg.bitbucket.org/manual/2.3/

Shell extension menu

• Clone• Init

Shell extension menu

• Commit

• Status• Add• Revert• Remove

• Update• Synchronize

Hg Workbench

HGE (Eclipse plugin)

• Download• http://javaforge.com/project/HGE

New project

Project context menu

File context menu

Commit

Compare

History

Netbeans

• Download• http://netbeans.org/downloads/

• Netbean’s Mercurial User Guide• http://netbeans.org/kb/docs/ide/mercurial.html

Clone repository

Context

History

Commit

Push

Bibliography

• A visual guide to version control, http://betterexplained.com/articles/a-visual-guide-to-version-control/

• Joel Spolsky, Hg Init, http://hginit.com/• Distributed version control illustrated,

http://betterexplained.com/articles/intro-to-distributed-version-control-illustrated/

• Eric Sink, Version Control by example. http://www.ericsink.com/vcbe/vcbe_a4_lo.pdf

• Tutorial, http://mercurial.selenic.com/wiki/Tutorial• Understanding Mercurial,

http://mercurial.selenic.com/wiki/UnderstandingMercurial• Version control 10 best practices,

http://blog.manishchhabra.com/2011/04/10-version-control-best-practices/