Revision control with Mercurial

35
Revision Control with Mercurial Paulo Gandra de Sousa @ pagsousa

description

 

Transcript of Revision control with Mercurial

Page 1: Revision control with Mercurial

Revision Control with MercurialPaulo Gandra de Sousa

@pagsousa

Page 2: Revision control with Mercurial

Agenda

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

Page 3: Revision control with Mercurial

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

Page 4: Revision control with Mercurial

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

Basic concepts

• Repository• Trunk• Add• Check in

• Revision• Diff• Head

Page 5: Revision control with Mercurial

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

• Check out• Working copy• Revert• Check in

Page 6: Revision control with Mercurial

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

Handling conflits

• Diff• Merge• Resolve

Page 7: Revision control with Mercurial

Handling files

• Add• Delete• Rename• Forget

• Lock• To avoid

Page 8: Revision control with Mercurial

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/

Page 9: Revision control with Mercurial

Geographicaly distributed teams

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

Page 10: Revision control with Mercurial

Revisions, heads, tips

Merge changeset

head

Head; tip

Page 11: Revision control with Mercurial

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

Page 12: Revision control with Mercurial

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

Page 13: Revision control with Mercurial

http://hginit.com/02.html

• Joel and Rose edit and commit in their local repository

• Rose pushes to the central repository

Page 14: Revision control with Mercurial

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

Page 15: Revision control with Mercurial

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

Page 16: Revision control with Mercurial

TOOLSMercurial, TortoiseHG, HGE, Netbeans

Page 17: Revision control with Mercurial

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

Page 18: Revision control with Mercurial

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/

Page 19: Revision control with Mercurial

Shell extension menu

• Clone• Init

Page 20: Revision control with Mercurial

Shell extension menu

• Commit

• Status• Add• Revert• Remove

• Update• Synchronize

Page 21: Revision control with Mercurial

Hg Workbench

Page 22: Revision control with Mercurial

HGE (Eclipse plugin)

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

Page 23: Revision control with Mercurial

New project

Page 24: Revision control with Mercurial

Project context menu

Page 25: Revision control with Mercurial

File context menu

Page 26: Revision control with Mercurial

Commit

Page 27: Revision control with Mercurial

Compare

Page 28: Revision control with Mercurial

History

Page 29: Revision control with Mercurial

Netbeans

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

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

Page 30: Revision control with Mercurial

Clone repository

Page 31: Revision control with Mercurial

Context

Page 32: Revision control with Mercurial

History

Page 33: Revision control with Mercurial

Commit

Page 34: Revision control with Mercurial

Push

Page 35: Revision control with Mercurial

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/