GTALUG Short Talk On Mercurial

1,159 views

Published on

I gave a short talk on Mercurial at GTALUG on 8th December, 2009.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,159
On SlideShare
0
From Embeds
0
Number of Embeds
11
Actions
Shares
0
Downloads
18
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

GTALUG Short Talk On Mercurial

  1. 1. What is Revision Control
  2. 2. • Allows multiple people to collaborate on a file.
  3. 3. Apple Oranges Cherries Milk Apple Pear Chinese Noodles Pomegranate Strawberries Bananas
  4. 4. $ rc add 2009-12-11.txt $ rc commit -m 'Added the Grocery List for Friday 11 Dec, 2009.'
  5. 5. $ rc log reversion: 1 author: Myles Braithwaite summary: Added the Grocery List for Friday 11 Dec, 2009.
  6. 6. Apple Oranges Cherries Milk Chinese White Pear Apple Pear Chinese Noodles Pomegranate Strawberries Bananas
  7. 7. $ rc status Modified: 2009-12-11.txt $ rc commit -m "It's called a Chinese White Pear not a Apple Pear Chinese Fruit"
  8. 8. $ rc diff -r 1 diff -r 1 2009-12-11.txt --- a/2009-12-11.txt Thu Dec 03 15:45:38 +++ b/2009-12-11.txt Thu Dec 03 15:51:39 @@ -2,7 +2,7 @@ Oranges Cherries Milk -Apple Pear Chinese Fruit +Chinese White Pear Noodles Pomegranate Strawberries
  9. 9. $ rc log reversion: 1 author: Myles Braithwaite summary: Added the Grocery List for Friday 11 Dec, 2009. reversion: 2 author: Other Person summary: It's called a Chinese White Pear not a Apple Pear Chinese Fruit
  10. 10. • Attempt to merge changes between two commits.
  11. 11. Apple Oranges Cherries Milk Chinese White Pear Noodles Pomegranate Strawberries Bananas Tea
  12. 12. $ rc commit -m 'Added tea to the list'
  13. 13. Apple @done Oranges @done Cherries @done Milk Chinese White Pear Noodles Pomegranate Strawberries Bananas
  14. 14. $ rc commit -m 'Went to the Grocery store and picked up Apples, Oranges, and Cherries.' The Repository is Out of Sync. Please merge the new changes.
  15. 15. $ rc merge Merge was successful. $ rc commit -m 'Merging changes'
  16. 16. Strawberries Bananas <<< HEAD Tea (Chai) >>>> <<<< 6 Tea (Green) >>>>
  17. 17. Mercurial Myles Braithwaite me@mylesbraithwaite.com @mylesb
  18. 18. History • Matt Machall • Originally developed for the Linux Kernel. • For some reason Torvalds’ picked Git?
  19. 19. Quick Facts • Implemented in the awesome Python programming language. • But includes a binary diff written in C.
  20. 20. • Originally written to run on Linux. • But it has been successfully ported to run natively on Mac OS X, Windows, and other Unix-like systems.
  21. 21. • Python (http://hg.python.org) • Mozilla (http://hg.mozilla.org) • OpenSolaris • OpenJDK (http://hg.openjdk.java.net) • OpenOffice.org • More here: http://j.mp/ProjectUsingHg
  22. 22. Installation (Linux) # Debian or Ubuntu $ aptitude install mercurial # Fedora $ yum install mercurial # Gentoo $ emerge mercurial # OpenSolaris $ pkg install SUNWmercurial
  23. 23. Installation (Windows) • Download and install the official exe. • Download TortoiseHg (http://tortoisehg.org) • Integrates Mercurial directly into explorer.
  24. 24. Installation (Mac OS X) • Install the DMG file.
  25. 25. Installation (PyPi) $ easy_install mercurial $ pip install mercurial
  26. 26. Installation from Source $ wget http://mercurial.selenic.com/ release/mercurial-1.4.1.tar.gz $ tar -xzf mercurial-1.4.1.tar.gz $ cd mercurial-1.4.1 $ python setup.py build $ sudo python setup.py install $ hg --version Mercurial Distributed SCM (version 1.4.1)
  27. 27. $ $EDITOR ~/.hgrc [ui] username = Myles Braithwaite <me@myles.tk>
  28. 28. $ export P_DIR=~/GroceryList $ $ # Create an empty repository on your $ # local machine. $ mkdir $P_DIR; cd $P_DIR $ hg init $ $ # Clone a remote repository. $ hg clone ssh://hg.mb/grocery_list $P_DIR destination directory: /home/m/GroveryList ... 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
  29. 29. $ echo 'Apple' > cat 2009-12-08.txt $ hg status ? 2009-12-08.txt $ hg add 2009-12-08.txt $ hg status A 2009-12-08.txt $ hg commit -m 'Added the grocery list for 9th Dec. 2009.'
  30. 30. $ hg status M 2009-12-08.txt $ hg diff diff -r 012549b5c017 2009-12-08.txt --- a/2009-12-08.txt 19:42:25 +++ b/2009-12-08.txt 19:44:46 @@ -1,1 +1,2 @@ Apples +Pizza $ hg commit -m 'I am hungry for some Pizza.'
  31. 31. $ hg log -l 2 changeset: 14:848072d17be0 tag: tip user: Myles Braithwaite date: 19:49:10 summary: I am hungry for some Pizza changeset: 13:012549b5c017 user: Myles Braithwaite date: 19:42:25 summary: Added the grocery list for 9th Dec. 2009.
  32. 32. $ hg annotate 2009-12-08.txt 13: Apples 14: Pizza 15: Nuts 16: Hot Chocolate Mix
  33. 33. $ hg tags tip 16:54c53457b1ac 2009-12-04 9:d1361977c248 $ hg tag 2009-12-08 $ hg tags tip 17:21598a08291c 2009-12-08 16:54c53457b1ac 2009-12-04 9:d1361977c248
  34. 34. $ cat .hgtags d1361977c2... 2009-12-04 54c53457b1... 2009-12-08
  35. 35. # If we cloned the repository. $ hg push $ hg push ssh://hg.mb/grocery_list
  36. 36. $ hg pull ssh://hg.mb/grocery_list pulling from ssh://hg.mb/grocery_list searching for changes ... (run 'hg update' to get a working copy) $ hg update 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  37. 37. $ hg log -l 2 changeset: 20:6dfef8e8a348 tag: tip user: Other Person summary: Remove some things fromthe list that were already entered on Friday' list. changeset: 19:1564f5195566 date: 16:30:18 summary: Added a shopping list for Sat. 12 Dec. 2009
  38. 38. $ hg diff -r 19 diff -r 1564f5195566 2009-12-12.odt Binary file 2009-12-12.odt has changed
  39. 39. $ # Using an extension we can call an $ # external program to run the diff. $ hg extdiff -p oodiff -r 19 --- GroceryList.1565f5195566/2009-12-12.odt +++ GroveryList/2009-12-12.odt @@ -1,12 +1,4 @@ - Oranges - - Apples - - Bananas - - Cereal - Cherios Beer
  40. 40. $ # To enable external diff's extension. $ $EDITOR .hg/hgrc [extensions] extdiff =
  41. 41. $ hg serve -n "Shopping List"
  42. 42. .hgignore # use global syntax. syntax: glob *.pyc *.pyo *~ # switch to regular expressions syntax. syntax: regexp ^.pc/
  43. 43. Find out more... • http://mercurial.selenic.com
  44. 44. Other cool stuff... • Google Code (http://code.google.com/p) • Bitbucket (http://bitbucket.org)

×