Mercurial Distributed Version Control
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Mercurial Distributed Version Control

on

  • 4,951 views

Learn about the Mercurial Distributed Version control system and some of the awesome features it has.

Learn about the Mercurial Distributed Version control system and some of the awesome features it has.

Statistics

Views

Total Views
4,951
Views on SlideShare
4,462
Embed Views
489

Actions

Likes
6
Downloads
132
Comments
0

7 Embeds 489

http://frontrangephp.org 416
http://www.slideshare.net 26
http://www.frontrangephp.org 25
http://www.techgig.com 16
http://translate.googleusercontent.com 3
http://sidengo.com 2
https://www.linkedin.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />
  • <br /> <br />

Mercurial Distributed Version Control Presentation Transcript

  • 1. Mercurial Distributed Source Control Presented by David Stockton for Front Range PHP User Group April 28, 2010
  • 2. “If debugging is the process of removing bugs, then programming must be the process of putting them in.” - Anonymous
  • 3. Source Control in a Nutshell A great way to avoid catastrophic mistakes with your code Essential - If your code is more than a few lines long and you’re not using source control, you must not think very highly of your work. If you’re not using source control, start now. Even CVS is better than no source control. (Not sure about VSS though)
  • 4. Source Control in a Nutshell If you are working with a team (read, one or more other people) source control is essential If you’re working by yourself and you’ve ever made a mistake, source control is essential If you ever wished you could undo something you just did, source control is essential If you need to maintain different versions of the same code, source control is essential.
  • 5. I could go on, but...
  • 6. I could go on, but... The bottom line is...
  • 7. I could go on, but... The bottom line is... Source control is absolutely essential!
  • 8. Questions? Questions about source control in general?
  • 9. Goals of Source Control Keep your source code safe Allow you to look at different versions of your code Allow multiple developers to work simultaneously Allow multiple “branches” of code to be worked on at the same time
  • 10. Common/Popular Source Control Tools CVS SVN (Subversion) ClearCase Perforce Microsoft Visual SourceSafe Git Mercurial
  • 11. Common/Popular Source Control Tools BitKeeper Telelogic Synergy Visual Studio Team System StarTeam RCS Tons of others...
  • 12. Types of Source Control Client Server Model (CVS, SVN, etc) Distributed (Git, Mercurial)
  • 13. Mercurial Distributed Version Control System Works the way you want it instead of forcing you to use it in a certain way Used by lots of big projects
  • 14. Who uses Mercurial? Adium Audacious BitBucket Growl Linux HA LinuxTV
  • 15. Who uses Mercurial? Mozilla Netbeans Mutt OpenOffice OpenJDK OpenSolaris
  • 16. How does it work? Probably not the way you’d think if you’ve used CVS or SVN or other client server VCS (Version Control System)
  • 17. How it’s different No central server ... or at least not one that’s required Works on changesets, not file or repository versions Changesets allow merges (shudder) to be simple This is a good thing since you’ll be merging a lot Learn to not be afraid of the merge
  • 18. What else? Doing a checkout gives you a full copy of the repository Including all changes, etc Lose a server? Just clone another copy of the repository
  • 19. What can you do with it? Pretty much anything Clone a repository to try out some experimental code If it works, keep it If not, delete it, no harm done And no evidence of your failed attempt
  • 20. What can you do with it? Work on a plane (and still check in code) Collaborate with a colleague in a coffee shop Pick and choose what you want in your repository Push, pull and clone from other repositories
  • 21. Make your VCS work how you do! Work on the road Work from home Work from work Work from a plane Work from a train Work in an automobile (if you’re not driving)
  • 22. #1 Awesome Thing Branches are easy ... But they’re pretty easy in CVS and SVN too
  • 23. Branches If you’re working on Feature A and I am working on Feature B, we’ve essentially branched Two or more people working on code based on the same thing creates branches Named branches Unnamed branches Branches by cloning
  • 24. #2 Awesome Thing Branches being easy is great, but only if... Merges are super easy! Most merges handled automatically Merge conflicts can be handled by a tool of your choice I like kdiff3
  • 25. #3 Awesome Thing No network? No problem Work from anywhere Collaborate with a colleague in the middle of nowhere
  • 26. Installation Mercurial is cross platform with excellent support on Windows, Linux and Mac http://mercurial.selenic.com/ Download binary for Windows or Mac ... or apt-get install mercurial yum install mercurial ermerge mercurial pkg install SUNWmercurial
  • 27. Create a new Repository
  • 28. What’d that do?
  • 29. You now have a working repository If you don’t do command line there are other ways IDE Integration - Eclipse, NetBeans, IntelliJ, Emacs, Vim, TextMate, Visual Studio Windows integration with TortoiseHg Build/Management tools with Hg support: CruiseControl, JIRA, Trac, Maven, Redmine, Hudson, ant, etc
  • 30. Add some code Use ‘hg add’ to tell Mercurial about the files you want it to track Use ‘hg commit’ to tell Mercurial to check in code hg ci hg com
  • 31. Adding and Committing
  • 32. Look at the repository
  • 33. Look at the repository
  • 34. Make some more changes
  • 35. Easy peasy...
  • 36. Enter developer #2
  • 37. Developer 2 Commits
  • 38. What does that commit look like? Pretty much the same Why? Luke Skywalker has his own repository
  • 39. How can I get Luke’s Change? Use ‘hg push’ from Luke’s instance Use ‘hg pull’ on my instance to Luke’s instance
  • 40. What’d that do?
  • 41. What does it do to me? Where are the changes? Pushes do not affect the working copy Why? Updating the workspace could make me lose my work
  • 42. How to see those changes? Use ‘hg up’ Update your own workspace
  • 43. Let’s mix it up Dave makes a change to cookie to specify flour amount Luke makes a change to cookie to add eggs
  • 44. A matter of timing...
  • 45. Dave commits changes
  • 46. Luke commits changes
  • 47. But then... Don’t use -f to force... Don’t do it...
  • 48. Let’s merge
  • 49. Quick recap First check-in goes in Second check-in based on same code needs merge ‘hg pull’ + ‘hg merge’ took a fraction of a second Merge was correct Luke now needs to commit the merge and push back to Dave’s server
  • 50. Merge Check-in
  • 51. And it now looks like...
  • 52. Still too easy... Let’s try a merge conflict... Dave needs more flour in the recipe Also, Dave hasn’t updated his workspace with the merge results Luke wants to use cake flour
  • 53. Merge conflict in the making
  • 54. Now the fun part Luke uses the force and does a check in and push before Dave does a check-in
  • 55. Here comes trouble... Dave tries to commit ... And it works ...
  • 56. But... it created a new head
  • 57. To get Luke’s changes...
  • 58. Merge 2 heads into 1 All that junk is kdiff3 launching. I should fix that...
  • 59. Merge in kdiff3 Notice that the eggs part was automatically resolved
  • 60. Merge completed
  • 61. Commit the merge
  • 62. What’d that do?
  • 63. Crazy branch/merges The example to the right was done with just 5 users but I was purposely trying to make lots of weird branch merge situations occur.
  • 64. Command overview hg clone - clone a repository hg merge - merge changes together hg add - tell Mercurial to start caring about some files hg commit - commit a new changeset hg push - send your changesets to another server hg pull - retrieve changesets from another server
  • 65. Command overview cont... hg update - Update your local workspace with the stuff from hg pull hg annotate - show which changeset is responsible for each line in a file hg diff - show the differences between files in your workspace and the committed file hg export - dump the header and diffs for one or more changesets
  • 66. Command overview cont... hg forget - Forget the specified files (remove from repository, not from workspace) when you commit hg log - show revision history hg remove - delete file and remove from repository when you commit hg serve - simple http server to show the repository (useful for coffee shop working)
  • 67. hg addremove - add all new files, remove deleted files hg backout - reverse effect of earlier changeset hg bisect - search changesets (DEMO) hg branch - set or show branch names hg branches - list all branches hg copy - mark file as copied for next commit (DEMO) hg heads - show repository or branch heads
  • 68. hg help - Where I’m getting this list of commands hg identify - identify the working copy hg incoming - show new changesets in source hg init - create a new repository hg outgoing - show changesets not in destination hg parents - show parents of working directory or revision
  • 69. Command overview cont... hg status - Show what’s going to happen when you commit hg summary - Summarize state of working directory hg paths - show aliases for remote repositories hg rename - rename a file (same as hg copy + hg remove) (DEMO) hg tag - tag a revision hg tags - show tags in repository
  • 70. Holy crap... That wasn’t even all the commands Or all the coolness
  • 71. As time permits... hg bisect demo hg copy demo hg rename demo hg mq - Patching, orthogonal mutable changesets
  • 72. Other sweet awesomeness Hooks Attic ACL
  • 73. Excellent Resources Quick and easy overview: http://hginit.com - Joel Spolsky’s explanation of Mercurial Mercurial: The Definitive Guide Available online at http://hgbook.red-bean.com/read/ Or buy from Amazon.com or O’Reilly Media
  • 74. Questions?